From 3a2257c45c5aa29809cabb0494751984683b8a9b Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Mon, 13 Jan 2020 11:36:01 -0500 Subject: [PATCH] net_facts modules: Don't warn about defaults changing if they're not being used (#66270) --- changelogs/fragments/66270-net-facts-quieter.yaml | 2 ++ lib/ansible/modules/network/eos/eos_facts.py | 8 +++++--- lib/ansible/modules/network/ios/ios_facts.py | 10 +++++++--- lib/ansible/modules/network/iosxr/iosxr_facts.py | 12 +++++++----- lib/ansible/modules/network/junos/junos_facts.py | 10 +++++++--- lib/ansible/modules/network/nxos/nxos_facts.py | 10 +++++++--- lib/ansible/modules/network/vyos/vyos_facts.py | 6 +++--- 7 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 changelogs/fragments/66270-net-facts-quieter.yaml diff --git a/changelogs/fragments/66270-net-facts-quieter.yaml b/changelogs/fragments/66270-net-facts-quieter.yaml new file mode 100644 index 00000000000..957289ad22c --- /dev/null +++ b/changelogs/fragments/66270-net-facts-quieter.yaml @@ -0,0 +1,2 @@ +bugfixes: +- Do not emit warnings about changing network facts defaults when not using the defaults. diff --git a/lib/ansible/modules/network/eos/eos_facts.py b/lib/ansible/modules/network/eos/eos_facts.py index e97ef370c3e..05151319083 100644 --- a/lib/ansible/modules/network/eos/eos_facts.py +++ b/lib/ansible/modules/network/eos/eos_facts.py @@ -181,7 +181,8 @@ from ansible.module_utils.network.eos.eos import eos_argument_spec def main(): - """ Main entry point for module execution + """ + Main entry point for module execution :returns: ansible_facts """ @@ -191,8 +192,9 @@ def main(): module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - warnings = ['default value for `gather_subset` ' - 'will be changed to `min` from `!config` v2.11 onwards'] + warnings = [] + if module.params["gather_subset"] == "!config": + warnings.append('default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards') result = Facts(module).get_facts() diff --git a/lib/ansible/modules/network/ios/ios_facts.py b/lib/ansible/modules/network/ios/ios_facts.py index 37e4b707571..791762153fd 100644 --- a/lib/ansible/modules/network/ios/ios_facts.py +++ b/lib/ansible/modules/network/ios/ios_facts.py @@ -212,7 +212,10 @@ from ansible.module_utils.network.ios.ios import ios_argument_spec def main(): - """ Main entry point for AnsibleModule + """ + Main entry point for module execution + + :returns: ansible_facts """ argument_spec = FactsArgs.argument_spec argument_spec.update(ios_argument_spec) @@ -220,8 +223,9 @@ def main(): module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - warnings = ['default value for `gather_subset` ' - 'will be changed to `min` from `!config` v2.11 onwards'] + warnings = [] + if module.params["gather_subset"] == "!config": + warnings.append('default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards') result = Facts(module).get_facts() diff --git a/lib/ansible/modules/network/iosxr/iosxr_facts.py b/lib/ansible/modules/network/iosxr/iosxr_facts.py index 4e7441ca9d6..8a1f685a5fc 100644 --- a/lib/ansible/modules/network/iosxr/iosxr_facts.py +++ b/lib/ansible/modules/network/iosxr/iosxr_facts.py @@ -193,13 +193,15 @@ def main(): :returns: ansible_facts """ - spec = FactsArgs.argument_spec - spec.update(iosxr_argument_spec) + argument_spec = FactsArgs.argument_spec + argument_spec.update(iosxr_argument_spec) - module = AnsibleModule(argument_spec=spec, + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - warnings = ['default value for `gather_subset` ' - 'will be changed to `min` from `!config` v2.11 onwards'] + + warnings = [] + if module.params["gather_subset"] == "!config": + warnings.append('default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards') result = Facts(module).get_facts() diff --git a/lib/ansible/modules/network/junos/junos_facts.py b/lib/ansible/modules/network/junos/junos_facts.py index 34b0587c60f..4bbcba29d5e 100644 --- a/lib/ansible/modules/network/junos/junos_facts.py +++ b/lib/ansible/modules/network/junos/junos_facts.py @@ -112,7 +112,10 @@ from ansible.module_utils.network.junos.junos import junos_argument_spec def main(): - """ Main entry point for AnsibleModule + """ + Main entry point for module execution + + :returns: ansible_facts """ argument_spec = FactsArgs.argument_spec argument_spec.update(junos_argument_spec) @@ -120,8 +123,9 @@ def main(): module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - warnings = ['default value for `gather_subset` ' - 'will be changed to `min` from `!config` v2.11 onwards'] + warnings = [] + if module.params["gather_subset"] == "!config": + warnings.append('default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards') result = Facts(module).get_facts() diff --git a/lib/ansible/modules/network/nxos/nxos_facts.py b/lib/ansible/modules/network/nxos/nxos_facts.py index bf0f801498e..3bf57caf2c1 100644 --- a/lib/ansible/modules/network/nxos/nxos_facts.py +++ b/lib/ansible/modules/network/nxos/nxos_facts.py @@ -216,7 +216,10 @@ from ansible.module_utils.network.nxos.nxos import nxos_argument_spec def main(): - """ Main entry point for AnsibleModule + """ + Main entry point for module execution + + :returns: ansible_facts """ argument_spec = FactsArgs.argument_spec argument_spec.update(nxos_argument_spec) @@ -224,8 +227,9 @@ def main(): module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - warnings = ['default value for `gather_subset` ' - 'will be changed to `min` from `!config` v2.11 onwards'] + warnings = [] + if module.params["gather_subset"] == "!config": + warnings.append('default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards') result = Facts(module).get_facts() diff --git a/lib/ansible/modules/network/vyos/vyos_facts.py b/lib/ansible/modules/network/vyos/vyos_facts.py index b0837097f1b..5f5dde8b9b2 100644 --- a/lib/ansible/modules/network/vyos/vyos_facts.py +++ b/lib/ansible/modules/network/vyos/vyos_facts.py @@ -150,14 +150,14 @@ def main(): :returns: ansible_facts """ argument_spec = FactsArgs.argument_spec - argument_spec.update(vyos_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - warnings = ['default value for `gather_subset` ' - 'will be changed to `min` from `!config` v2.11 onwards'] + warnings = [] + if module.params["gather_subset"] == "!config": + warnings.append('default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards') result = Facts(module).get_facts()