From 7da2c16b4a48d420e8522bc0a5d292a0a9a9ca65 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 28 Jul 2021 04:24:29 +1200 Subject: [PATCH] added supports_check_mode=True to info/facts modules (#3084) * added supports_check_mode=True to info/facts modules * added changelog fragment * rolled back vertica_info * rolled back utm_proxy_*_info * updated changelog fragment with latest adjustments * Update changelogs/fragments/3084-info-checkmode.yaml Co-authored-by: Felix Fontein * added check mode to xenserver_facts + oneview_*_info * added check mode to utm_proxy_*_info * updated changelog Co-authored-by: Felix Fontein --- changelogs/fragments/3084-info-checkmode.yaml | 24 +++++++++++++++++++ plugins/module_utils/oneview.py | 4 ++-- .../cloud/alicloud/ali_instance_info.py | 5 +++- .../cloud/memset/memset_memstore_info.py | 2 +- .../cloud/memset/memset_server_info.py | 2 +- plugins/modules/cloud/misc/xenserver_facts.py | 4 +++- plugins/modules/cloud/rackspace/rax_facts.py | 1 + .../cloud/smartos/smartos_image_info.py | 2 +- plugins/modules/net_tools/snmp_facts.py | 2 +- .../oneview/oneview_datacenter_info.py | 5 +++- .../oneview/oneview_enclosure_info.py | 5 +++- .../oneview/oneview_ethernet_network_info.py | 5 +++- .../oneview/oneview_fc_network_info.py | 5 +++- .../oneview/oneview_fcoe_network_info.py | 5 +++- ...oneview_logical_interconnect_group_info.py | 5 +++- .../oneview/oneview_network_set_info.py | 5 +++- .../oneview/oneview_san_manager_info.py | 5 +++- .../redfish/idrac_redfish_info.py | 2 +- .../remote_management/redfish/redfish_info.py | 2 +- plugins/modules/system/xfconf_info.py | 1 + .../sophos_utm/utm_aaa_group_info.py | 3 ++- .../sophos_utm/utm_ca_host_key_cert_info.py | 3 ++- .../utm_network_interface_address_info.py | 3 ++- .../sophos_utm/utm_proxy_frontend_info.py | 5 ++-- .../sophos_utm/utm_proxy_location_info.py | 5 ++-- 25 files changed, 85 insertions(+), 25 deletions(-) create mode 100644 changelogs/fragments/3084-info-checkmode.yaml diff --git a/changelogs/fragments/3084-info-checkmode.yaml b/changelogs/fragments/3084-info-checkmode.yaml new file mode 100644 index 0000000000..4e9fa85075 --- /dev/null +++ b/changelogs/fragments/3084-info-checkmode.yaml @@ -0,0 +1,24 @@ +bugfixes: + - ali_instance_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - memset_memstore_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - memset_server_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - xenserver_facts - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - rax_facts - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - smartos_image_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - snmp_facts - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - oneview_datacenter_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - oneview_enclosure_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - oneview_ethernet_network_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - oneview_fc_network_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - oneview_fcoe_network_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - oneview_logical_interconnect_group_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - oneview_network_set_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - oneview_san_manager_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - idrac_redfish_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - redfish_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - xfconf_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - utm_aaa_group_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - utm_ca_host_key_cert_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - utm_network_interface_address_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - utm_proxy_frontend_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). + - utm_proxy_location_info - added support to check mode (https://github.com/ansible-collections/community.general/pull/3084). diff --git a/plugins/module_utils/oneview.py b/plugins/module_utils/oneview.py index 3ebb057ca7..66e1d6d4c7 100644 --- a/plugins/module_utils/oneview.py +++ b/plugins/module_utils/oneview.py @@ -201,7 +201,7 @@ class OneViewModuleBase(object): resource_client = None - def __init__(self, additional_arg_spec=None, validate_etag_support=False): + def __init__(self, additional_arg_spec=None, validate_etag_support=False, supports_check_mode=False): """ OneViewModuleBase constructor. @@ -210,7 +210,7 @@ class OneViewModuleBase(object): """ argument_spec = self._build_argument_spec(additional_arg_spec, validate_etag_support) - self.module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False) + self.module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=supports_check_mode) self._check_hpe_oneview_sdk() self._create_oneview_client() diff --git a/plugins/modules/cloud/alicloud/ali_instance_info.py b/plugins/modules/cloud/alicloud/ali_instance_info.py index 23665bbcad..06df6cb4f1 100644 --- a/plugins/modules/cloud/alicloud/ali_instance_info.py +++ b/plugins/modules/cloud/alicloud/ali_instance_info.py @@ -386,7 +386,10 @@ def main(): filters=dict(type='dict') ) ) - module = AnsibleModule(argument_spec=argument_spec) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) if HAS_FOOTMARK is False: module.fail_json(msg=missing_required_lib('footmark'), exception=FOOTMARK_IMP_ERR) diff --git a/plugins/modules/cloud/memset/memset_memstore_info.py b/plugins/modules/cloud/memset/memset_memstore_info.py index df5ede1a62..e880b46009 100644 --- a/plugins/modules/cloud/memset/memset_memstore_info.py +++ b/plugins/modules/cloud/memset/memset_memstore_info.py @@ -149,7 +149,7 @@ def main(): api_key=dict(required=True, type='str', no_log=True), name=dict(required=True, type='str') ), - supports_check_mode=False + supports_check_mode=True, ) # populate the dict with the user-provided vars. diff --git a/plugins/modules/cloud/memset/memset_server_info.py b/plugins/modules/cloud/memset/memset_server_info.py index 50fe39fd99..853e2c884d 100644 --- a/plugins/modules/cloud/memset/memset_server_info.py +++ b/plugins/modules/cloud/memset/memset_server_info.py @@ -274,7 +274,7 @@ def main(): api_key=dict(required=True, type='str', no_log=True), name=dict(required=True, type='str') ), - supports_check_mode=False + supports_check_mode=True, ) # populate the dict with the user-provided vars. diff --git a/plugins/modules/cloud/misc/xenserver_facts.py b/plugins/modules/cloud/misc/xenserver_facts.py index 25923cb288..bc01c56ecb 100644 --- a/plugins/modules/cloud/misc/xenserver_facts.py +++ b/plugins/modules/cloud/misc/xenserver_facts.py @@ -160,7 +160,9 @@ def get_srs(session): def main(): - module = AnsibleModule({}) + module = AnsibleModule( + supports_check_mode=True, + ) if not HAVE_XENAPI: module.fail_json(changed=False, msg="python xen api required for this module") diff --git a/plugins/modules/cloud/rackspace/rax_facts.py b/plugins/modules/cloud/rackspace/rax_facts.py index 386ca7cfa9..f9fd89556f 100644 --- a/plugins/modules/cloud/rackspace/rax_facts.py +++ b/plugins/modules/cloud/rackspace/rax_facts.py @@ -124,6 +124,7 @@ def main(): required_together=rax_required_together(), mutually_exclusive=[['address', 'id', 'name']], required_one_of=[['address', 'id', 'name']], + supports_check_mode=True, ) if not HAS_PYRAX: diff --git a/plugins/modules/cloud/smartos/smartos_image_info.py b/plugins/modules/cloud/smartos/smartos_image_info.py index f1c75bc26c..369559f52a 100644 --- a/plugins/modules/cloud/smartos/smartos_image_info.py +++ b/plugins/modules/cloud/smartos/smartos_image_info.py @@ -97,7 +97,7 @@ def main(): argument_spec=dict( filters=dict(default=None), ), - supports_check_mode=False, + supports_check_mode=True, ) image_facts = ImageFacts(module) diff --git a/plugins/modules/net_tools/snmp_facts.py b/plugins/modules/net_tools/snmp_facts.py index 221eda30f9..e9d0ebc94c 100644 --- a/plugins/modules/net_tools/snmp_facts.py +++ b/plugins/modules/net_tools/snmp_facts.py @@ -288,7 +288,7 @@ def main(): ['username', 'level', 'integrity', 'authkey'], ['privacy', 'privkey'], ), - supports_check_mode=False, + supports_check_mode=True, ) m_args = module.params diff --git a/plugins/modules/remote_management/oneview/oneview_datacenter_info.py b/plugins/modules/remote_management/oneview/oneview_datacenter_info.py index 13ab883330..04d4fc0c7e 100644 --- a/plugins/modules/remote_management/oneview/oneview_datacenter_info.py +++ b/plugins/modules/remote_management/oneview/oneview_datacenter_info.py @@ -116,7 +116,10 @@ class DatacenterInfoModule(OneViewModuleBase): ) def __init__(self): - super(DatacenterInfoModule, self).__init__(additional_arg_spec=self.argument_spec) + super(DatacenterInfoModule, self).__init__( + additional_arg_spec=self.argument_spec, + supports_check_mode=True, + ) def execute_module(self): diff --git a/plugins/modules/remote_management/oneview/oneview_enclosure_info.py b/plugins/modules/remote_management/oneview/oneview_enclosure_info.py index 1889dc1a4f..a9bbb8e799 100644 --- a/plugins/modules/remote_management/oneview/oneview_enclosure_info.py +++ b/plugins/modules/remote_management/oneview/oneview_enclosure_info.py @@ -163,7 +163,10 @@ class EnclosureInfoModule(OneViewModuleBase): ) def __init__(self): - super(EnclosureInfoModule, self).__init__(additional_arg_spec=self.argument_spec) + super(EnclosureInfoModule, self).__init__( + additional_arg_spec=self.argument_spec, + supports_check_mode=True, + ) def execute_module(self): diff --git a/plugins/modules/remote_management/oneview/oneview_ethernet_network_info.py b/plugins/modules/remote_management/oneview/oneview_ethernet_network_info.py index 4021b768f9..63a9e1efae 100644 --- a/plugins/modules/remote_management/oneview/oneview_ethernet_network_info.py +++ b/plugins/modules/remote_management/oneview/oneview_ethernet_network_info.py @@ -114,7 +114,10 @@ class EthernetNetworkInfoModule(OneViewModuleBase): ) def __init__(self): - super(EthernetNetworkInfoModule, self).__init__(additional_arg_spec=self.argument_spec) + super(EthernetNetworkInfoModule, self).__init__( + additional_arg_spec=self.argument_spec, + supports_check_mode=True, + ) self.resource_client = self.oneview_client.ethernet_networks diff --git a/plugins/modules/remote_management/oneview/oneview_fc_network_info.py b/plugins/modules/remote_management/oneview/oneview_fc_network_info.py index 21d9673b51..86430402fe 100644 --- a/plugins/modules/remote_management/oneview/oneview_fc_network_info.py +++ b/plugins/modules/remote_management/oneview/oneview_fc_network_info.py @@ -83,7 +83,10 @@ class FcNetworkInfoModule(OneViewModuleBase): params=dict(required=False, type='dict') ) - super(FcNetworkInfoModule, self).__init__(additional_arg_spec=argument_spec) + super(FcNetworkInfoModule, self).__init__( + additional_arg_spec=argument_spec, + supports_check_mode=True, + ) def execute_module(self): diff --git a/plugins/modules/remote_management/oneview/oneview_fcoe_network_info.py b/plugins/modules/remote_management/oneview/oneview_fcoe_network_info.py index e207670a9a..b0ede13820 100644 --- a/plugins/modules/remote_management/oneview/oneview_fcoe_network_info.py +++ b/plugins/modules/remote_management/oneview/oneview_fcoe_network_info.py @@ -82,7 +82,10 @@ class FcoeNetworkInfoModule(OneViewModuleBase): params=dict(type='dict'), ) - super(FcoeNetworkInfoModule, self).__init__(additional_arg_spec=argument_spec) + super(FcoeNetworkInfoModule, self).__init__( + additional_arg_spec=argument_spec, + supports_check_mode=True, + ) def execute_module(self): diff --git a/plugins/modules/remote_management/oneview/oneview_logical_interconnect_group_info.py b/plugins/modules/remote_management/oneview/oneview_logical_interconnect_group_info.py index 1f7f3c9613..e8670a33a8 100644 --- a/plugins/modules/remote_management/oneview/oneview_logical_interconnect_group_info.py +++ b/plugins/modules/remote_management/oneview/oneview_logical_interconnect_group_info.py @@ -96,7 +96,10 @@ class LogicalInterconnectGroupInfoModule(OneViewModuleBase): params=dict(type='dict'), ) - super(LogicalInterconnectGroupInfoModule, self).__init__(additional_arg_spec=argument_spec) + super(LogicalInterconnectGroupInfoModule, self).__init__( + additional_arg_spec=argument_spec, + supports_check_mode=True, + ) def execute_module(self): if self.module.params.get('name'): diff --git a/plugins/modules/remote_management/oneview/oneview_network_set_info.py b/plugins/modules/remote_management/oneview/oneview_network_set_info.py index bc76cb36b1..5cb7463b4c 100644 --- a/plugins/modules/remote_management/oneview/oneview_network_set_info.py +++ b/plugins/modules/remote_management/oneview/oneview_network_set_info.py @@ -135,7 +135,10 @@ class NetworkSetInfoModule(OneViewModuleBase): ) def __init__(self): - super(NetworkSetInfoModule, self).__init__(additional_arg_spec=self.argument_spec) + super(NetworkSetInfoModule, self).__init__( + additional_arg_spec=self.argument_spec, + supports_check_mode=True, + ) def execute_module(self): diff --git a/plugins/modules/remote_management/oneview/oneview_san_manager_info.py b/plugins/modules/remote_management/oneview/oneview_san_manager_info.py index 5dbc28afc2..c80ef474cc 100644 --- a/plugins/modules/remote_management/oneview/oneview_san_manager_info.py +++ b/plugins/modules/remote_management/oneview/oneview_san_manager_info.py @@ -90,7 +90,10 @@ class SanManagerInfoModule(OneViewModuleBase): ) def __init__(self): - super(SanManagerInfoModule, self).__init__(additional_arg_spec=self.argument_spec) + super(SanManagerInfoModule, self).__init__( + additional_arg_spec=self.argument_spec, + supports_check_mode=True, + ) self.resource_client = self.oneview_client.san_managers def execute_module(self): diff --git a/plugins/modules/remote_management/redfish/idrac_redfish_info.py b/plugins/modules/remote_management/redfish/idrac_redfish_info.py index cb1aa8f34f..fb137acca3 100644 --- a/plugins/modules/remote_management/redfish/idrac_redfish_info.py +++ b/plugins/modules/remote_management/redfish/idrac_redfish_info.py @@ -191,7 +191,7 @@ def main(): mutually_exclusive=[ ('username', 'auth_token'), ], - supports_check_mode=False + supports_check_mode=True, ) category = module.params['category'] diff --git a/plugins/modules/remote_management/redfish/redfish_info.py b/plugins/modules/remote_management/redfish/redfish_info.py index 41d5bfb04a..49bd7c6ee3 100644 --- a/plugins/modules/remote_management/redfish/redfish_info.py +++ b/plugins/modules/remote_management/redfish/redfish_info.py @@ -318,7 +318,7 @@ def main(): mutually_exclusive=[ ('username', 'auth_token'), ], - supports_check_mode=False + supports_check_mode=True, ) # admin credentials used for authentication diff --git a/plugins/modules/system/xfconf_info.py b/plugins/modules/system/xfconf_info.py index 9cef821071..766267dd3d 100644 --- a/plugins/modules/system/xfconf_info.py +++ b/plugins/modules/system/xfconf_info.py @@ -132,6 +132,7 @@ class XFConfInfo(CmdModuleHelper): required_by=dict( property=['channel'] ), + supports_check_mode=True, ) command = 'xfconf-query' diff --git a/plugins/modules/web_infrastructure/sophos_utm/utm_aaa_group_info.py b/plugins/modules/web_infrastructure/sophos_utm/utm_aaa_group_info.py index 88356a2e54..d5660ab73c 100644 --- a/plugins/modules/web_infrastructure/sophos_utm/utm_aaa_group_info.py +++ b/plugins/modules/web_infrastructure/sophos_utm/utm_aaa_group_info.py @@ -110,7 +110,8 @@ def main(): module = UTMModule( argument_spec=dict( name=dict(type='str', required=True) - ) + ), + supports_check_mode=True, ) try: UTM(module, endpoint, key_to_check_for_changes, info_only=True).execute() diff --git a/plugins/modules/web_infrastructure/sophos_utm/utm_ca_host_key_cert_info.py b/plugins/modules/web_infrastructure/sophos_utm/utm_ca_host_key_cert_info.py index 02542532f7..9aa16d4aca 100644 --- a/plugins/modules/web_infrastructure/sophos_utm/utm_ca_host_key_cert_info.py +++ b/plugins/modules/web_infrastructure/sophos_utm/utm_ca_host_key_cert_info.py @@ -88,7 +88,8 @@ def main(): module = UTMModule( argument_spec=dict( name=dict(type='str', required=True) - ) + ), + supports_check_mode=True, ) try: # This is needed because the bool value only accepts int values in the backend diff --git a/plugins/modules/web_infrastructure/sophos_utm/utm_network_interface_address_info.py b/plugins/modules/web_infrastructure/sophos_utm/utm_network_interface_address_info.py index 3f623d5a86..700799ab59 100644 --- a/plugins/modules/web_infrastructure/sophos_utm/utm_network_interface_address_info.py +++ b/plugins/modules/web_infrastructure/sophos_utm/utm_network_interface_address_info.py @@ -84,7 +84,8 @@ def main(): module = UTMModule( argument_spec=dict( name=dict(type='str', required=True) - ) + ), + supports_check_mode=True, ) try: UTM(module, endpoint, key_to_check_for_changes, info_only=True).execute() diff --git a/plugins/modules/web_infrastructure/sophos_utm/utm_proxy_frontend_info.py b/plugins/modules/web_infrastructure/sophos_utm/utm_proxy_frontend_info.py index 263b976045..62a832d7c6 100644 --- a/plugins/modules/web_infrastructure/sophos_utm/utm_proxy_frontend_info.py +++ b/plugins/modules/web_infrastructure/sophos_utm/utm_proxy_frontend_info.py @@ -128,8 +128,9 @@ def main(): key_to_check_for_changes = [] module = UTMModule( argument_spec=dict( - name=dict(type='str', required=True) - ) + name=dict(type='str', required=True), + ), + supports_check_mode=True, ) try: UTM(module, endpoint, key_to_check_for_changes, info_only=True).execute() diff --git a/plugins/modules/web_infrastructure/sophos_utm/utm_proxy_location_info.py b/plugins/modules/web_infrastructure/sophos_utm/utm_proxy_location_info.py index afc0f5efcd..99174a89b1 100644 --- a/plugins/modules/web_infrastructure/sophos_utm/utm_proxy_location_info.py +++ b/plugins/modules/web_infrastructure/sophos_utm/utm_proxy_location_info.py @@ -109,8 +109,9 @@ def main(): key_to_check_for_changes = [] module = UTMModule( argument_spec=dict( - name=dict(type='str', required=True) - ) + name=dict(type='str', required=True), + ), + supports_check_mode=True, ) try: UTM(module, endpoint, key_to_check_for_changes, info_only=True).execute()