diff --git a/plugins/modules/cs_configuration_info.py b/plugins/modules/configuration_info.py similarity index 69% rename from plugins/modules/cs_configuration_info.py rename to plugins/modules/configuration_info.py index bb1caf4b..98c32dec 100644 --- a/plugins/modules/cs_configuration_info.py +++ b/plugins/modules/configuration_info.py @@ -5,16 +5,17 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function + __metaclass__ = type -DOCUMENTATION = ''' +DOCUMENTATION = """ --- -module: cs_configuration_info +module: configuration_info short_description: Gathering information about configurations from Apache CloudStack based clouds. description: - Gathering information from the API about configurations. author: Francisco Arencibia (@arencibiafrancisco) -version_added: 0.1.0 +version_added: 3.0.0 options: name: description: @@ -23,11 +24,11 @@ type: str extends_documentation_fragment: - ngine_io.cloudstack.cloudstack -''' +""" -EXAMPLES = ''' +EXAMPLES = """ - name: Gather information about a specific configuration - ngine_io.cloudstack.cs_configuration_info: + ngine_io.cloudstack.configuration_info: name: consoleproxy.sslEnabled register: config @@ -36,15 +37,15 @@ msg: "{{ config }}" - name: Gather information about all configurations - ngine_io.cloudstack.cs_configuration_info: + ngine_io.cloudstack.configuration_info: register: configs - name: Show information on all configurations debug: msg: "{{ configs }}" -''' +""" -RETURN = ''' +RETURN = """ --- configurations: description: A list of matching configurations. @@ -66,13 +67,10 @@ returned: success type: str sample: "Enable SSL for console proxy" -''' +""" from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ngine_io.cloudstack.plugins.module_utils.cloudstack import ( - AnsibleCloudStack, - cs_argument_spec, -) +from ansible_collections.ngine_io.cloudstack.plugins.module_utils.cloudstack import AnsibleCloudStack, cs_argument_spec class AnsibleCloudStackConfigurationInfo(AnsibleCloudStack): @@ -80,37 +78,37 @@ class AnsibleCloudStackConfigurationInfo(AnsibleCloudStack): def __init__(self, module): super(AnsibleCloudStackConfigurationInfo, self).__init__(module) self.returns = { - 'name': 'name', - 'value': 'value', - 'description': 'description', + "name": "name", + "value": "value", + "description": "description", } def get_configuration(self): args = {} - if self.module.params['name']: - args['name'] = self.module.params['name'] - configurations = self.query_api('listConfigurations', **args) - if configurations and 'configuration' in configurations: - configurations = configurations['configuration'] + if self.module.params["name"]: + args["name"] = self.module.params["name"] + configurations = self.query_api("listConfigurations", **args) + if configurations and "configuration" in configurations: + configurations = configurations["configuration"] else: configurations = [] else: - configurations = self.query_api('listConfigurations') - if configurations and 'configuration' in configurations: - configurations = configurations['configuration'] + configurations = self.query_api("listConfigurations") + if configurations and "configuration" in configurations: + configurations = configurations["configuration"] else: configurations = [] - return { - 'configurations': [self.update_result(config) for config in configurations] - } + return {"configurations": [self.update_result(config) for config in configurations]} def main(): argument_spec = cs_argument_spec() - argument_spec.update(dict( - name=dict(type='str'), - )) + argument_spec.update( + dict( + name=dict(type="str"), + ) + ) module = AnsibleModule( argument_spec=argument_spec, @@ -122,5 +120,5 @@ def main(): module.exit_json(**result) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/tests/integration/targets/configuration_info/aliases b/tests/integration/targets/configuration_info/aliases new file mode 100644 index 00000000..1d747ed2 --- /dev/null +++ b/tests/integration/targets/configuration_info/aliases @@ -0,0 +1,3 @@ +cloud/cs +cs/group2 +cs/group3 diff --git a/tests/integration/targets/cs_configuration_info/meta/main.yml b/tests/integration/targets/configuration_info/meta/main.yml similarity index 100% rename from tests/integration/targets/cs_configuration_info/meta/main.yml rename to tests/integration/targets/configuration_info/meta/main.yml diff --git a/tests/integration/targets/cs_configuration_info/tasks/main.yml b/tests/integration/targets/configuration_info/tasks/main.yml similarity index 87% rename from tests/integration/targets/cs_configuration_info/tasks/main.yml rename to tests/integration/targets/configuration_info/tasks/main.yml index 9a4f244a..8284618c 100644 --- a/tests/integration/targets/cs_configuration_info/tasks/main.yml +++ b/tests/integration/targets/configuration_info/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: setup configuration is present - cs_configuration: + ngine_io.cloudstack.configuration: name: consoleproxy.sslEnabled value: true register: config @@ -10,10 +10,10 @@ - config is successful - name: get info from configuration in check mode - cs_configuration_info: + ngine_io.cloudstack.configuration_info: name: consoleproxy.sslEnabled register: config_info - check_mode: yes + check_mode: true - name: verify get info from configuration in check mode assert: that: @@ -23,7 +23,7 @@ - config_info.configurations[0].value == "true" - name: get info from configuration - cs_configuration_info: + ngine_io.cloudstack.configuration_info: name: consoleproxy.sslEnabled register: config_info - name: verify get info from configuration @@ -35,7 +35,7 @@ - config_info.configurations[0].value == "true" - name: get info from all configurations - cs_configuration_info: + ngine_io.cloudstack.configuration_info: register: configs - name: verify get info from all configurations assert: diff --git a/tests/integration/targets/cs_configuration_info/aliases b/tests/integration/targets/cs_configuration_info/aliases deleted file mode 100644 index 3b5a38e7..00000000 --- a/tests/integration/targets/cs_configuration_info/aliases +++ /dev/null @@ -1,3 +0,0 @@ -cloud/cs -shippable/cs/group2 -shippable/cs/smoketest