diff --git a/changelogs/fragments/60516-hcloud-facts-info.yml b/changelogs/fragments/60516-hcloud-facts-info.yml new file mode 100644 index 00000000000..b89c6758608 --- /dev/null +++ b/changelogs/fragments/60516-hcloud-facts-info.yml @@ -0,0 +1,17 @@ +minor_changes: + - The ``hcloud_datacenter_facts`` module has been renamed to ``hcloud_datacenter_info``. + When called with the new name, the module no longer returns ``ansible_facts``. + - The ``hcloud_floating_ip_facts`` module has been renamed to ``hcloud_floating_ip_info``. + When called with the new name, the module no longer returns ``ansible_facts``. + - The ``hcloud_image_facts`` module has been renamed to ``hcloud_image_info``. + When called with the new name, the module no longer returns ``ansible_facts``. + - The ``hcloud_location_facts`` module has been renamed to ``hcloud_location_info``. + When called with the new name, the module no longer returns ``ansible_facts``. + - The ``hcloud_server_facts`` module has been renamed to ``hcloud_server_info``. + When called with the new name, the module no longer returns ``ansible_facts``. + - The ``hcloud_server_type_facts`` module has been renamed to ``hcloud_server_type_info``. + When called with the new name, the module no longer returns ``ansible_facts``. + - The ``hcloud_ssh_key_facts`` module has been renamed to ``hcloud_ssh_key_info``. + When called with the new name, the module no longer returns ``ansible_facts``. + - The ``hcloud_volume_facts`` module has been renamed to ``hcloud_volume_info``. + When called with the new name, the module no longer returns ``ansible_facts``. \ No newline at end of file diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.9.rst b/docs/docsite/rst/porting_guides/porting_guide_2.9.rst index aedc902778d..6078a8200bb 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_2.9.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_2.9.rst @@ -246,6 +246,30 @@ be removed in Ansible 2.13. Please update update your playbooks accordingly. * The ``gluster_heal_facts`` module was renamed to :ref:`gluster_heal_info `. When called with the new name, the module no longer returns ``ansible_facts``. To access return values, :ref:`register a variable `. +* The ``hcloud_datacenter_facts`` module was renamed to :ref:`hcloud_datacenter_info `. + When called with the new name, the module no longer returns ``ansible_facts``. + To access return values, :ref:`register a variable `. +* The ``hcloud_floating_ip_facts`` module was renamed to :ref:`hcloud_floating_ip_info `. + When called with the new name, the module no longer returns ``ansible_facts``. + To access return values, :ref:`register a variable `. +* The ``hcloud_image_facts`` module was renamed to :ref:`hcloud_image_info `. + When called with the new name, the module no longer returns ``ansible_facts``. + To access return values, :ref:`register a variable `. +* The ``hcloud_location_facts`` module was renamed to :ref:`hcloud_location_info `. + When called with the new name, the module no longer returns ``ansible_facts``. + To access return values, :ref:`register a variable `. +* The ``hcloud_server_facts`` module was renamed to :ref:`hcloud_server_info `. + When called with the new name, the module no longer returns ``ansible_facts``. + To access return values, :ref:`register a variable `. +* The ``hcloud_server_type_facts`` module was renamed to :ref:`hcloud_server_type_info `. + When called with the new name, the module no longer returns ``ansible_facts``. + To access return values, :ref:`register a variable `. +* The ``hcloud_ssh_key_facts`` module was renamed to :ref:`hcloud_ssh_key_info `. + When called with the new name, the module no longer returns ``ansible_facts``. + To access return values, :ref:`register a variable `. +* The ``hcloud_volume_facts`` module was renamed to :ref:`hcloud_volume_info `. + When called with the new name, the module no longer returns ``ansible_facts``. + To access return values, :ref:`register a variable `. * The ``hpilo_facts`` module was renamed to :ref:`hpilo_info `. When called with the new name, the module no longer returns ``ansible_facts``. To access return values, :ref:`register a variable `. diff --git a/lib/ansible/modules/cloud/hcloud/_hcloud_datacenter_facts.py b/lib/ansible/modules/cloud/hcloud/_hcloud_datacenter_facts.py new file mode 120000 index 00000000000..44473ed316c --- /dev/null +++ b/lib/ansible/modules/cloud/hcloud/_hcloud_datacenter_facts.py @@ -0,0 +1 @@ +hcloud_datacenter_info.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/hcloud/_hcloud_floating_ip_facts.py b/lib/ansible/modules/cloud/hcloud/_hcloud_floating_ip_facts.py new file mode 120000 index 00000000000..76db56c3604 --- /dev/null +++ b/lib/ansible/modules/cloud/hcloud/_hcloud_floating_ip_facts.py @@ -0,0 +1 @@ +hcloud_floating_ip_info.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/hcloud/_hcloud_image_facts.py b/lib/ansible/modules/cloud/hcloud/_hcloud_image_facts.py new file mode 120000 index 00000000000..c673044bcc2 --- /dev/null +++ b/lib/ansible/modules/cloud/hcloud/_hcloud_image_facts.py @@ -0,0 +1 @@ +hcloud_image_info.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/hcloud/_hcloud_location_facts.py b/lib/ansible/modules/cloud/hcloud/_hcloud_location_facts.py new file mode 120000 index 00000000000..adb06ecb098 --- /dev/null +++ b/lib/ansible/modules/cloud/hcloud/_hcloud_location_facts.py @@ -0,0 +1 @@ +hcloud_location_info.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/hcloud/_hcloud_server_facts.py b/lib/ansible/modules/cloud/hcloud/_hcloud_server_facts.py new file mode 120000 index 00000000000..cc0effff1be --- /dev/null +++ b/lib/ansible/modules/cloud/hcloud/_hcloud_server_facts.py @@ -0,0 +1 @@ +hcloud_server_info.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/hcloud/_hcloud_server_type_facts.py b/lib/ansible/modules/cloud/hcloud/_hcloud_server_type_facts.py new file mode 120000 index 00000000000..5fe872d486b --- /dev/null +++ b/lib/ansible/modules/cloud/hcloud/_hcloud_server_type_facts.py @@ -0,0 +1 @@ +hcloud_server_type_info.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/hcloud/_hcloud_ssh_key_facts.py b/lib/ansible/modules/cloud/hcloud/_hcloud_ssh_key_facts.py new file mode 120000 index 00000000000..c4b0f78e70f --- /dev/null +++ b/lib/ansible/modules/cloud/hcloud/_hcloud_ssh_key_facts.py @@ -0,0 +1 @@ +hcloud_ssh_key_info.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/hcloud/_hcloud_volume_facts.py b/lib/ansible/modules/cloud/hcloud/_hcloud_volume_facts.py new file mode 120000 index 00000000000..1dd0312c663 --- /dev/null +++ b/lib/ansible/modules/cloud/hcloud/_hcloud_volume_facts.py @@ -0,0 +1 @@ +hcloud_volume_info.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_datacenter_facts.py b/lib/ansible/modules/cloud/hcloud/hcloud_datacenter_info.py similarity index 56% rename from lib/ansible/modules/cloud/hcloud/hcloud_datacenter_facts.py rename to lib/ansible/modules/cloud/hcloud/hcloud_datacenter_info.py index 801922cfeeb..5e9f64370ce 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_datacenter_facts.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_datacenter_info.py @@ -16,13 +16,15 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ --- -module: hcloud_datacenter_facts +module: hcloud_datacenter_info -short_description: Gather facts about the Hetzner Cloud datacenters. +short_description: Gather info about the Hetzner Cloud datacenters. version_added: "2.8" description: - - Gather facts about your Hetzner Cloud datacenters. + - Gather info about your Hetzner Cloud datacenters. + - This module was called C(hcloud_datacenter_facts) before Ansible 2.9, returning C(ansible_facts) and C(hcloud_datacenter_facts). + Note that the M(hcloud_datacenter_info) module no longer returns C(ansible_facts) and the value was renamed to C(hcloud_datacenter_info)! author: - Lukas Kaemmerling (@LKaemmerling) @@ -40,32 +42,35 @@ extends_documentation_fragment: hcloud """ EXAMPLES = """ -- name: Gather hcloud datacenter facts - local_action: - module: hcloud_datacenter_facts -- name: Print the gathered facts +- name: Gather hcloud datacenter info + hcloud_datacenter_info: + register: output +- name: Print the gathered info debug: - var: ansible_facts.hcloud_datacenter_facts + var: output """ RETURN = """ -hcloud_datacenter_facts: - description: The datacenter facts as list +hcloud_datacenter_info: + description: + - The datacenter info as list + - This module was called C(hcloud_datacenter_facts) before Ansible 2.9, returning C(ansible_facts) and C(hcloud_datacenter_facts). + Note that the M(hcloud_datacenter_info) module no longer returns C(ansible_facts) and the value was renamed to C(hcloud_datacenter_info)! returned: always type: complex contains: id: - description: Numeric identifier of the location + description: Numeric identifier of the datacenter returned: always type: int sample: 1937415 name: - description: Name of the location + description: Name of the datacenter returned: always type: str sample: fsn1-dc8 description: - description: Detail description of the location + description: Detail description of the datacenter returned: always type: str sample: Falkenstein DC 8 @@ -91,15 +96,15 @@ except ImportError: pass -class AnsibleHcloudDatacenterFacts(Hcloud): +class AnsibleHcloudDatacenterInfo(Hcloud): def __init__(self, module): - Hcloud.__init__(self, module, "hcloud_datacenter_facts") - self.hcloud_datacenter_facts = None + Hcloud.__init__(self, module, "hcloud_datacenter_info") + self.hcloud_datacenter_info = None def _prepare_result(self): tmp = [] - for datacenter in self.hcloud_datacenter_facts: + for datacenter in self.hcloud_datacenter_info: if datacenter is not None: tmp.append({ "id": to_native(datacenter.id), @@ -113,15 +118,15 @@ class AnsibleHcloudDatacenterFacts(Hcloud): def get_datacenters(self): try: if self.module.params.get("id") is not None: - self.hcloud_datacenter_facts = [self.client.datacenters.get_by_id( + self.hcloud_datacenter_info = [self.client.datacenters.get_by_id( self.module.params.get("id") )] elif self.module.params.get("name") is not None: - self.hcloud_datacenter_facts = [self.client.datacenters.get_by_name( + self.hcloud_datacenter_info = [self.client.datacenters.get_by_name( self.module.params.get("name") )] else: - self.hcloud_datacenter_facts = self.client.datacenters.get_all() + self.hcloud_datacenter_info = self.client.datacenters.get_all() except APIException as e: self.module.fail_json(msg=e.message) @@ -139,16 +144,26 @@ class AnsibleHcloudDatacenterFacts(Hcloud): def main(): - module = AnsibleHcloudDatacenterFacts.define_module() + module = AnsibleHcloudDatacenterInfo.define_module() - hcloud = AnsibleHcloudDatacenterFacts(module) + is_old_facts = module._name == 'hcloud_datacenter_facts' + if is_old_facts: + module.deprecate("The 'hcloud_datacenter_facts' module has been renamed to 'hcloud_datacenter_info', " + "and the renamed one no longer returns ansible_facts", version='2.13') + hcloud = AnsibleHcloudDatacenterInfo(module) hcloud.get_datacenters() result = hcloud.get_result() - ansible_facts = { - 'hcloud_datacenter_facts': result['hcloud_datacenter_facts'] - } - module.exit_json(ansible_facts=ansible_facts) + if is_old_facts: + ansible_info = { + 'hcloud_datacenter_facts': result['hcloud_datacenter_info'] + } + module.exit_json(ansible_facts=ansible_info) + else: + ansible_info = { + 'hcloud_datacenter_info': result['hcloud_datacenter_info'] + } + module.exit_json(**ansible_info) if __name__ == "__main__": diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_floating_ip_facts.py b/lib/ansible/modules/cloud/hcloud/hcloud_floating_ip_info.py similarity index 68% rename from lib/ansible/modules/cloud/hcloud/hcloud_floating_ip_facts.py rename to lib/ansible/modules/cloud/hcloud/hcloud_floating_ip_info.py index 52b1ebc992a..dcb1464d3bc 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_floating_ip_facts.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_floating_ip_info.py @@ -16,13 +16,15 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ --- -module: hcloud_floating_ip_facts +module: hcloud_floating_ip_info -short_description: Gather facts about the Hetzner Cloud Floating IPs. +short_description: Gather infos about the Hetzner Cloud Floating IPs. version_added: "2.8" description: - Gather facts about your Hetzner Cloud Floating IPs. + - This module was called C(hcloud_floating_ip_facts) before Ansible 2.9, returning C(ansible_facts) and C(hcloud_floating_ip_facts). + Note that the M(hcloud_floating_ip_info) module no longer returns C(ansible_facts) and the value was renamed to C(hcloud_floating_ip_info)! author: - Lukas Kaemmerling (@LKaemmerling) @@ -40,17 +42,17 @@ extends_documentation_fragment: hcloud """ EXAMPLES = """ -- name: Gather hcloud Floating ip facts - local_action: - module: hcloud_floating_ip_facts -- name: Print the gathered facts +- name: Gather hcloud Floating ip infos + hcloud_floating_ip_info: + register: output +- name: Print the gathered infos debug: - var: ansible_facts.hcloud_floating_ip_facts + var: output """ RETURN = """ -hcloud_floating_ip_facts: - description: The Floating ip facts as list +hcloud_floating_ip_info: + description: The Floating ip infos as list returned: always type: complex contains: @@ -100,15 +102,15 @@ except ImportError: pass -class AnsibleHcloudFloatingIPFacts(Hcloud): +class AnsibleHcloudFloatingIPInfo(Hcloud): def __init__(self, module): - Hcloud.__init__(self, module, "hcloud_floating_ip_facts") - self.hcloud_floating_ip_facts = None + Hcloud.__init__(self, module, "hcloud_floating_ip_info") + self.hcloud_floating_ip_info = None def _prepare_result(self): tmp = [] - for floating_ip in self.hcloud_floating_ip_facts: + for floating_ip in self.hcloud_floating_ip_info: if floating_ip is not None: server_name = None if floating_ip.server is not None: @@ -128,14 +130,14 @@ class AnsibleHcloudFloatingIPFacts(Hcloud): def get_floating_ips(self): try: if self.module.params.get("id") is not None: - self.hcloud_floating_ip_facts = [self.client.floating_ips.get_by_id( + self.hcloud_floating_ip_info = [self.client.floating_ips.get_by_id( self.module.params.get("id") )] elif self.module.params.get("label_selector") is not None: - self.hcloud_floating_ip_facts = self.client.floating_ips.get_all( + self.hcloud_floating_ip_info = self.client.floating_ips.get_all( label_selector=self.module.params.get("label_selector")) else: - self.hcloud_floating_ip_facts = self.client.floating_ips.get_all() + self.hcloud_floating_ip_info = self.client.floating_ips.get_all() except APIException as e: self.module.fail_json(msg=e.message) @@ -153,16 +155,27 @@ class AnsibleHcloudFloatingIPFacts(Hcloud): def main(): - module = AnsibleHcloudFloatingIPFacts.define_module() + module = AnsibleHcloudFloatingIPInfo.define_module() - hcloud = AnsibleHcloudFloatingIPFacts(module) + is_old_facts = module._name == 'hcloud_floating_ip_facts' + if is_old_facts: + module.deprecate("The 'hcloud_floating_ip_facts' module has been renamed to 'hcloud_floating_ip_info', " + "and the renamed one no longer returns ansible_facts", version='2.13') + + hcloud = AnsibleHcloudFloatingIPInfo(module) hcloud.get_floating_ips() result = hcloud.get_result() - ansible_facts = { - 'hcloud_floating_ip_facts': result['hcloud_floating_ip_facts'] - } - module.exit_json(ansible_facts=ansible_facts) + if is_old_facts: + ansible_info = { + 'hcloud_floating_ip_facts': result['hcloud_floating_ip_info'] + } + module.exit_json(ansible_facts=ansible_info) + else: + ansible_info = { + 'hcloud_floating_ip_info': result['hcloud_floating_ip_info'] + } + module.exit_json(**ansible_info) if __name__ == "__main__": diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_image_facts.py b/lib/ansible/modules/cloud/hcloud/hcloud_image_info.py similarity index 70% rename from lib/ansible/modules/cloud/hcloud/hcloud_image_facts.py rename to lib/ansible/modules/cloud/hcloud/hcloud_image_info.py index ab94f890d33..fbbc3eb8127 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_image_facts.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_image_info.py @@ -16,14 +16,16 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ --- -module: hcloud_image_facts +module: hcloud_image_info -short_description: Gather facts about your Hetzner Cloud images. +short_description: Gather infos about your Hetzner Cloud images. version_added: "2.8" description: - - Gather facts about your Hetzner Cloud images. + - Gather infos about your Hetzner Cloud images. + - This module was called C(hcloud_location_facts) before Ansible 2.9, returning C(ansible_facts) and C(hcloud_location_facts). + Note that the M(hcloud_image_info) module no longer returns C(ansible_facts) and the value was renamed to C(hcloud_image_info)! author: - Lukas Kaemmerling (@LKaemmerling) @@ -46,22 +48,23 @@ options: - The label selector for the images you want to get. default: system choices: [ system, snapshot, backup ] + type: str extends_documentation_fragment: hcloud """ EXAMPLES = """ -- name: Gather hcloud image facts - local_action: - module: hcloud_image_facts +- name: Gather hcloud image infos + hcloud_image_info: + register: output -- name: Print the gathered facts +- name: Print the gathered infos debug: - var: ansible_facts.hcloud_image_facts + var: output """ RETURN = """ -hcloud_image_facts: - description: The image facts as list +hcloud_image_info: + description: The image infos as list returned: always type: complex contains: @@ -116,15 +119,15 @@ except ImportError: pass -class AnsibleHcloudImageFacts(Hcloud): +class AnsibleHcloudImageInfo(Hcloud): def __init__(self, module): - Hcloud.__init__(self, module, "hcloud_image_facts") - self.hcloud_image_facts = None + Hcloud.__init__(self, module, "hcloud_image_info") + self.hcloud_image_info = None def _prepare_result(self): tmp = [] - for image in self.hcloud_image_facts: + for image in self.hcloud_image_info: if image is not None: tmp.append({ "id": to_native(image.id), @@ -138,14 +141,14 @@ class AnsibleHcloudImageFacts(Hcloud): }) return tmp - def get_servers(self): + def get_images(self): try: if self.module.params.get("id") is not None: - self.hcloud_image_facts = [self.client.images.get_by_id( + self.hcloud_image_info = [self.client.images.get_by_id( self.module.params.get("id") )] elif self.module.params.get("name") is not None: - self.hcloud_image_facts = [self.client.images.get_by_name( + self.hcloud_image_info = [self.client.images.get_by_name( self.module.params.get("name") )] else: @@ -158,7 +161,7 @@ class AnsibleHcloudImageFacts(Hcloud): if image_type: params["type"] = image_type - self.hcloud_image_facts = self.client.images.get_all(**params) + self.hcloud_image_info = self.client.images.get_all(**params) except APIException as e: self.module.fail_json(msg=e.message) @@ -170,7 +173,7 @@ class AnsibleHcloudImageFacts(Hcloud): id={"type": "int"}, name={"type": "str"}, label_selector={"type": "str"}, - type={"choices": ["system", "snapshot", "backup"], "default": "system"}, + type={"choices": ["system", "snapshot", "backup"], "default": "system", "type": "str"}, **Hcloud.base_module_arguments() ), supports_check_mode=True, @@ -178,15 +181,27 @@ class AnsibleHcloudImageFacts(Hcloud): def main(): - module = AnsibleHcloudImageFacts.define_module() + module = AnsibleHcloudImageInfo.define_module() - hcloud = AnsibleHcloudImageFacts(module) - hcloud.get_servers() + is_old_facts = module._name == 'hcloud_image_facts' + if is_old_facts: + module.deprecate("The 'hcloud_image_facts' module has been renamed to 'hcloud_image_info', " + "and the renamed one no longer returns ansible_facts", version='2.13') + + hcloud = AnsibleHcloudImageInfo(module) + hcloud.get_images() result = hcloud.get_result() - ansible_facts = { - 'hcloud_image_facts': result['hcloud_image_facts'] - } - module.exit_json(ansible_facts=ansible_facts) + + if is_old_facts: + ansible_info = { + 'hcloud_imagen_facts': result['hcloud_image_info'] + } + module.exit_json(ansible_s=ansible_info) + else: + ansible_info = { + 'hcloud_image_info': result['hcloud_image_info'] + } + module.exit_json(**ansible_info) if __name__ == "__main__": diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_location_facts.py b/lib/ansible/modules/cloud/hcloud/hcloud_location_info.py similarity index 64% rename from lib/ansible/modules/cloud/hcloud/hcloud_location_facts.py rename to lib/ansible/modules/cloud/hcloud/hcloud_location_info.py index 43c2fae9c93..73e3f15117d 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_location_facts.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_location_info.py @@ -16,14 +16,16 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ --- -module: hcloud_location_facts +module: hcloud_location_info -short_description: Gather facts about your Hetzner Cloud locations. +short_description: Gather infos about your Hetzner Cloud locations. version_added: "2.8" description: - - Gather facts about your Hetzner Cloud locations. + - Gather infos about your Hetzner Cloud locations. + - This module was called C(hcloud_location_facts) before Ansible 2.9, returning C(ansible_facts) and C(hcloud_location_facts). + Note that the M(hcloud_location_info) module no longer returns C(ansible_facts) and the value was renamed to C(hcloud_location_info)! author: - Lukas Kaemmerling (@LKaemmerling) @@ -41,18 +43,18 @@ extends_documentation_fragment: hcloud """ EXAMPLES = """ -- name: Gather hcloud location facts - local_action: - module: hcloud_location_facts +- name: Gather hcloud location infos + hcloud_location_info: + register: output -- name: Print the gathered facts +- name: Print the gathered infos debug: - var: ansible_facts.hcloud_location_facts + var: output """ RETURN = """ -hcloud_location_facts: - description: The location facts as list +hcloud_location_info: + description: The location infos as list returned: always type: complex contains: @@ -93,15 +95,15 @@ except ImportError: pass -class AnsibleHcloudLocationFacts(Hcloud): +class AnsibleHcloudLocationInfo(Hcloud): def __init__(self, module): - Hcloud.__init__(self, module, "hcloud_location_facts") - self.hcloud_location_facts = None + Hcloud.__init__(self, module, "hcloud_location_info") + self.hcloud_location_info = None def _prepare_result(self): tmp = [] - for location in self.hcloud_location_facts: + for location in self.hcloud_location_info: if location is not None: tmp.append({ "id": to_native(location.id), @@ -115,15 +117,15 @@ class AnsibleHcloudLocationFacts(Hcloud): def get_locations(self): try: if self.module.params.get("id") is not None: - self.hcloud_location_facts = [self.client.locations.get_by_id( + self.hcloud_location_info = [self.client.locations.get_by_id( self.module.params.get("id") )] elif self.module.params.get("name") is not None: - self.hcloud_location_facts = [self.client.locations.get_by_name( + self.hcloud_location_info = [self.client.locations.get_by_name( self.module.params.get("name") )] else: - self.hcloud_location_facts = self.client.locations.get_all() + self.hcloud_location_info = self.client.locations.get_all() except APIException as e: self.module.fail_json(msg=e.message) @@ -141,15 +143,26 @@ class AnsibleHcloudLocationFacts(Hcloud): def main(): - module = AnsibleHcloudLocationFacts.define_module() + module = AnsibleHcloudLocationInfo.define_module() - hcloud = AnsibleHcloudLocationFacts(module) + is_old_facts = module._name == 'hcloud_location_facts' + if is_old_facts: + module.deprecate("The 'hcloud_location_info' module has been renamed to 'hcloud_location_info', " + "and the renamed one no longer returns ansible_facts", version='2.13') + + hcloud = AnsibleHcloudLocationInfo(module) hcloud.get_locations() result = hcloud.get_result() - ansible_facts = { - 'hcloud_location_facts': result['hcloud_location_facts'] - } - module.exit_json(ansible_facts=ansible_facts) + if is_old_facts: + ansible_info = { + 'hcloud_location_facts': result['hcloud_location_info'] + } + module.exit_json(ansible_s=ansible_info) + else: + ansible_info = { + 'hcloud_location_info': result['hcloud_location_info'] + } + module.exit_json(**ansible_info) if __name__ == "__main__": diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_server_facts.py b/lib/ansible/modules/cloud/hcloud/hcloud_server_info.py similarity index 73% rename from lib/ansible/modules/cloud/hcloud/hcloud_server_facts.py rename to lib/ansible/modules/cloud/hcloud/hcloud_server_info.py index 7b7ce4bed03..0e10ea150cd 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_server_facts.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_server_info.py @@ -16,14 +16,16 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ --- -module: hcloud_server_facts +module: hcloud_server_info -short_description: Gather facts about your Hetzner Cloud servers. +short_description: Gather infos about your Hetzner Cloud servers. version_added: "2.8" description: - - Gather facts about your Hetzner Cloud servers. + - Gather infos about your Hetzner Cloud servers. + - This module was called C(hcloud_server_facts) before Ansible 2.9, returning C(ansible_facts) and C(hcloud_server_facts). + Note that the M(hcloud_server_info) module no longer returns C(ansible_facts) and the value was renamed to C(hcloud_server_info)! author: - Lukas Kaemmerling (@LKaemmerling) @@ -45,18 +47,18 @@ extends_documentation_fragment: hcloud """ EXAMPLES = """ -- name: Gather hcloud server facts - local_action: - module: hcloud_server_facts +- name: Gather hcloud server infos + hcloud_server_info: + register: output -- name: Print the gathered facts +- name: Print the gathered infos debug: - var: ansible_facts.hcloud_server_facts + var: output.hcloud_server_info """ RETURN = """ -hcloud_server_facts: - description: The server facts as list +hcloud_server_info: + description: The server infos as list returned: always type: complex contains: @@ -126,15 +128,15 @@ except ImportError: pass -class AnsibleHcloudServerFacts(Hcloud): +class AnsibleHcloudServerInfo(Hcloud): def __init__(self, module): - Hcloud.__init__(self, module, "hcloud_server_facts") - self.hcloud_server_facts = None + Hcloud.__init__(self, module, "hcloud_server_info") + self.hcloud_server_info = None def _prepare_result(self): tmp = [] - for server in self.hcloud_server_facts: + for server in self.hcloud_server_info: if server is not None: tmp.append({ "id": to_native(server.id), @@ -155,18 +157,18 @@ class AnsibleHcloudServerFacts(Hcloud): def get_servers(self): try: if self.module.params.get("id") is not None: - self.hcloud_server_facts = [self.client.servers.get_by_id( + self.hcloud_server_info = [self.client.servers.get_by_id( self.module.params.get("id") )] elif self.module.params.get("name") is not None: - self.hcloud_server_facts = [self.client.servers.get_by_name( + self.hcloud_server_info = [self.client.servers.get_by_name( self.module.params.get("name") )] elif self.module.params.get("label_selector") is not None: - self.hcloud_server_facts = self.client.servers.get_all( + self.hcloud_server_info = self.client.servers.get_all( label_selector=self.module.params.get("label_selector")) else: - self.hcloud_server_facts = self.client.servers.get_all() + self.hcloud_server_info = self.client.servers.get_all() except APIException as e: self.module.fail_json(msg=e.message) @@ -185,15 +187,27 @@ class AnsibleHcloudServerFacts(Hcloud): def main(): - module = AnsibleHcloudServerFacts.define_module() + module = AnsibleHcloudServerInfo.define_module() - hcloud = AnsibleHcloudServerFacts(module) + is_old_facts = module._name == 'hcloud_server_facts' + if is_old_facts: + module.deprecate("The 'hcloud_server_facts' module has been renamed to 'hcloud_server_info', " + "and the renamed one no longer returns ansible_facts", version='2.13') + + hcloud = AnsibleHcloudServerInfo(module) hcloud.get_servers() result = hcloud.get_result() - ansible_facts = { - 'hcloud_server_facts': result['hcloud_server_facts'] - } - module.exit_json(ansible_facts=ansible_facts) + + if is_old_facts: + ansible_info = { + 'hcloud_server_facts': result['hcloud_server_info'] + } + module.exit_json(ansible_facts=ansible_info) + else: + ansible_info = { + 'hcloud_server_info': result['hcloud_server_info'] + } + module.exit_json(**ansible_info) if __name__ == "__main__": diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_server_type_facts.py b/lib/ansible/modules/cloud/hcloud/hcloud_server_type_info.py similarity index 67% rename from lib/ansible/modules/cloud/hcloud/hcloud_server_type_facts.py rename to lib/ansible/modules/cloud/hcloud/hcloud_server_type_info.py index b07f747efcc..88793260fdc 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_server_type_facts.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_server_type_info.py @@ -16,14 +16,16 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ --- -module: hcloud_server_type_facts +module: hcloud_server_type_info -short_description: Gather facts about the Hetzner Cloud server types. +short_description: Gather infos about the Hetzner Cloud server types. version_added: "2.8" description: - - Gather facts about your Hetzner Cloud server types. + - Gather infos about your Hetzner Cloud server types. + - This module was called C(hcloud_server_type_facts) before Ansible 2.9, returning C(ansible_facts) and C(hcloud_server_type_facts). + Note that the M(hcloud_server_type_info) module no longer returns C(ansible_facts) and the value was renamed to C(hcloud_server_type_info)! author: - Lukas Kaemmerling (@LKaemmerling) @@ -41,18 +43,18 @@ extends_documentation_fragment: hcloud """ EXAMPLES = """ -- name: Gather hcloud server type facts - local_action: - module: hcloud_server_type_facts +- name: Gather hcloud server type infos + hcloud_server_type_info: + register: output -- name: Print the gathered facts +- name: Print the gathered infos debug: - var: ansible_facts.hcloud_server_type_facts + var: output.hcloud_server_type_info """ RETURN = """ -hcloud_server_type_facts: - description: The server type facts as list +hcloud_server_type_info: + description: The server type infos as list returned: always type: complex contains: @@ -108,15 +110,15 @@ except ImportError: pass -class AnsibleHcloudLocationFacts(Hcloud): +class AnsibleHcloudServerTypeInfo(Hcloud): def __init__(self, module): - Hcloud.__init__(self, module, "hcloud_server_type_facts") - self.hcloud_server_type_facts = None + Hcloud.__init__(self, module, "hcloud_server_type_info") + self.hcloud_server_type_info = None def _prepare_result(self): tmp = [] - for server_type in self.hcloud_server_type_facts: + for server_type in self.hcloud_server_type_info: if server_type is not None: tmp.append({ "id": to_native(server_type.id), @@ -133,15 +135,15 @@ class AnsibleHcloudLocationFacts(Hcloud): def get_server_types(self): try: if self.module.params.get("id") is not None: - self.hcloud_server_type_facts = [self.client.server_types.get_by_id( + self.hcloud_server_type_info = [self.client.server_types.get_by_id( self.module.params.get("id") )] elif self.module.params.get("name") is not None: - self.hcloud_server_type_facts = [self.client.server_types.get_by_name( + self.hcloud_server_type_info = [self.client.server_types.get_by_name( self.module.params.get("name") )] else: - self.hcloud_server_type_facts = self.client.server_types.get_all() + self.hcloud_server_type_info = self.client.server_types.get_all() except APIException as e: self.module.fail_json(msg=e.message) @@ -159,15 +161,26 @@ class AnsibleHcloudLocationFacts(Hcloud): def main(): - module = AnsibleHcloudLocationFacts.define_module() + module = AnsibleHcloudServerTypeInfo.define_module() - hcloud = AnsibleHcloudLocationFacts(module) + is_old_facts = module._name == 'hcloud_server_type_facts' + if is_old_facts: + module.deprecate("The 'hcloud_server_type_info' module has been renamed to 'hcloud_server_type_info', " + "and the renamed one no longer returns ansible_facts", version='2.13') + + hcloud = AnsibleHcloudServerTypeInfo(module) hcloud.get_server_types() result = hcloud.get_result() - ansible_facts = { - 'hcloud_server_type_facts': result['hcloud_server_type_facts'] - } - module.exit_json(ansible_facts=ansible_facts) + if is_old_facts: + ansible_info = { + 'hcloud_server_type_info': result['hcloud_server_type_info'] + } + module.exit_json(ansible_facts=ansible_info) + else: + ansible_info = { + 'hcloud_server_type_info': result['hcloud_server_type_info'] + } + module.exit_json(**ansible_info) if __name__ == "__main__": diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_ssh_key_facts.py b/lib/ansible/modules/cloud/hcloud/hcloud_ssh_key_info.py similarity index 68% rename from lib/ansible/modules/cloud/hcloud/hcloud_ssh_key_facts.py rename to lib/ansible/modules/cloud/hcloud/hcloud_ssh_key_info.py index 158e08ef775..078b4a1ccdf 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_ssh_key_facts.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_ssh_key_info.py @@ -16,11 +16,13 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ --- -module: hcloud_ssh_key_facts -short_description: Gather facts about your Hetzner Cloud ssh_keys. +module: hcloud_ssh_key_info +short_description: Gather infos about your Hetzner Cloud ssh_keys. version_added: "2.8" description: - Gather facts about your Hetzner Cloud ssh_keys. + - This module was called C(hcloud_ssh_key_facts) before Ansible 2.9, returning C(ansible_facts) and C(hcloud_ssh_key_facts). + Note that the M(hcloud_ssh_key_info) module no longer returns C(ansible_facts) and the value was renamed to C(hcloud_ssh_key_info)! author: - Christopher Schmitt (@cschmitt-hcloud) options: @@ -44,16 +46,16 @@ extends_documentation_fragment: hcloud """ EXAMPLES = """ -- name: Gather hcloud sshkey facts - local_action: - module: hcloud_ssh_key_facts -- name: Print the gathered facts +- name: Gather hcloud sshkey infos + hcloud_ssh_key_info: + register: output +- name: Print the gathered infos debug: - var: ansible_facts.hcloud_ssh_key_facts + var: output.hcloud_ssh_key_info """ RETURN = """ -hcloud_ssh_key_facts: +hcloud_ssh_key_info: description: The ssh key instances returned: Always type: complex @@ -93,15 +95,15 @@ except ImportError: pass -class AnsibleHcloudSSHKeyFacts(Hcloud): +class AnsibleHcloudSSHKeyInfo(Hcloud): def __init__(self, module): - Hcloud.__init__(self, module, "hcloud_ssh_key_facts") - self.hcloud_ssh_key_facts = None + Hcloud.__init__(self, module, "hcloud_ssh_key_info") + self.hcloud_ssh_key_info = None def _prepare_result(self): ssh_keys = [] - for ssh_key in self.hcloud_ssh_key_facts: + for ssh_key in self.hcloud_ssh_key_info: if ssh_key: ssh_keys.append({ "id": to_native(ssh_key.id), @@ -115,22 +117,22 @@ class AnsibleHcloudSSHKeyFacts(Hcloud): def get_ssh_keys(self): try: if self.module.params.get("id") is not None: - self.hcloud_ssh_key_facts = [self.client.ssh_keys.get_by_id( + self.hcloud_ssh_key_info = [self.client.ssh_keys.get_by_id( self.module.params.get("id") )] elif self.module.params.get("name") is not None: - self.hcloud_ssh_key_facts = [self.client.ssh_keys.get_by_name( + self.hcloud_ssh_key_info = [self.client.ssh_keys.get_by_name( self.module.params.get("name") )] elif self.module.params.get("fingerprint") is not None: - self.hcloud_ssh_key_facts = [self.client.ssh_keys.get_by_fingerprint( + self.hcloud_ssh_key_info = [self.client.ssh_keys.get_by_fingerprint( self.module.params.get("fingerprint") )] elif self.module.params.get("label_selector") is not None: - self.hcloud_ssh_key_facts = self.client.ssh_keys.get_all( + self.hcloud_ssh_key_info = self.client.ssh_keys.get_all( label_selector=self.module.params.get("label_selector")) else: - self.hcloud_ssh_key_facts = self.client.ssh_keys.get_all() + self.hcloud_ssh_key_info = self.client.ssh_keys.get_all() except APIException as e: self.module.fail_json(msg=e.message) @@ -150,15 +152,27 @@ class AnsibleHcloudSSHKeyFacts(Hcloud): def main(): - module = AnsibleHcloudSSHKeyFacts.define_module() + module = AnsibleHcloudSSHKeyInfo.define_module() - hcloud = AnsibleHcloudSSHKeyFacts(module) + is_old_facts = module._name == 'hcloud_ssh_key_facts' + if is_old_facts: + module.deprecate("The 'hcloud_ssh_key_facts' module has been renamed to 'hcloud_ssh_key_info', " + "and the renamed one no longer returns ansible_facts", version='2.13') + + hcloud = AnsibleHcloudSSHKeyInfo(module) hcloud.get_ssh_keys() result = hcloud.get_result() - ansible_facts = { - 'hcloud_ssh_key_facts': result['hcloud_ssh_key_facts'] - } - module.exit_json(ansible_facts=ansible_facts) + + if is_old_facts: + ansible_info = { + 'hcloud_ssh_key_facts': result['hcloud_ssh_key_info'] + } + module.exit_json(ansible_facts=ansible_info) + else: + ansible_info = { + 'hcloud_ssh_key_info': result['hcloud_ssh_key_info'] + } + module.exit_json(**ansible_info) if __name__ == "__main__": diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_volume_facts.py b/lib/ansible/modules/cloud/hcloud/hcloud_volume_info.py similarity index 70% rename from lib/ansible/modules/cloud/hcloud/hcloud_volume_facts.py rename to lib/ansible/modules/cloud/hcloud/hcloud_volume_info.py index 80559ab95c5..5dcc6b556ab 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_volume_facts.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_volume_info.py @@ -16,13 +16,13 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ --- -module: hcloud_volume_facts +module: hcloud_volume_info -short_description: Gather facts about your Hetzner Cloud volumes. +short_description: Gather infos about your Hetzner Cloud volumes. version_added: "2.8" description: - - Gather facts about your Hetzner Cloud volumes. + - Gather infos about your Hetzner Cloud volumes. author: - Lukas Kaemmerling (@LKaemmerling) @@ -44,17 +44,17 @@ extends_documentation_fragment: hcloud """ EXAMPLES = """ -- name: Gather hcloud volume facts - local_action: - module: hcloud_volume_facts -- name: Print the gathered facts +- name: Gather hcloud volume infos + hcloud_volume_info: + register: output +- name: Print the gathered infos debug: - var: ansible_facts.hcloud_volume_facts + var: output.hcloud_volume_info """ RETURN = """ -hcloud_volume_facts: - description: The volume facts as list +hcloud_volume_info: + description: The volume infos as list returned: always type: complex contains: @@ -99,15 +99,15 @@ except ImportError: pass -class AnsibleHcloudVolumeFacts(Hcloud): +class AnsibleHcloudVolumeInfo(Hcloud): def __init__(self, module): - Hcloud.__init__(self, module, "hcloud_volume_facts") - self.hcloud_volume_facts = None + Hcloud.__init__(self, module, "hcloud_volume_info") + self.hcloud_volume_info = None def _prepare_result(self): tmp = [] - for volume in self.hcloud_volume_facts: + for volume in self.hcloud_volume_info: if volume is not None: server_name = None if volume.server is not None: @@ -126,18 +126,18 @@ class AnsibleHcloudVolumeFacts(Hcloud): def get_volumes(self): try: if self.module.params.get("id") is not None: - self.hcloud_volume_facts = [self.client.volumes.get_by_id( + self.hcloud_volume_info = [self.client.volumes.get_by_id( self.module.params.get("id") )] elif self.module.params.get("name") is not None: - self.hcloud_volume_facts = [self.client.volumes.get_by_name( + self.hcloud_volume_info = [self.client.volumes.get_by_name( self.module.params.get("name") )] elif self.module.params.get("label_selector") is not None: - self.hcloud_volume_facts = self.client.volumes.get_all( + self.hcloud_volume_info = self.client.volumes.get_all( label_selector=self.module.params.get("label_selector")) else: - self.hcloud_volume_facts = self.client.volumes.get_all() + self.hcloud_volume_info = self.client.volumes.get_all() except APIException as e: self.module.fail_json(msg=e.message) @@ -156,16 +156,27 @@ class AnsibleHcloudVolumeFacts(Hcloud): def main(): - module = AnsibleHcloudVolumeFacts.define_module() + module = AnsibleHcloudVolumeInfo.define_module() - hcloud = AnsibleHcloudVolumeFacts(module) + is_old_facts = module._name == 'hcloud_volume_facts' + if is_old_facts: + module.deprecate("The 'hcloud_volume_facts' module has been renamed to 'hcloud_volume_info', " + "and the renamed one no longer returns ansible_facts", version='2.13') + + hcloud = AnsibleHcloudVolumeInfo(module) hcloud.get_volumes() result = hcloud.get_result() - ansible_facts = { - 'hcloud_volume_facts': result['hcloud_volume_facts'] - } - module.exit_json(ansible_facts=ansible_facts) + if is_old_facts: + ansible_info = { + 'hcloud_volume_facts': result['hcloud_volume_info'] + } + module.exit_json(ansible_facts=ansible_info) + else: + ansible_info = { + 'hcloud_volume_info': result['hcloud_volume_info'] + } + module.exit_json(**ansible_info) if __name__ == "__main__": diff --git a/test/integration/targets/hcloud_datacenter_facts/tasks/main.yml b/test/integration/targets/hcloud_datacenter_facts/tasks/main.yml deleted file mode 100644 index 09723be49c0..00000000000 --- a/test/integration/targets/hcloud_datacenter_facts/tasks/main.yml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright: (c) 2019, Hetzner Cloud GmbH -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather hcloud datacenter facts - hcloud_datacenter_facts: - -- name: verify test gather hcloud datacenter facts - assert: - that: - - ansible_facts.hcloud_datacenter_facts| list | count == 3 - -- name: test gather hcloud datacenter facts in check mode - hcloud_datacenter_facts: - check_mode: yes - -- name: verify test gather hcloud datacenter facts in check mode - assert: - that: - - ansible_facts.hcloud_datacenter_facts| list | count == 3 - - -- name: test gather hcloud datacenter facts with correct name - hcloud_datacenter_facts: - name: "{{hcloud_datacenter_name}}" -- name: verify test gather hcloud datacenter with correct name - assert: - that: - - ansible_facts.hcloud_datacenter_facts|selectattr('name','equalto','{{ hcloud_datacenter_name }}') |selectattr('location','equalto','{{ hcloud_location_name }}') | list | count == 1 - -- name: test gather hcloud datacenter facts with correct id - hcloud_datacenter_facts: - id: "{{hcloud_datacenter_id}}" -- name: verify test gather hcloud datacenter with correct id - assert: - that: - - ansible_facts.hcloud_datacenter_facts|selectattr('name','equalto','{{ hcloud_datacenter_name }}') | list | count == 1 diff --git a/test/integration/targets/hcloud_datacenter_facts/aliases b/test/integration/targets/hcloud_datacenter_info/aliases similarity index 100% rename from test/integration/targets/hcloud_datacenter_facts/aliases rename to test/integration/targets/hcloud_datacenter_info/aliases diff --git a/test/integration/targets/hcloud_datacenter_facts/defaults/main.yml b/test/integration/targets/hcloud_datacenter_info/defaults/main.yml similarity index 100% rename from test/integration/targets/hcloud_datacenter_facts/defaults/main.yml rename to test/integration/targets/hcloud_datacenter_info/defaults/main.yml diff --git a/test/integration/targets/hcloud_datacenter_info/tasks/main.yml b/test/integration/targets/hcloud_datacenter_info/tasks/main.yml new file mode 100644 index 00000000000..7f49b040c58 --- /dev/null +++ b/test/integration/targets/hcloud_datacenter_info/tasks/main.yml @@ -0,0 +1,40 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather hcloud datacenter infos + hcloud_datacenter_info: + register: hcloud_datacenters + +- name: verify test gather hcloud datacenter infos + assert: + that: + - hcloud_datacenters.hcloud_datacenter_info| list | count == 3 + +- name: test gather hcloud datacenter infos in check mode + hcloud_datacenter_info: + register: hcloud_datacenters + check_mode: yes + +- name: verify test gather hcloud datacenter infos in check mode + assert: + that: + - hcloud_datacenters.hcloud_datacenter_info| list | count == 3 + + +- name: test gather hcloud datacenter infos with correct name + hcloud_datacenter_info: + name: "{{hcloud_datacenter_name}}" + register: hcloud_datacenter +- name: verify test gather hcloud datacenter with correct name + assert: + that: + - hcloud_datacenter.hcloud_datacenter_info|selectattr('name','equalto','{{ hcloud_datacenter_name }}') |selectattr('location','equalto','{{ hcloud_location_name }}') | list | count == 1 + +- name: test gather hcloud datacenter infos with correct id + hcloud_datacenter_info: + id: "{{hcloud_datacenter_id}}" + register: hcloud_datacenter +- name: verify test gather hcloud datacenter with correct id + assert: + that: + - hcloud_datacenter.hcloud_datacenter_info|selectattr('name','equalto','{{ hcloud_datacenter_name }}') | list | count == 1 diff --git a/test/integration/targets/hcloud_floating_ip_facts/tasks/main.yml b/test/integration/targets/hcloud_floating_ip_facts/tasks/main.yml deleted file mode 100644 index a29cc10ff09..00000000000 --- a/test/integration/targets/hcloud_floating_ip_facts/tasks/main.yml +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright: (c) 2019, Hetzner Cloud GmbH -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather hcloud floating ip facts - hcloud_floating_ip_facts: -- name: verify test gather hcloud floating ip facts in check mode - assert: - that: - - ansible_facts.hcloud_floating_ip_facts| list | count == 1 - -- name: test gather hcloud floating ip facts in check mode - hcloud_floating_ip_facts: - check_mode: yes - -- name: verify test gather hcloud floating ip facts in check mode - assert: - that: - - ansible_facts.hcloud_floating_ip_facts| list | count == 1 - - -- name: test gather hcloud floating ip facts with correct label selector - hcloud_floating_ip_facts: - label_selector: "key=value" -- name: verify test gather hcloud floating ip with correct label selector - assert: - that: - - ansible_facts.hcloud_floating_ip_facts|selectattr('description','equalto','{{ hcloud_test_floating_ip_name }}') | list | count == 1 - -- name: test gather hcloud floating ip facts with wrong label selector - hcloud_floating_ip_facts: - label_selector: "key!=value" -- name: verify test gather hcloud floating ip with wrong label selector - assert: - that: - - ansible_facts.hcloud_floating_ip_facts | list | count == 0 - -- name: test gather hcloud floating ip facts with correct id - hcloud_floating_ip_facts: - id: "{{hcloud_test_floating_ip_id}}" -- name: verify test gather hcloud floating ip with correct id - assert: - that: - - ansible_facts.hcloud_floating_ip_facts|selectattr('description','equalto','{{ hcloud_test_floating_ip_name }}') | list | count == 1 - -- name: test gather hcloud floating ip facts with wrong id - hcloud_floating_ip_facts: - id: "{{hcloud_test_floating_ip_id}}1" - register: result - ignore_errors: yes -- name: verify test gather hcloud floating ip with wrong id - assert: - that: - - result is failed diff --git a/test/integration/targets/hcloud_floating_ip_facts/aliases b/test/integration/targets/hcloud_floating_ip_info/aliases similarity index 100% rename from test/integration/targets/hcloud_floating_ip_facts/aliases rename to test/integration/targets/hcloud_floating_ip_info/aliases diff --git a/test/integration/targets/hcloud_floating_ip_facts/defaults/main.yml b/test/integration/targets/hcloud_floating_ip_info/defaults/main.yml similarity index 100% rename from test/integration/targets/hcloud_floating_ip_facts/defaults/main.yml rename to test/integration/targets/hcloud_floating_ip_info/defaults/main.yml diff --git a/test/integration/targets/hcloud_floating_ip_info/tasks/main.yml b/test/integration/targets/hcloud_floating_ip_info/tasks/main.yml new file mode 100644 index 00000000000..4b1ba555c56 --- /dev/null +++ b/test/integration/targets/hcloud_floating_ip_info/tasks/main.yml @@ -0,0 +1,58 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather hcloud floating ip infos + hcloud_floating_ip_info: + register: hcloud_floating_ips +- name: verify test gather hcloud floating ip infos in check mode + assert: + that: + - hcloud_floating_ips.hcloud_floating_ip_info| list | count == 1 + +- name: test gather hcloud floating ip infos in check mode + hcloud_floating_ip_info: + check_mode: yes + register: hcloud_floating_ips + +- name: verify test gather hcloud floating ip infos in check mode + assert: + that: + - hcloud_floating_ips.hcloud_floating_ip_info| list | count == 1 + + +- name: test gather hcloud floating ip infos with correct label selector + hcloud_floating_ip_info: + label_selector: "key=value" + register: hcloud_floating_ips +- name: verify test gather hcloud floating ip with correct label selector + assert: + that: + - hcloud_floating_ips.hcloud_floating_ip_info|selectattr('description','equalto','{{ hcloud_test_floating_ip_name }}') | list | count == 1 + +- name: test gather hcloud floating ip infos with wrong label selector + hcloud_floating_ip_info: + label_selector: "key!=value" + register: hcloud_floating_ips +- name: verify test gather hcloud floating ip with wrong label selector + assert: + that: + - hcloud_floating_ips.hcloud_floating_ip_info | list | count == 0 + +- name: test gather hcloud floating ip infos with correct id + hcloud_floating_ip_info: + id: "{{hcloud_test_floating_ip_id}}" + register: hcloud_floating_ips +- name: verify test gather hcloud floating ip with correct id + assert: + that: + - hcloud_floating_ips.hcloud_floating_ip_info|selectattr('description','equalto','{{ hcloud_test_floating_ip_name }}') | list | count == 1 + +- name: test gather hcloud floating ip infos with wrong id + hcloud_floating_ip_info: + id: "{{hcloud_test_floating_ip_id}}1" + register: result + ignore_errors: yes +- name: verify test gather hcloud floating ip with wrong id + assert: + that: + - result is failed diff --git a/test/integration/targets/hcloud_image_facts/tasks/main.yml b/test/integration/targets/hcloud_image_facts/tasks/main.yml deleted file mode 100644 index b44b08a61fa..00000000000 --- a/test/integration/targets/hcloud_image_facts/tasks/main.yml +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright: (c) 2019, Hetzner Cloud GmbH -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather hcloud image facts with type system - hcloud_image_facts: -- name: verify test gather hcloud image facts in check mode - assert: - that: - - ansible_facts.hcloud_image_facts| list | count > 2 - -- name: test gather hcloud image facts in check mode - hcloud_image_facts: - check_mode: yes - -- name: verify test gather hcloud image facts in check mode - assert: - that: - - ansible_facts.hcloud_image_facts| list | count > 2 - - -- name: test gather hcloud image facts with correct label selector - hcloud_image_facts: - label_selector: "key=value" - type: snapshot -- name: verify test gather hcloud image with correct label selector - assert: - that: - - ansible_facts.hcloud_image_facts|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1 - -- name: test gather hcloud image facts with wrong label selector - hcloud_image_facts: - label_selector: "key!=value" - type: snapshot -- name: verify test gather hcloud image with wrong label selector - assert: - that: - - ansible_facts.hcloud_image_facts | list | count == 0 - -- name: test gather hcloud image facts with correct id - hcloud_image_facts: - id: "{{hcloud_test_image_id}}" - type: snapshot -- name: verify test gather hcloud image with correct id - assert: - that: - - ansible_facts.hcloud_image_facts|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1 - -- name: test gather hcloud image facts with wrong id - hcloud_image_facts: - id: "{{hcloud_test_image_id}}1" - type: snapshot - ignore_errors: yes - register: result -- name: verify test gather hcloud image with wrong id - assert: - that: - - result is failed diff --git a/test/integration/targets/hcloud_image_facts/aliases b/test/integration/targets/hcloud_image_info/aliases similarity index 100% rename from test/integration/targets/hcloud_image_facts/aliases rename to test/integration/targets/hcloud_image_info/aliases diff --git a/test/integration/targets/hcloud_image_facts/defaults/main.yml b/test/integration/targets/hcloud_image_info/defaults/main.yml similarity index 100% rename from test/integration/targets/hcloud_image_facts/defaults/main.yml rename to test/integration/targets/hcloud_image_info/defaults/main.yml diff --git a/test/integration/targets/hcloud_image_info/tasks/main.yml b/test/integration/targets/hcloud_image_info/tasks/main.yml new file mode 100644 index 00000000000..503d5b78704 --- /dev/null +++ b/test/integration/targets/hcloud_image_info/tasks/main.yml @@ -0,0 +1,62 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather hcloud image infos with type system + hcloud_image_info: + register: hcloud_images +- name: verify test gather hcloud image infos in check mode + assert: + that: + - hcloud_images.hcloud_image_info| list | count > 2 + +- name: test gather hcloud image infos in check mode + hcloud_image_info: + check_mode: yes + register: hcloud_images + +- name: verify test gather hcloud image infos in check mode + assert: + that: + - hcloud_images.hcloud_image_info| list | count > 2 + + +- name: test gather hcloud image infos with correct label selector + hcloud_image_info: + label_selector: "key=value" + type: snapshot + register: hcloud_images +- name: verify test gather hcloud image with correct label selector + assert: + that: + - hcloud_images.hcloud_image_info|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1 + +- name: test gather hcloud image infos with wrong label selector + hcloud_image_info: + label_selector: "key!=value" + type: snapshot + register: hcloud_images +- name: verify test gather hcloud image with wrong label selector + assert: + that: + - hcloud_images.hcloud_image_info | list | count == 0 + +- name: test gather hcloud image infos with correct id + hcloud_image_info: + id: "{{hcloud_test_image_id}}" + type: snapshot + register: hcloud_images +- name: verify test gather hcloud image with correct id + assert: + that: + - hcloud_images.hcloud_image_info|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1 + +- name: test gather hcloud image infos with wrong id + hcloud_image_info: + id: "{{hcloud_test_image_id}}1" + type: snapshot + ignore_errors: yes + register: result +- name: verify test gather hcloud image with wrong id + assert: + that: + - result is failed diff --git a/test/integration/targets/hcloud_location_facts/tasks/main.yml b/test/integration/targets/hcloud_location_facts/tasks/main.yml deleted file mode 100644 index 0a36678a4df..00000000000 --- a/test/integration/targets/hcloud_location_facts/tasks/main.yml +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright: (c) 2019, Hetzner Cloud GmbH -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather hcloud location facts - hcloud_location_facts: - -- name: verify test gather hcloud location facts - assert: - that: - - ansible_facts.hcloud_location_facts| list | count == 3 - -- name: test gather hcloud location facts in check mode - hcloud_location_facts: - check_mode: yes - -- name: verify test gather hcloud location facts in check mode - assert: - that: - - ansible_facts.hcloud_location_facts| list | count == 3 - - -- name: test gather hcloud location facts with correct name - hcloud_location_facts: - name: "{{hcloud_location_name}}" -- name: verify test gather hcloud location with correct name - assert: - that: - - ansible_facts.hcloud_location_facts|selectattr('name','equalto','{{ hcloud_location_name }}') | list | count == 1 - -- name: test gather hcloud location facts with wrong name - hcloud_location_facts: - name: "{{hcloud_location_name}}1" -- name: verify test gather hcloud location with wrong name - assert: - that: - - ansible_facts.hcloud_location_facts | list | count == 0 - -- name: test gather hcloud location facts with correct id - hcloud_location_facts: - id: "{{hcloud_location_id}}" -- name: verify test gather hcloud location with correct id - assert: - that: - - ansible_facts.hcloud_location_facts|selectattr('name','equalto','{{ hcloud_location_name }}') | list | count == 1 - -- name: test gather hcloud location facts with wrong id - hcloud_location_facts: - name: "4711" -- name: verify test gather hcloud location with wrong id - assert: - that: - - ansible_facts.hcloud_location_facts | list | count == 0 diff --git a/test/integration/targets/hcloud_location_facts/aliases b/test/integration/targets/hcloud_location_info/aliases similarity index 100% rename from test/integration/targets/hcloud_location_facts/aliases rename to test/integration/targets/hcloud_location_info/aliases diff --git a/test/integration/targets/hcloud_location_facts/defaults/main.yml b/test/integration/targets/hcloud_location_info/defaults/main.yml similarity index 100% rename from test/integration/targets/hcloud_location_facts/defaults/main.yml rename to test/integration/targets/hcloud_location_info/defaults/main.yml diff --git a/test/integration/targets/hcloud_location_info/tasks/main.yml b/test/integration/targets/hcloud_location_info/tasks/main.yml new file mode 100644 index 00000000000..e0ae5f176bb --- /dev/null +++ b/test/integration/targets/hcloud_location_info/tasks/main.yml @@ -0,0 +1,57 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather hcloud location infos + hcloud_location_info: + register: hcloud_location + +- name: verify test gather hcloud location infos + assert: + that: + - hcloud_location.hcloud_location_info | list | count == 3 + +- name: test gather hcloud location infos in check mode + hcloud_location_info: + check_mode: yes + register: hcloud_location + +- name: verify test gather hcloud location infos in check mode + assert: + that: + - hcloud_location.hcloud_location_info | list | count == 3 + +- name: test gather hcloud location infos with correct name + hcloud_location_info: + name: "{{hcloud_location_name}}" + register: hcloud_location +- name: verify test gather hcloud location with correct name + assert: + that: + - hcloud_location.hcloud_location_info|selectattr('name','equalto','{{ hcloud_location_name }}') | list | count == 1 + +- name: test gather hcloud location infos with wrong name + hcloud_location_info: + name: "{{hcloud_location_name}}1" + register: hcloud_location +- name: verify test gather hcloud location with wrong name + assert: + that: + - hcloud_location.hcloud_location_info | list | count == 0 + +- name: test gather hcloud location infos with correct id + hcloud_location_info: + id: "{{hcloud_location_id}}" + register: hcloud_location +- name: verify test gather hcloud location with correct id + assert: + that: + - hcloud_location.hcloud_location_info|selectattr('name','equalto','{{ hcloud_location_name }}') | list | count == 1 + +- name: test gather hcloud location infos with wrong id + hcloud_location_info: + name: "4711" + register: hcloud_location +- name: verify test gather hcloud location with wrong id + assert: + that: + - hcloud_location.hcloud_location_info | list | count == 0 diff --git a/test/integration/targets/hcloud_server_facts/tasks/main.yml b/test/integration/targets/hcloud_server_facts/tasks/main.yml deleted file mode 100644 index d67eaef2bc1..00000000000 --- a/test/integration/targets/hcloud_server_facts/tasks/main.yml +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright: (c) 2019, Hetzner Cloud GmbH -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: setup ensure server is absent - hcloud_server: - name: "{{ hcloud_server_name }}" - state: absent - register: result - -- name: create server - hcloud_server: - name: "{{ hcloud_server_name }}" - server_type: cx11 - image: ubuntu-18.04 - state: started - labels: - key: value - register: main_server -- name: verify create server - assert: - that: - - main_server is changed - - main_server.hcloud_server.name == "{{ hcloud_server_name }}" - - main_server.hcloud_server.server_type == "cx11" - - main_server.hcloud_server.status == "running" - - main_server.root_password != "" - - -- name: test gather hcloud server facts in check mode - hcloud_server_facts: - check_mode: yes - -- name: verify test gather hcloud server facts in check mode - assert: - that: - - ansible_facts.hcloud_server_facts|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1 - - -- name: test gather hcloud server facts with correct label selector - hcloud_server_facts: - label_selector: "key=value" -- name: verify test gather hcloud server with correct label selector - assert: - that: - - ansible_facts.hcloud_server_facts|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1 - -- name: test gather hcloud server facts with wrong label selector - hcloud_server_facts: - label_selector: "key!=value" -- name: verify test gather hcloud server with wrong label selector - assert: - that: - - ansible_facts.hcloud_server_facts | list | count == 0 - -- name: test gather hcloud server facts with correct name - hcloud_server_facts: - name: "{{hcloud_server_name}}" -- name: verify test gather hcloud server with correct name - assert: - that: - - ansible_facts.hcloud_server_facts|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1 - -- name: test gather hcloud server facts with wrong name - hcloud_server_facts: - name: "{{hcloud_server_name}}1" -- name: verify test gather hcloud server with wrong name - assert: - that: - - ansible_facts.hcloud_server_facts | list | count == 0 - -- name: test gather hcloud server facts with correct id - hcloud_server_facts: - id: "{{main_server.hcloud_server.id}}" -- name: verify test gather hcloud server with correct id - assert: - that: - - ansible_facts.hcloud_server_facts|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1 - -- name: test gather hcloud server facts with wrong id - hcloud_server_facts: - name: "4711" -- name: verify test gather hcloud server with wrong id - assert: - that: - - ansible_facts.hcloud_server_facts | list | count == 0 - -- name: cleanup - hcloud_server: - name: "{{ hcloud_server_name }}" - state: absent diff --git a/test/integration/targets/hcloud_server_facts/aliases b/test/integration/targets/hcloud_server_info/aliases similarity index 100% rename from test/integration/targets/hcloud_server_facts/aliases rename to test/integration/targets/hcloud_server_info/aliases diff --git a/test/integration/targets/hcloud_server_facts/defaults/main.yml b/test/integration/targets/hcloud_server_info/defaults/main.yml similarity index 100% rename from test/integration/targets/hcloud_server_facts/defaults/main.yml rename to test/integration/targets/hcloud_server_info/defaults/main.yml diff --git a/test/integration/targets/hcloud_server_info/tasks/main.yml b/test/integration/targets/hcloud_server_info/tasks/main.yml new file mode 100644 index 00000000000..92eac5cc56f --- /dev/null +++ b/test/integration/targets/hcloud_server_info/tasks/main.yml @@ -0,0 +1,97 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup ensure server is absent + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result + +- name: create server + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: cx11 + image: ubuntu-18.04 + state: started + labels: + key: value + register: main_server +- name: verify create server + assert: + that: + - main_server is changed + - main_server.hcloud_server.name == "{{ hcloud_server_name }}" + - main_server.hcloud_server.server_type == "cx11" + - main_server.hcloud_server.status == "running" + - main_server.root_password != "" + + +- name: test gather hcloud server infos in check mode + hcloud_server_info: + register: hcloud_server + check_mode: yes + +- name: verify test gather hcloud server infos in check mode + assert: + that: + - hcloud_server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1 + + +- name: test gather hcloud server infos with correct label selector + hcloud_server_info: + label_selector: "key=value" + register: hcloud_server +- name: verify test gather hcloud server infos with correct label selector + assert: + that: + - hcloud_server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1 + +- name: test gather hcloud server infos with wrong label selector + hcloud_server_info: + label_selector: "key!=value" + register: hcloud_server +- name: verify test gather hcloud server infos with wrong label selector + assert: + that: + - hcloud_server.hcloud_server_info | list | count == 0 + +- name: test gather hcloud server infos with correct name + hcloud_server_info: + name: "{{hcloud_server_name}}" + register: hcloud_server +- name: verify test gather hcloud server infos with correct name + assert: + that: + - hcloud_server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1 + +- name: test gather hcloud server infos with wrong name + hcloud_server_info: + name: "{{hcloud_server_name}}1" + register: hcloud_server +- name: verify test gather hcloud server infos with wrong name + assert: + that: + - hcloud_server.hcloud_server_info | list | count == 0 + +- name: test gather hcloud server infos with correct id + hcloud_server_info: + id: "{{main_server.hcloud_server.id}}" + register: hcloud_server +- name: verify test gather hcloud server infos with correct id + assert: + that: + - hcloud_server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1 + +- name: test gather hcloud server infos with wrong id + hcloud_server_info: + name: "4711" + register: hcloud_server +- name: verify test gather hcloud server infos with wrong id + assert: + that: + - hcloud_server.hcloud_server_info | list | count == 0 + +- name: cleanup + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent diff --git a/test/integration/targets/hcloud_server_type_facts/tasks/main.yml b/test/integration/targets/hcloud_server_type_facts/tasks/main.yml deleted file mode 100644 index c0d2e50296d..00000000000 --- a/test/integration/targets/hcloud_server_type_facts/tasks/main.yml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright: (c) 2019, Hetzner Cloud GmbH -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather hcloud server type facts - hcloud_server_type_facts: -- name: verify test gather hcloud server type facts - assert: - that: - - ansible_facts.hcloud_server_type_facts| list | count > 2 - -- name: test gather hcloud server type facts in check mode - hcloud_server_type_facts: - check_mode: yes - -- name: verify test gather hcloud server type facts in check mode - assert: - that: - - ansible_facts.hcloud_server_type_facts| list | count > 2 - -- name: test gather hcloud server type facts with name - hcloud_server_type_facts: - name: "{{hcloud_server_type_name}}" -- name: verify test gather hcloud server type with name - assert: - that: - - ansible_facts.hcloud_server_type_facts|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1 - -- name: test gather hcloud server type facts with correct id - hcloud_server_type_facts: - id: "{{hcloud_server_type_id}}" -- name: verify test gather hcloud server type with correct id - assert: - that: - - ansible_facts.hcloud_server_type_facts|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1 diff --git a/test/integration/targets/hcloud_server_type_facts/aliases b/test/integration/targets/hcloud_server_type_info/aliases similarity index 100% rename from test/integration/targets/hcloud_server_type_facts/aliases rename to test/integration/targets/hcloud_server_type_info/aliases diff --git a/test/integration/targets/hcloud_server_type_facts/defaults/main.yml b/test/integration/targets/hcloud_server_type_info/defaults/main.yml similarity index 100% rename from test/integration/targets/hcloud_server_type_facts/defaults/main.yml rename to test/integration/targets/hcloud_server_type_info/defaults/main.yml diff --git a/test/integration/targets/hcloud_server_type_info/tasks/main.yml b/test/integration/targets/hcloud_server_type_info/tasks/main.yml new file mode 100644 index 00000000000..3c1fce8c0e0 --- /dev/null +++ b/test/integration/targets/hcloud_server_type_info/tasks/main.yml @@ -0,0 +1,38 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather hcloud server type infos + hcloud_server_type_info: + register: hcloud_server_types +- name: verify test gather hcloud server type infos + assert: + that: + - hcloud_server_types.hcloud_server_type_info| list | count > 2 + +- name: test gather hcloud server type infos in check mode + hcloud_server_type_info: + check_mode: yes + register: hcloud_server_types + +- name: verify test gather hcloud server type infos in check mode + assert: + that: + - hcloud_server_types.hcloud_server_type_info| list | count > 2 + +- name: test gather hcloud server type infos with name + hcloud_server_type_info: + name: "{{hcloud_server_type_name}}" + register: hcloud_server_types +- name: verify test gather hcloud server type with name + assert: + that: + - hcloud_server_types.hcloud_server_type_info|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1 + +- name: test gather hcloud server type infos with correct id + hcloud_server_type_info: + id: "{{hcloud_server_type_id}}" + register: hcloud_server_types +- name: verify test gather hcloud server type with correct id + assert: + that: + - hcloud_server_types.hcloud_server_type_info|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1 diff --git a/test/integration/targets/hcloud_ssh_key_facts/aliases b/test/integration/targets/hcloud_ssh_key_info/aliases similarity index 100% rename from test/integration/targets/hcloud_ssh_key_facts/aliases rename to test/integration/targets/hcloud_ssh_key_info/aliases diff --git a/test/integration/targets/hcloud_ssh_key_facts/defaults/main.yml b/test/integration/targets/hcloud_ssh_key_info/defaults/main.yml similarity index 100% rename from test/integration/targets/hcloud_ssh_key_facts/defaults/main.yml rename to test/integration/targets/hcloud_ssh_key_info/defaults/main.yml diff --git a/test/integration/targets/hcloud_ssh_key_facts/meta/main.yml b/test/integration/targets/hcloud_ssh_key_info/meta/main.yml similarity index 100% rename from test/integration/targets/hcloud_ssh_key_facts/meta/main.yml rename to test/integration/targets/hcloud_ssh_key_info/meta/main.yml diff --git a/test/integration/targets/hcloud_ssh_key_facts/tasks/main.yml b/test/integration/targets/hcloud_ssh_key_info/tasks/main.yml similarity index 52% rename from test/integration/targets/hcloud_ssh_key_facts/tasks/main.yml rename to test/integration/targets/hcloud_ssh_key_info/tasks/main.yml index 8c574f67214..87cbd26264c 100644 --- a/test/integration/targets/hcloud_ssh_key_facts/tasks/main.yml +++ b/test/integration/targets/hcloud_ssh_key_info/tasks/main.yml @@ -21,37 +21,41 @@ - result is changed - result.hcloud_ssh_key.public_key == "{{ key_material }}" -- name: test gather hcloud ssh key facts in check mode - hcloud_ssh_key_facts: +- name: test gather hcloud ssh key infos in check mode + hcloud_ssh_key_info: + register: hcloud_ssh_key check_mode: yes -- name: verify test gather hcloud ssh key facts in check mode +- name: verify test gather hcloud ssh key infos in check mode assert: that: - - ansible_facts.hcloud_ssh_key_facts| list | count >= 1 + - hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1 -- name: test gather hcloud ssh key facts - hcloud_ssh_key_facts: +- name: test gather hcloud ssh key infos + hcloud_ssh_key_info: + register: hcloud_ssh_key check_mode: yes -- name: verify test gather hcloud ssh key facts +- name: verify test gather hcloud ssh key infos assert: that: - - ansible_facts.hcloud_ssh_key_facts| list | count >= 1 + - hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1 -- name: test gather hcloud ssh key facts with correct label selector - hcloud_ssh_key_facts: +- name: test gather hcloud ssh key infos with correct label selector + hcloud_ssh_key_info: label_selector: "key=value" -- name: verify test gather hcloud ssh key with correct label selector + register: hcloud_ssh_key +- name: verify test gather hcloud ssh key infos with correct label selector assert: that: - - ansible_facts.hcloud_ssh_key_facts|selectattr('name','equalto','{{ hcloud_ssh_key_name }}') | list | count == 1 + - hcloud_ssh_key.hcloud_ssh_key_info|selectattr('name','equalto','{{ hcloud_ssh_key_name }}') | list | count == 1 -- name: test gather hcloud ssh key facts with wrong label selector - hcloud_ssh_key_facts: +- name: test gather hcloud ssh key infos with wrong label selector + hcloud_ssh_key_info: label_selector: "key!=value" -- name: verify test gather hcloud ssh key with wrong label selector + register: hcloud_ssh_key +- name: verify test gather hcloud ssh key infos with wrong label selector assert: that: - - ansible_facts.hcloud_ssh_key_facts | list | count == 0 + - hcloud_ssh_key.hcloud_ssh_key_info | list | count == 0 - name: cleanup hcloud_ssh_key: diff --git a/test/integration/targets/hcloud_volume_facts/tasks/main.yml b/test/integration/targets/hcloud_volume_facts/tasks/main.yml deleted file mode 100644 index 9eae2e9a1ab..00000000000 --- a/test/integration/targets/hcloud_volume_facts/tasks/main.yml +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright: (c) 2019, Hetzner Cloud GmbH -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: setup ensure volume is absent - hcloud_volume: - name: "{{ hcloud_volume_name }}" - state: absent - register: result - -- name: setup volume - hcloud_volume: - name: "{{hcloud_volume_name}}" - size: 10 - location: "fsn1" - labels: - key: value - register: main_volume -- name: verify setup volume - assert: - that: - - main_volume is changed - -- name: test gather hcloud volume facts in check mode - hcloud_volume_facts: - check_mode: yes - -- name: verify test gather hcloud volume facts in check mode - assert: - that: - - ansible_facts.hcloud_volume_facts|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1 - -- name: test gather hcloud volume facts with correct label selector - hcloud_volume_facts: - label_selector: "key=value" -- name: verify test gather hcloud volume with correct label selector - assert: - that: - - ansible_facts.hcloud_volume_facts|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1 - -- name: test gather hcloud volume facts with wrong label selector - hcloud_volume_facts: - label_selector: "key!=value" -- name: verify test gather hcloud volume with wrong label selector - assert: - that: - - ansible_facts.hcloud_volume_facts | list | count == 0 - -- name: test gather hcloud volume facts with correct name - hcloud_volume_facts: - name: "{{hcloud_volume_name}}" -- name: verify test gather hcloud volume with correct name - assert: - that: - - ansible_facts.hcloud_volume_facts|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1 - -- name: test gather hcloud volume facts with wrong name - hcloud_volume_facts: - name: "{{hcloud_volume_name}}1" -- name: verify test gather hcloud volume with wrong name - assert: - that: - - ansible_facts.hcloud_volume_facts | list | count == 0 - -- name: test gather hcloud volume facts with correct id - hcloud_volume_facts: - id: "{{main_volume.hcloud_volume.id}}" -- name: verify test gather hcloud volume with correct id - assert: - that: - - ansible_facts.hcloud_volume_facts|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1 - -- name: test gather hcloud volume facts with wrong id - hcloud_volume_facts: - name: "4711" -- name: verify test gather hcloud volume with wrong id - assert: - that: - - ansible_facts.hcloud_volume_facts | list | count == 0 - -- name: cleanup - hcloud_volume: - name: "{{ hcloud_volume_name }}" - state: absent - register: result -- name: verify cleanup - assert: - that: - - result is success diff --git a/test/integration/targets/hcloud_volume_facts/aliases b/test/integration/targets/hcloud_volume_info/aliases similarity index 100% rename from test/integration/targets/hcloud_volume_facts/aliases rename to test/integration/targets/hcloud_volume_info/aliases diff --git a/test/integration/targets/hcloud_volume_facts/defaults/main.yml b/test/integration/targets/hcloud_volume_info/defaults/main.yml similarity index 100% rename from test/integration/targets/hcloud_volume_facts/defaults/main.yml rename to test/integration/targets/hcloud_volume_info/defaults/main.yml diff --git a/test/integration/targets/hcloud_volume_info/tasks/main.yml b/test/integration/targets/hcloud_volume_info/tasks/main.yml new file mode 100644 index 00000000000..7e74bb9a8f8 --- /dev/null +++ b/test/integration/targets/hcloud_volume_info/tasks/main.yml @@ -0,0 +1,95 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup ensure volume is absent + hcloud_volume: + name: "{{ hcloud_volume_name }}" + state: absent + register: result + +- name: setup volume + hcloud_volume: + name: "{{hcloud_volume_name}}" + size: 10 + location: "fsn1" + labels: + key: value + register: main_volume +- name: verify setup volume + assert: + that: + - main_volume is changed + +- name: test gather hcloud volume infos in check mode + hcloud_volume_info: + register: hcloud_volume + check_mode: yes + +- name: verify test gather hcloud volume infos in check mode + assert: + that: + - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1 + +- name: test gather hcloud volume infos with correct label selector + hcloud_volume_info: + label_selector: "key=value" + register: hcloud_volume +- name: verify test gather hcloud volume infos with correct label selector + assert: + that: + - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1 + +- name: test gather hcloud volume infos with wrong label selector + hcloud_volume_info: + label_selector: "key!=value" + register: hcloud_volume +- name: verify test gather hcloud volume infos with wrong label selector + assert: + that: + - hcloud_volume.hcloud_volume_info | list | count == 0 + +- name: test gather hcloud volume infos with correct name + hcloud_volume_info: + name: "{{hcloud_volume_name}}" + register: hcloud_volume +- name: verify test gather hcloud volume infos with correct name + assert: + that: + - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1 + +- name: test gather hcloud volume infos with wrong name + hcloud_volume_info: + name: "{{hcloud_volume_name}}1" + register: hcloud_volume +- name: verify test gather hcloud volume infos with wrong name + assert: + that: + - hcloud_volume.hcloud_volume_info | list | count == 0 + +- name: test gather hcloud volume facts with correct id + hcloud_volume_info: + id: "{{main_volume.hcloud_volume.id}}" + register: hcloud_volume +- name: verify test gather hcloud volume with correct id + assert: + that: + - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1 + +- name: test gather hcloud volume infos with wrong id + hcloud_volume_info: + name: "4711" + register: hcloud_volume +- name: verify test gather hcloud volume infos with wrong id + assert: + that: + - hcloud_volume.hcloud_volume_info | list | count == 0 + +- name: cleanup + hcloud_volume: + name: "{{ hcloud_volume_name }}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is success diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index 1fffed8b860..cd9eb2031dd 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -1518,7 +1518,6 @@ lib/ansible/modules/cloud/google/gcpubsub_info.py validate-modules:E322 lib/ansible/modules/cloud/google/gcpubsub_info.py validate-modules:E324 lib/ansible/modules/cloud/google/gcpubsub_info.py validate-modules:E326 lib/ansible/modules/cloud/google/gcpubsub_info.py validate-modules:E338 -lib/ansible/modules/cloud/hcloud/hcloud_image_facts.py validate-modules:E338 lib/ansible/modules/cloud/heroku/heroku_collaborator.py validate-modules:E337 lib/ansible/modules/cloud/kubevirt/kubevirt_cdi_upload.py validate-modules:E338 lib/ansible/modules/cloud/kubevirt/kubevirt_preset.py validate-modules:E337