Closed petermcd closed 3 years ago
I originally posted the above issue on the official Ansible GitHub but was directed here instead
I am currently undecided as to whether this is now a bug or not and will leave it here for discussion.
The argument appears to be between the following options
- name: Add Fortinet Device
hosts: FortiManager
connection: httpapi
tasks:
- name: Discover and add device
register: command_output
vars:
ansible_command_timeout: 60
fmgr_device:
adom: "root"
device_username: "dfghjfgjmfgh"
device_password: "sfjrgkr"
device_ip: "192.168.1.1"
device_unique_name: "xhgmgkhyj"
mode: "add"
blind_add: "disable"
- name: fail
fail:
msg: "{{ command_output['ansible_module_results']['status']['message'] }}"
when: "-20042 == command_output['ansible_module_results']['status']['code']"
cc @Ftntcorecse @Ghilli3 @lweighall @p4r4n0y1ng click here for bot help
Hi
I have similar issue, when I try to run multple tasks in playbook its skip tje task and indivisual task working fine
Please update me if anyone have any update or any other workaround.
(devops) root@control-node01:~/home/devops/project# ansible --version ansible 2.10.14 config file = None configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /root/devops/lib/python3.8/site-packages/ansible executable location = /root/devops/bin/ansible python version = 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.
my playbook
tasks:
ansible-playbook -i inventory test_create_everything_thru_one_playbook.yml -vv ansible-playbook 2.10.14 config file = None configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /root/devops/lib/python3.8/site-packages/ansible executable location = /root/devops/bin/ansible-playbook python version = 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0] No config file found; using defaults [WARNING]: While constructing a mapping from /root/home/devops/project/test_create_everything_thru_one_playbook.yml, line 1, column 3, found a duplicate dict key (tasks). Using last defined value only. redirecting (type: modules) ansible.builtin.fmgr_fwpol_package to community.network.fmgr_fwpol_package Skipping callback 'default', as we already have a stdout callback. Skipping callback 'minimal', as we already have a stdout callback. Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: test_create_everything_thru_one_playbook.yml ***** 1 plays in test_create_everything_thru_one_playbook.yml
PLAY [fortimanagers] ***
TASK [Gathering Facts] ***** task path: /root/home/devops/project/test_create_everything_thru_one_playbook.yml:1 redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi ok: [fmg] META: ran handlers
TASK [Add Policy Package] ** task path: /root/home/devops/project/test_create_everything_thru_one_playbook.yml:29 redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi redirecting (type: modules) ansible.builtin.fmgr_fwpol_package to community.network.fmgr_fwpol_package [WARNING]: Found internal 'results' key in module return, renamed to 'ansible_module_results'. changed: [fmg] => {"ansible_facts": {"ansible_params": {"adom": "FWC", "central_nat": "disable", "fwpolicy6_implicit_log": "disable", "fwpolicy_implicit_log": "disable", "inspection_mode": "flow", "mode": "add", "name": "ansiblePKG", "ngfw_mode": "profile-based", "object_type": "pkg", "scope_members_vdom": "ans-vdom"}, "connected_fmgr": {"data": {"Admin Domain Configuration": "Enabled", "BIOS version": "04000002", "Branch Point": "2363", "Build": "2363", "Current Time": "Tue Oct 05 04:24:59 PDT 2021", "Daylight Time Saving": "Yes", "FIPS Mode": "Disabled", "HA Mode": "Stand Alone", "Hostname": "FortiManager", "License Status": "Valid", "Major": 6, "Max Number of Admin Domains": 10000, "Max Number of Device Groups": 10000, "Minor": 4, "Offline Mode": "Disabled", "Patch": 6, "Platform Full Name": "FortiManager-VM64", "Platform Type": "FMG-VM64", "Release Version Information": " (GA)", "Serial Number": "FMG-VMTM21010111", "Time Zone": "(GMT-8:00) Pacific Time (US & Canada).", "Version": "v6.4.6-build2363 210531 (GA)", "x86-64 Applications": "Yes"}, "status": {"code": 0, "message": "OK"}, "url": "sys/status"}, "paramgram": {"adom": "FWC", "central-nat": "disable", "fwpolicy-implicit-log": "disable", "fwpolicy6-implicit-log": "disable", "inspection-mode": "flow", "mode": "add", "name": "ansiblePKG", "ngfw-mode": "profile-based", "object_type": "pkg", "scope_members_vdom": "ans-vdom"}, "response": [0, {"status": {"code": 0, "message": "OK"}, "url": "/pm/pkg/adom/FWC"}]}, "ansible_module_results": {"status": {"code": 0, "message": "OK"}, "url": "/pm/pkg/adom/FWC"}, "changed": true, "msg": "OK", "rc": 0, "success": true, "unreachable": false} META: ran handlers META: ran handlers
PLAY RECAP ***** fmg : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Hi @sanjay-chahar
Unfortunately it is inlikely this issue is going to be resolved here as per the responses I got on a pull request I raised for ref:
https://github.com/ansible-collections/community.network/pull/15
SUMMARY
When utilising the fmgr_device module to add a new device the module reports skipped when the API call failed due to the device not being available.
ISSUE TYPE
COMPONENT NAME
fmgr_device
ANSIBLE VERSION
The below version was also modified to include the correct fortimanager.py file to resolve the httpapi bug.
ansible 2.9.7 config file = None configured module search path = ['/home/peter/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/peter/.virtualenvs/ansibletest/lib/python3.6/site-packages/ansible executable location = /home/peter/.virtualenvs/ansibletest/bin/ansible python version = 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0]
CONFIGURATION
No output (no custom configuration)
OS / ENVIRONMENT
Linux petermcd.dev 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
STEPS TO REPRODUCE
1) Create the below playbook and call it device_create.playbook (this has details of a device that does not exist to purposely cause a failure):
2) create a host group called FortiManager with valid credentials associated
3) perform the following call:
ansible-playbook device_create.playbook
EXPECTED RESULTS
PLAY [Add Fortinet Device] *****
TASK [Gathering Facts] ***** ok: [device-name]
ACTUAL RESULTS
The task is marked as skipped with no error being output for the call. As can be seen from the error in the -vvvv call below the device could not be added to the FortiManager as the probe failed.