From df6d46fed3dad975e2dba630c75514bfe9795cdf Mon Sep 17 00:00:00 2001 From: Fortinet Core CSE NA <43451990+ftntcorecse@users.noreply.github.com> Date: Thu, 22 Aug 2019 03:24:46 -0700 Subject: [PATCH] Fortinet: fmgr_fwpol_ipv4 update/behavioral option fix (#58154) * PR Update to fmgr_fwpol_ipv4 -- now allows for failure or skip behavior option upon missing dependencies * fmgr_fwpol_ipv4 minor docs fix * Removed "system_package_print" line from test/sanity/ignore.txt as instructed by failed shippable test. Actual PR module isn't affected. --- .../network/fortimanager/fmgr_fwpol_ipv4.py | 20 +- test/sanity/ignore.txt | 1 - .../routeros/fixtures/system_package_print | 210 +++++++++--------- 3 files changed, 122 insertions(+), 109 deletions(-) diff --git a/lib/ansible/modules/network/fortimanager/fmgr_fwpol_ipv4.py b/lib/ansible/modules/network/fortimanager/fmgr_fwpol_ipv4.py index 75210779004..e236f064ab7 100644 --- a/lib/ansible/modules/network/fortimanager/fmgr_fwpol_ipv4.py +++ b/lib/ansible/modules/network/fortimanager/fmgr_fwpol_ipv4.py @@ -59,6 +59,15 @@ options: required: false default: "default" + fail_on_missing_dependency: + description: + - Normal behavior is to "skip" tasks that fail dependency checks, so other tasks can run. + - If set to "enabled" if a failed dependency check happeens, Ansible will exit as with failure instead of skip. + required: false + default: "disable" + choices: ["enable", "disable"] + version_added: "2.9" + wsso: description: - Enable/disable WiFi Single Sign On (WSSO). @@ -1024,7 +1033,8 @@ def main(): adom=dict(type="str", default="root"), mode=dict(choices=["add", "set", "delete", "update"], type="str", default="add"), package_name=dict(type="str", required=False, default="default"), - + fail_on_missing_dependency=dict(type="str", required=False, default="disable", choices=["enable", + "disable"]), wsso=dict(required=False, type="str", choices=["disable", "enable"]), webfilter_profile=dict(required=False, type="str"), webcache_https=dict(required=False, type="str", choices=["disable", "enable"]), @@ -1335,8 +1345,12 @@ def main(): try: results = fmgr_firewall_policy_modify(fmgr, paramgram) - fmgr.govern_response(module=module, results=results, good_codes=[0, -9998], - ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram)) + if module.params["fail_on_missing_dependency"] == "disable": + fmgr.govern_response(module=module, results=results, good_codes=[0, -9998], + ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram)) + if module.params["fail_on_missing_dependency"] == "enable" and results[0] == -10131: + fmgr.govern_response(module=module, results=results, good_codes=[0, ], failed=True, skipped=False, + ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram)) except Exception as err: raise FMGBaseException(err) diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index 76f77590a63..2613efb9f21 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -6640,7 +6640,6 @@ test/units/modules/network/radware/test_vdirect_file.py future-import-boilerplat test/units/modules/network/radware/test_vdirect_file.py metaclass-boilerplate test/units/modules/network/radware/test_vdirect_runnable.py future-import-boilerplate test/units/modules/network/radware/test_vdirect_runnable.py metaclass-boilerplate -test/units/modules/network/routeros/fixtures/system_package_print line-endings test/units/modules/notification/test_slack.py future-import-boilerplate test/units/modules/notification/test_slack.py metaclass-boilerplate test/units/modules/packaging/language/test_gem.py future-import-boilerplate diff --git a/test/units/modules/network/routeros/fixtures/system_package_print b/test/units/modules/network/routeros/fixtures/system_package_print index 54ef6a809b9..3f806211e54 100644 --- a/test/units/modules/network/routeros/fixtures/system_package_print +++ b/test/units/modules/network/routeros/fixtures/system_package_print @@ -1,106 +1,106 @@ - - - - - - - - - - - - - - - - - MMM MMM KKK TTTTTTTTTTT KKK - - MMMM MMMM KKK TTTTTTTTTTT KKK - - MMM MMMM MMM III KKK KKK RRRRRR OOOOOO TTT III KKK KKK - - MMM MM MMM III KKKKK RRR RRR OOO OOO TTT III KKKKK - - MMM MMM III KKK KKK RRRRRR OOO OOO TTT III KKK KKK - - MMM MMM III KKK KKK RRR RRR OOOOOO TTT III KKK KKK - - - - MikroTik RouterOS 6.42.5 (c) 1999-2018 http://www.mikrotik.com/ - - -[?] Gives the list of available commands - -command [?] Gives help on the command and list of arguments - - - -[Tab] Completes the command/word. If the input is ambiguous, - - a second [Tab] gives possible options - - - -/ Move up to base level - -.. Move up one level - -/command Use command at the base level - - -Z <[?47l[?7h[?5l[?25h - - - -[admin@MainRouter] > -[admin@MainRouter] > /system routerboard print -[admin@MainRouter] > /system routerboard print - - routerboard: yes - model: 750GL - serial-number: 1234567890AB - firmware-type: ar7240 - factory-firmware: 3.09 - current-firmware: 6.41.2 - upgrade-firmware: 6.42.5 - - - - - -[admin@MainRouter] > -[admin@MainRouter] > /system identity print -[admin@MainRouter] > /system identity print - - name: MikroTik - - - - - -[admin@MainRouter] > -[admin@MainRouter] > /system package print -[admin@MainRouter] > /system package print - -Flags: X - disabled - # NAME VERSION SCHEDULED - 0 routeros-mipsbe 6.42.5 - 1 system 6.42.5 - 2 ipv6 6.42.5 - 3 wireless 6.42.5 - 4 hotspot 6.42.5 - 5 dhcp 6.42.5 - 6 mpls 6.42.5 - 7 routing 6.42.5 - 8 ppp 6.42.5 - 9 security 6.42.5 -10 advanced-tools 6.42.5 - - - - - -[admin@MainRouter] > + + + + + + + + + + + + + + + + + MMM MMM KKK TTTTTTTTTTT KKK + + MMMM MMMM KKK TTTTTTTTTTT KKK + + MMM MMMM MMM III KKK KKK RRRRRR OOOOOO TTT III KKK KKK + + MMM MM MMM III KKKKK RRR RRR OOO OOO TTT III KKKKK + + MMM MMM III KKK KKK RRRRRR OOO OOO TTT III KKK KKK + + MMM MMM III KKK KKK RRR RRR OOOOOO TTT III KKK KKK + + + + MikroTik RouterOS 6.42.5 (c) 1999-2018 http://www.mikrotik.com/ + + +[?] Gives the list of available commands + +command [?] Gives help on the command and list of arguments + + + +[Tab] Completes the command/word. If the input is ambiguous, + + a second [Tab] gives possible options + + + +/ Move up to base level + +.. Move up one level + +/command Use command at the base level + + +Z <[?47l[?7h[?5l[?25h + + + +[admin@MainRouter] > +[admin@MainRouter] > /system routerboard print +[admin@MainRouter] > /system routerboard print + + routerboard: yes + model: 750GL + serial-number: 1234567890AB + firmware-type: ar7240 + factory-firmware: 3.09 + current-firmware: 6.41.2 + upgrade-firmware: 6.42.5 + + + + + +[admin@MainRouter] > +[admin@MainRouter] > /system identity print +[admin@MainRouter] > /system identity print + + name: MikroTik + + + + + +[admin@MainRouter] > +[admin@MainRouter] > /system package print +[admin@MainRouter] > /system package print + +Flags: X - disabled + # NAME VERSION SCHEDULED + 0 routeros-mipsbe 6.42.5 + 1 system 6.42.5 + 2 ipv6 6.42.5 + 3 wireless 6.42.5 + 4 hotspot 6.42.5 + 5 dhcp 6.42.5 + 6 mpls 6.42.5 + 7 routing 6.42.5 + 8 ppp 6.42.5 + 9 security 6.42.5 +10 advanced-tools 6.42.5 + + + + + +[admin@MainRouter] > [admin@MainRouter] > \ No newline at end of file