From c3b1a0a7e84cfb58c0161b2098bfdceef5907307 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 24 Aug 2019 17:54:17 +0200 Subject: [PATCH] Vultr: rename _facts -> _info (#61239) --- .../fragments/61239-vultr-facts-info.yaml | 8 + .../rst/porting_guides/porting_guide_2.9.rst | 14 ++ .../rst/scenario_guides/guide_vultr.rst | 16 +- ...in_facts.py => _vultr_dns_domain_facts.py} | 6 +- ...acts.py => _vultr_firewall_group_facts.py} | 6 +- ...twork_facts.py => _vultr_network_facts.py} | 6 +- ...ltr_plan_facts.py => _vultr_plan_facts.py} | 6 +- ...region_facts.py => _vultr_region_facts.py} | 6 +- ...server_facts.py => _vultr_server_facts.py} | 6 +- ...acts.py => _vultr_startup_script_facts.py} | 6 +- .../cloud/vultr/vultr_dns_domain_info.py | 116 +++++++++++ .../cloud/vultr/vultr_firewall_group_info.py | 133 ++++++++++++ .../modules/cloud/vultr/vultr_network_info.py | 139 +++++++++++++ .../modules/cloud/vultr/vultr_plan_info.py | 143 +++++++++++++ .../modules/cloud/vultr/vultr_region_info.py | 133 ++++++++++++ .../modules/cloud/vultr/vultr_server_info.py | 192 ++++++++++++++++++ .../cloud/vultr/vultr_startup_script_info.py | 132 ++++++++++++ .../vultr_dns_domain_facts/tasks/main.yml | 30 --- .../aliases | 0 .../defaults/main.yml | 0 .../vultr_dns_domain_info/tasks/main.yml | 32 +++ .../vultr_firewall_group_facts/tasks/main.yml | 31 --- .../aliases | 0 .../defaults/main.yml | 0 .../vultr_firewall_group_info/tasks/main.yml | 33 +++ .../vultr_network_facts/tasks/main.yml | 33 --- .../aliases | 0 .../defaults/main.yml | 0 .../targets/vultr_network_info/tasks/main.yml | 35 ++++ .../targets/vultr_plan_facts/tasks/main.yml | 19 -- .../aliases | 0 .../targets/vultr_plan_info/tasks/main.yml | 21 ++ .../targets/vultr_region_facts/tasks/main.yml | 19 -- .../aliases | 0 .../targets/vultr_region_info/tasks/main.yml | 21 ++ .../aliases | 0 .../defaults/main.yml | 0 .../tasks/main.yml | 33 +-- .../vultr_startup_script_facts/tasks/main.yml | 33 --- .../aliases | 0 .../defaults/main.yml | 0 .../vultr_startup_script_info/tasks/main.yml | 35 ++++ 42 files changed, 1244 insertions(+), 199 deletions(-) create mode 100644 changelogs/fragments/61239-vultr-facts-info.yaml rename lib/ansible/modules/cloud/vultr/{vultr_dns_domain_facts.py => _vultr_dns_domain_facts.py} (94%) rename lib/ansible/modules/cloud/vultr/{vultr_firewall_group_facts.py => _vultr_firewall_group_facts.py} (95%) rename lib/ansible/modules/cloud/vultr/{vultr_network_facts.py => _vultr_network_facts.py} (95%) rename lib/ansible/modules/cloud/vultr/{vultr_plan_facts.py => _vultr_plan_facts.py} (95%) rename lib/ansible/modules/cloud/vultr/{vultr_region_facts.py => _vultr_region_facts.py} (95%) rename lib/ansible/modules/cloud/vultr/{vultr_server_facts.py => _vultr_server_facts.py} (97%) rename lib/ansible/modules/cloud/vultr/{vultr_startup_script_facts.py => _vultr_startup_script_facts.py} (95%) create mode 100644 lib/ansible/modules/cloud/vultr/vultr_dns_domain_info.py create mode 100644 lib/ansible/modules/cloud/vultr/vultr_firewall_group_info.py create mode 100644 lib/ansible/modules/cloud/vultr/vultr_network_info.py create mode 100644 lib/ansible/modules/cloud/vultr/vultr_plan_info.py create mode 100644 lib/ansible/modules/cloud/vultr/vultr_region_info.py create mode 100644 lib/ansible/modules/cloud/vultr/vultr_server_info.py create mode 100644 lib/ansible/modules/cloud/vultr/vultr_startup_script_info.py delete mode 100644 test/integration/targets/vultr_dns_domain_facts/tasks/main.yml rename test/integration/targets/{vultr_dns_domain_facts => vultr_dns_domain_info}/aliases (100%) rename test/integration/targets/{vultr_dns_domain_facts => vultr_dns_domain_info}/defaults/main.yml (100%) create mode 100644 test/integration/targets/vultr_dns_domain_info/tasks/main.yml delete mode 100644 test/integration/targets/vultr_firewall_group_facts/tasks/main.yml rename test/integration/targets/{vultr_firewall_group_facts => vultr_firewall_group_info}/aliases (100%) rename test/integration/targets/{vultr_firewall_group_facts => vultr_firewall_group_info}/defaults/main.yml (100%) create mode 100644 test/integration/targets/vultr_firewall_group_info/tasks/main.yml delete mode 100644 test/integration/targets/vultr_network_facts/tasks/main.yml rename test/integration/targets/{vultr_network_facts => vultr_network_info}/aliases (100%) rename test/integration/targets/{vultr_network_facts => vultr_network_info}/defaults/main.yml (100%) create mode 100644 test/integration/targets/vultr_network_info/tasks/main.yml delete mode 100644 test/integration/targets/vultr_plan_facts/tasks/main.yml rename test/integration/targets/{vultr_plan_facts => vultr_plan_info}/aliases (100%) create mode 100644 test/integration/targets/vultr_plan_info/tasks/main.yml delete mode 100644 test/integration/targets/vultr_region_facts/tasks/main.yml rename test/integration/targets/{vultr_region_facts => vultr_region_info}/aliases (100%) create mode 100644 test/integration/targets/vultr_region_info/tasks/main.yml rename test/integration/targets/{vultr_server_facts => vultr_server_info}/aliases (100%) rename test/integration/targets/{vultr_server_facts => vultr_server_info}/defaults/main.yml (100%) rename test/integration/targets/{vultr_server_facts => vultr_server_info}/tasks/main.yml (54%) delete mode 100644 test/integration/targets/vultr_startup_script_facts/tasks/main.yml rename test/integration/targets/{vultr_startup_script_facts => vultr_startup_script_info}/aliases (100%) rename test/integration/targets/{vultr_startup_script_facts => vultr_startup_script_info}/defaults/main.yml (100%) create mode 100644 test/integration/targets/vultr_startup_script_info/tasks/main.yml diff --git a/changelogs/fragments/61239-vultr-facts-info.yaml b/changelogs/fragments/61239-vultr-facts-info.yaml new file mode 100644 index 00000000000..40e93a9f1dc --- /dev/null +++ b/changelogs/fragments/61239-vultr-facts-info.yaml @@ -0,0 +1,8 @@ +minor_changes: +- The ``vultr_dns_domain_facts`` module has been deprecated. Use ``vultr_dns_domain_info`` instead. +- The ``vultr_firewall_group_facts`` module has been deprecated. Use ``vultr_firewall_group_info`` instead. +- The ``vultr_network_facts`` module has been deprecated. Use ``vultr_network_info`` instead. +- The ``vultr_plan_facts`` module has been deprecated. Use ``vultr_plan_info`` instead. +- The ``vultr_region_facts`` module has been deprecated. Use ``vultr_region_info`` instead. +- The ``vultr_server_facts`` module has been deprecated. Use ``vultr_server_info`` instead. +- The ``vultr_startup_script_facts`` module has been deprecated. Use ``vultr_startup_script_info`` instead. 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 8c45f9caabf..1afed01adbc 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_2.9.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_2.9.rst @@ -94,6 +94,20 @@ The following modules will be removed in Ansible 2.13. Please update update your * purefb_facts use :ref:`purefb_info ` instead. +* vultr_dns_domain_facts use :ref:`vultr_dns_domain_info ` instead. + +* vultr_firewall_group_facts use :ref:`vultr_firewall_group_info ` instead. + +* vultr_network_facts use :ref:`vultr_network_info ` instead. + +* vultr_plan_facts use :ref:`vultr_plan_info ` instead. + +* vultr_region_facts use :ref:`vultr_region_info ` instead. + +* vultr_server_facts use :ref:`vultr_server_info ` instead. + +* vultr_startup_script_facts use :ref:`vultr_startup_script_info ` instead. + * vyos_interface use :ref:`vyos_interfaces ` instead. * vyos_l3_interface use :ref:`vyos_l3_interfaces ` instead. diff --git a/docs/docsite/rst/scenario_guides/guide_vultr.rst b/docs/docsite/rst/scenario_guides/guide_vultr.rst index fbb16222587..eff69ecb76a 100644 --- a/docs/docsite/rst/scenario_guides/guide_vultr.rst +++ b/docs/docsite/rst/scenario_guides/guide_vultr.rst @@ -55,18 +55,10 @@ To check that everything is working properly run the following command: .. code-block:: console - #> VULTR_API_KEY=XXX ansible -m vultr_account_facts localhost + #> VULTR_API_KEY=XXX ansible -m vultr_account_info localhost localhost | SUCCESS => { - "ansible_facts": { - "vultr_account_facts": { - "balance": -8.9, - "last_payment_amount": -10.0, - "last_payment_date": "2018-07-21 11:34:46", - "pending_charges": 6.0 - } - }, "changed": false, - "vultr_account_facts": { + "vultr_account_info": { "balance": -8.9, "last_payment_amount": -10.0, "last_payment_date": "2018-07-21 11:34:46", @@ -172,8 +164,8 @@ Run all Vultr tests: $ ansible-test integration cloud/vultr/ -v --diff --allow-unsupported -To run a specific test, e.g. vultr_account_facts: +To run a specific test, e.g. vultr_account_info: .. code-block:: shell - $ ansible-test integration cloud/vultr/vultr_account_facts -v --diff --allow-unsupported + $ ansible-test integration cloud/vultr/vultr_account_info -v --diff --allow-unsupported diff --git a/lib/ansible/modules/cloud/vultr/vultr_dns_domain_facts.py b/lib/ansible/modules/cloud/vultr/_vultr_dns_domain_facts.py similarity index 94% rename from lib/ansible/modules/cloud/vultr/vultr_dns_domain_facts.py rename to lib/ansible/modules/cloud/vultr/_vultr_dns_domain_facts.py index 3a1872ab7fb..05173412169 100644 --- a/lib/ansible/modules/cloud/vultr/vultr_dns_domain_facts.py +++ b/lib/ansible/modules/cloud/vultr/_vultr_dns_domain_facts.py @@ -7,12 +7,16 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], + 'status': ['deprecated'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: vultr_dns_domain_facts +deprecated: + removed_in: '2.13' + why: Deprecated in favour of C(_info) module. + alternative: Use M(vultr_dns_domain_info) instead. short_description: Gather facts about the Vultr DNS domains available. description: - Gather facts about DNS domains available in Vultr. diff --git a/lib/ansible/modules/cloud/vultr/vultr_firewall_group_facts.py b/lib/ansible/modules/cloud/vultr/_vultr_firewall_group_facts.py similarity index 95% rename from lib/ansible/modules/cloud/vultr/vultr_firewall_group_facts.py rename to lib/ansible/modules/cloud/vultr/_vultr_firewall_group_facts.py index 279b4e7d0d5..f27c40f3f08 100644 --- a/lib/ansible/modules/cloud/vultr/vultr_firewall_group_facts.py +++ b/lib/ansible/modules/cloud/vultr/_vultr_firewall_group_facts.py @@ -7,12 +7,16 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], + 'status': ['deprecated'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: vultr_firewall_group_facts +deprecated: + removed_in: '2.13' + why: Deprecated in favour of C(_info) module. + alternative: Use M(vultr_firewall_group_info) instead. short_description: Gather facts about the Vultr firewall groups available. description: - Gather facts about firewall groups available in Vultr. diff --git a/lib/ansible/modules/cloud/vultr/vultr_network_facts.py b/lib/ansible/modules/cloud/vultr/_vultr_network_facts.py similarity index 95% rename from lib/ansible/modules/cloud/vultr/vultr_network_facts.py rename to lib/ansible/modules/cloud/vultr/_vultr_network_facts.py index eba45254a49..71b3193a725 100644 --- a/lib/ansible/modules/cloud/vultr/vultr_network_facts.py +++ b/lib/ansible/modules/cloud/vultr/_vultr_network_facts.py @@ -7,12 +7,16 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], + 'status': ['deprecated'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: vultr_network_facts +deprecated: + removed_in: '2.13' + why: Deprecated in favour of C(_info) module. + alternative: Use M(vultr_network_info) instead. short_description: Gather facts about the Vultr networks available. description: - Gather facts about networks available in Vultr. diff --git a/lib/ansible/modules/cloud/vultr/vultr_plan_facts.py b/lib/ansible/modules/cloud/vultr/_vultr_plan_facts.py similarity index 95% rename from lib/ansible/modules/cloud/vultr/vultr_plan_facts.py rename to lib/ansible/modules/cloud/vultr/_vultr_plan_facts.py index 75fe03e67e3..e30defadc22 100644 --- a/lib/ansible/modules/cloud/vultr/vultr_plan_facts.py +++ b/lib/ansible/modules/cloud/vultr/_vultr_plan_facts.py @@ -8,12 +8,16 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], + 'status': ['deprecated'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: vultr_plan_facts +deprecated: + removed_in: '2.13' + why: Deprecated in favour of C(_info) module. + alternative: Use M(vultr_plan_info) instead. short_description: Gather facts about the Vultr plans available. description: - Gather facts about plans available to boot servers. diff --git a/lib/ansible/modules/cloud/vultr/vultr_region_facts.py b/lib/ansible/modules/cloud/vultr/_vultr_region_facts.py similarity index 95% rename from lib/ansible/modules/cloud/vultr/vultr_region_facts.py rename to lib/ansible/modules/cloud/vultr/_vultr_region_facts.py index 93738639b06..ec0a81cadd9 100644 --- a/lib/ansible/modules/cloud/vultr/vultr_region_facts.py +++ b/lib/ansible/modules/cloud/vultr/_vultr_region_facts.py @@ -8,12 +8,16 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], + 'status': ['deprecated'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: vultr_region_facts +deprecated: + removed_in: '2.13' + why: Deprecated in favour of C(_info) module. + alternative: Use M(vultr_region_info) instead. short_description: Gather facts about the Vultr regions available. description: - Gather facts about regions available to boot servers. diff --git a/lib/ansible/modules/cloud/vultr/vultr_server_facts.py b/lib/ansible/modules/cloud/vultr/_vultr_server_facts.py similarity index 97% rename from lib/ansible/modules/cloud/vultr/vultr_server_facts.py rename to lib/ansible/modules/cloud/vultr/_vultr_server_facts.py index 11e39f0ee8c..766651500a3 100644 --- a/lib/ansible/modules/cloud/vultr/vultr_server_facts.py +++ b/lib/ansible/modules/cloud/vultr/_vultr_server_facts.py @@ -8,12 +8,16 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], + 'status': ['deprecated'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: vultr_server_facts +deprecated: + removed_in: '2.13' + why: Deprecated in favour of C(_info) module. + alternative: Use M(vultr_server_info) instead. short_description: Gather facts about the Vultr servers available. description: - Gather facts about servers available. diff --git a/lib/ansible/modules/cloud/vultr/vultr_startup_script_facts.py b/lib/ansible/modules/cloud/vultr/_vultr_startup_script_facts.py similarity index 95% rename from lib/ansible/modules/cloud/vultr/vultr_startup_script_facts.py rename to lib/ansible/modules/cloud/vultr/_vultr_startup_script_facts.py index 65cb78ca105..6313bea0afb 100644 --- a/lib/ansible/modules/cloud/vultr/vultr_startup_script_facts.py +++ b/lib/ansible/modules/cloud/vultr/_vultr_startup_script_facts.py @@ -8,12 +8,16 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], + 'status': ['deprecated'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: vultr_startup_script_facts +deprecated: + removed_in: '2.13' + why: Deprecated in favour of C(_info) module. + alternative: Use M(vultr_startup_script_info) instead. short_description: Gather facts about the Vultr startup scripts available. description: - Gather facts about vultr_startup_scripts available. diff --git a/lib/ansible/modules/cloud/vultr/vultr_dns_domain_info.py b/lib/ansible/modules/cloud/vultr/vultr_dns_domain_info.py new file mode 100644 index 00000000000..9730c12726d --- /dev/null +++ b/lib/ansible/modules/cloud/vultr/vultr_dns_domain_info.py @@ -0,0 +1,116 @@ +#!/usr/bin/python +# +# (c) 2018, Yanis Guenane +# 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 + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = r''' +--- +module: vultr_dns_domain_info +short_description: Gather information about the Vultr DNS domains available. +description: + - Gather information about DNS domains available in Vultr. +version_added: "2.9" +author: "Yanis Guenane (@Spredzy)" +extends_documentation_fragment: vultr +''' + +EXAMPLES = r''' +- name: Gather Vultr DNS domains information + local_action: + module: vultr_dns_domains_info + register: result + +- name: Print the gathered information + debug: + var: result.vultr_dns_domain_info +''' + +RETURN = r''' +--- +vultr_api: + description: Response from Vultr API with a few additions/modification + returned: success + type: complex + contains: + api_account: + description: Account used in the ini file to select the key + returned: success + type: str + sample: default + api_timeout: + description: Timeout used for the API requests + returned: success + type: int + sample: 60 + api_retries: + description: Amount of max retries for the API requests + returned: success + type: int + sample: 5 + api_retry_max_delay: + description: Exponential backoff delay in seconds between retries up to this max delay value. + returned: success + type: int + sample: 12 + version_added: '2.9' + api_endpoint: + description: Endpoint used for the API requests + returned: success + type: str + sample: "https://api.vultr.com" +vultr_dns_domain_info: + description: Response from Vultr API + returned: success + type: complex + contains: + "vultr_dns_domain_info": [ + { + "date_created": "2018-07-19 07:14:21", + "domain": "ansibletest.com" + } + ] +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.vultr import ( + Vultr, + vultr_argument_spec, +) + + +class AnsibleVultrDnsDomainInfo(Vultr): + + def __init__(self, module): + super(AnsibleVultrDnsDomainInfo, self).__init__(module, "vultr_dns_domain_info") + + self.returns = { + "date_created": dict(), + "domain": dict(), + } + + def get_domains(self): + return self.api_query(path="/v1/dns/list") + + +def main(): + argument_spec = vultr_argument_spec() + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + domain_info = AnsibleVultrDnsDomainInfo(module) + result = domain_info.get_result(domain_info.get_domains()) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/cloud/vultr/vultr_firewall_group_info.py b/lib/ansible/modules/cloud/vultr/vultr_firewall_group_info.py new file mode 100644 index 00000000000..eab67ba6291 --- /dev/null +++ b/lib/ansible/modules/cloud/vultr/vultr_firewall_group_info.py @@ -0,0 +1,133 @@ +#!/usr/bin/python +# +# (c) 2018, Yanis Guenane +# 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 + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = r''' +--- +module: vultr_firewall_group_info +short_description: Gather information about the Vultr firewall groups available. +description: + - Gather information about firewall groups available in Vultr. +version_added: "2.9" +author: "Yanis Guenane (@Spredzy)" +extends_documentation_fragment: vultr +''' + +EXAMPLES = r''' +- name: Gather Vultr firewall groups information + local_action: + module: vultr_firewall_group_info + register: result + +- name: Print the gathered information + debug: + var: result.vultr_firewall_group_info +''' + +RETURN = r''' +--- +vultr_api: + description: Response from Vultr API with a few additions/modification + returned: success + type: complex + contains: + api_account: + description: Account used in the ini file to select the key + returned: success + type: str + sample: default + api_timeout: + description: Timeout used for the API requests + returned: success + type: int + sample: 60 + api_retries: + description: Amount of max retries for the API requests + returned: success + type: int + sample: 5 + api_retry_max_delay: + description: Exponential backoff delay in seconds between retries up to this max delay value. + returned: success + type: int + sample: 12 + version_added: '2.9' + api_endpoint: + description: Endpoint used for the API requests + returned: success + type: str + sample: "https://api.vultr.com" +vultr_firewall_group_info: + description: Response from Vultr API + returned: success + type: complex + contains: + "vultr_firewall_group_info": [ + { + "date_created": "2018-07-12 10:27:14", + "date_modified": "2018-07-12 10:27:14", + "description": "test", + "id": "5e128ff0", + "instance_count": 0, + "max_rule_count": 50, + "rule_count": 0 + } + ] +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.vultr import ( + Vultr, + vultr_argument_spec, +) + + +class AnsibleVultrFirewallGroupInfo(Vultr): + + def __init__(self, module): + super(AnsibleVultrFirewallGroupInfo, self).__init__(module, "vultr_firewall_group_info") + + self.returns = { + "FIREWALLGROUPID": dict(key='id'), + "date_created": dict(), + "date_modified": dict(), + "description": dict(), + "instance_count": dict(convert_to='int'), + "max_rule_count": dict(convert_to='int'), + "rule_count": dict(convert_to='int') + } + + def get_firewall_group(self): + return self.api_query(path="/v1/firewall/group_list") + + +def parse_fw_group_list(fwgroups_list): + if not fwgroups_list: + return [] + + return [group for id, group in fwgroups_list.items()] + + +def main(): + argument_spec = vultr_argument_spec() + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + fw_group_info = AnsibleVultrFirewallGroupInfo(module) + result = fw_group_info.get_result(parse_fw_group_list(fw_group_info.get_firewall_group())) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/cloud/vultr/vultr_network_info.py b/lib/ansible/modules/cloud/vultr/vultr_network_info.py new file mode 100644 index 00000000000..5b7fb7ee187 --- /dev/null +++ b/lib/ansible/modules/cloud/vultr/vultr_network_info.py @@ -0,0 +1,139 @@ +#!/usr/bin/python +# +# (c) 2018, Yanis Guenane +# 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 + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = r''' +--- +module: vultr_network_info +short_description: Gather information about the Vultr networks available. +description: + - Gather information about networks available in Vultr. +version_added: "2.9" +author: "Yanis Guenane (@Spredzy)" +extends_documentation_fragment: vultr +''' + +EXAMPLES = r''' +- name: Gather Vultr networks information + local_action: + module: vultr_network_info + register: result + +- name: Print the gathered information + debug: + var: result.vultr_network_info +''' + +RETURN = r''' +--- +vultr_api: + description: Response from Vultr API with a few additions/modification + returned: success + type: complex + contains: + api_account: + description: Account used in the ini file to select the key + returned: success + type: str + sample: default + api_timeout: + description: Timeout used for the API requests + returned: success + type: int + sample: 60 + api_retries: + description: Amount of max retries for the API requests + returned: success + type: int + sample: 5 + api_retry_max_delay: + description: Exponential backoff delay in seconds between retries up to this max delay value. + returned: success + type: int + sample: 12 + version_added: '2.9' + api_endpoint: + description: Endpoint used for the API requests + returned: success + type: str + sample: "https://api.vultr.com" +vultr_network_info: + description: Response from Vultr API + returned: success + type: complex + contains: + "vultr_network_info": [ + { + "date_created": "2018-08-02 11:18:49", + "id": "net5b62e8991adfg", + "name": "mynet", + "region": "Amsterdam", + "v4_subnet": "192.168.42.0", + "v4_subnet_mask": 24 + } + ] +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.vultr import ( + Vultr, + vultr_argument_spec, +) + + +class AnsibleVultrNetworkInfo(Vultr): + + def __init__(self, module): + super(AnsibleVultrNetworkInfo, self).__init__(module, "vultr_network_info") + + self.returns = { + 'DCID': dict(key='region', transform=self._get_region_name), + 'NETWORKID': dict(key='id'), + 'date_created': dict(), + 'description': dict(key='name'), + 'v4_subnet': dict(), + 'v4_subnet_mask': dict(convert_to='int'), + } + + def _get_region_name(self, region): + return self.query_resource_by_key( + key='DCID', + value=region, + resource='regions', + use_cache=True + )['name'] + + def get_networks(self): + return self.api_query(path="/v1/network/list") + + +def parse_network_list(network_list): + if isinstance(network_list, list): + return [] + + return [network for id, network in network_list.items()] + + +def main(): + argument_spec = vultr_argument_spec() + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + network_info = AnsibleVultrNetworkInfo(module) + result = network_info.get_result(parse_network_list(network_info.get_networks())) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/cloud/vultr/vultr_plan_info.py b/lib/ansible/modules/cloud/vultr/vultr_plan_info.py new file mode 100644 index 00000000000..956211f5cf8 --- /dev/null +++ b/lib/ansible/modules/cloud/vultr/vultr_plan_info.py @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# (c) 2018, Yanis Guenane +# 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 + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = r''' +--- +module: vultr_plan_info +short_description: Gather information about the Vultr plans available. +description: + - Gather information about plans available to boot servers. +version_added: "2.9" +author: "Yanis Guenane (@Spredzy)" +extends_documentation_fragment: vultr +''' + +EXAMPLES = r''' +- name: Gather Vultr plans information + local_action: + module: vultr_plan_info + register: result + +- name: Print the gathered information + debug: + var: result.vultr_plan_info +''' + +RETURN = r''' +--- +vultr_api: + description: Response from Vultr API with a few additions/modification + returned: success + type: complex + contains: + api_account: + description: Account used in the ini file to select the key + returned: success + type: str + sample: default + api_timeout: + description: Timeout used for the API requests + returned: success + type: int + sample: 60 + api_retries: + description: Amount of max retries for the API requests + returned: success + type: int + sample: 5 + api_retry_max_delay: + description: Exponential backoff delay in seconds between retries up to this max delay value. + returned: success + type: int + sample: 12 + version_added: '2.9' + api_endpoint: + description: Endpoint used for the API requests + returned: success + type: str + sample: "https://api.vultr.com" +vultr_plan_info: + description: Response from Vultr API + returned: success + type: complex + contains: + plan: + description: List of the plans available. + returned: success + type: list + sample: [{ + "available_locations": [ + 1 + ], + "bandwidth": 40.0, + "bandwidth_gb": 40960, + "disk": 110, + "id": 118, + "name": "32768 MB RAM,110 GB SSD,40.00 TB BW", + "plan_type": "DEDICATED", + "price_per_month": 240.0, + "ram": 32768, + "vcpu_count": 8, + "windows": false + }] +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.vultr import ( + Vultr, + vultr_argument_spec, +) + + +class AnsibleVultrPlanInfo(Vultr): + + def __init__(self, module): + super(AnsibleVultrPlanInfo, self).__init__(module, "vultr_plan_info") + + self.returns = { + "VPSPLANID": dict(key='id', convert_to='int'), + "available_locations": dict(), + "bandwidth": dict(convert_to='float'), + "bandwidth_gb": dict(convert_to='int'), + "disk": dict(convert_to='int'), + "name": dict(), + "plan_type": dict(), + "price_per_month": dict(convert_to='float'), + "ram": dict(convert_to='int'), + "vcpu_count": dict(convert_to='int'), + "windows": dict(convert_to='bool') + } + + def get_plans(self): + return self.api_query(path="/v1/plans/list") + + +def parse_plans_list(plans_list): + return [plan for id, plan in plans_list.items()] + + +def main(): + argument_spec = vultr_argument_spec() + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + plan_info = AnsibleVultrPlanInfo(module) + result = plan_info.get_result(parse_plans_list(plan_info.get_plans())) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/cloud/vultr/vultr_region_info.py b/lib/ansible/modules/cloud/vultr/vultr_region_info.py new file mode 100644 index 00000000000..414cd359e75 --- /dev/null +++ b/lib/ansible/modules/cloud/vultr/vultr_region_info.py @@ -0,0 +1,133 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# (c) 2018, Yanis Guenane +# 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 + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = r''' +--- +module: vultr_region_info +short_description: Gather information about the Vultr regions available. +description: + - Gather information about regions available to boot servers. +version_added: "2.9" +author: "Yanis Guenane (@Spredzy)" +extends_documentation_fragment: vultr +''' + +EXAMPLES = r''' +- name: Gather Vultr regions information + local_action: + module: vultr_region_info + register: result + +- name: Print the gathered information + debug: + var: result.vultr_region_info +''' + +RETURN = r''' +--- +vultr_api: + description: Response from Vultr API with a few additions/modification + returned: success + type: complex + contains: + api_account: + description: Account used in the ini file to select the key + returned: success + type: str + sample: default + api_timeout: + description: Timeout used for the API requests + returned: success + type: int + sample: 60 + api_retries: + description: Amount of max retries for the API requests + returned: success + type: int + sample: 5 + api_retry_max_delay: + description: Exponential backoff delay in seconds between retries up to this max delay value. + returned: success + type: int + sample: 12 + version_added: '2.9' + api_endpoint: + description: Endpoint used for the API requests + returned: success + type: str + sample: "https://api.vultr.com" +vultr_region_info: + description: Response from Vultr API + returned: success + type: complex + contains: + "vultr_region_info": [ + { + "block_storage": false, + "continent": "Europe", + "country": "GB", + "ddos_protection": true, + "id": 8, + "name": "London", + "regioncode": "LHR", + "state": "" + } + ] +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.vultr import ( + Vultr, + vultr_argument_spec, +) + + +class AnsibleVultrRegionInfo(Vultr): + + def __init__(self, module): + super(AnsibleVultrRegionInfo, self).__init__(module, "vultr_region_info") + + self.returns = { + "DCID": dict(key='id', convert_to='int'), + "block_storage": dict(convert_to='bool'), + "continent": dict(), + "country": dict(), + "ddos_protection": dict(convert_to='bool'), + "name": dict(), + "regioncode": dict(), + "state": dict() + } + + def get_regions(self): + return self.api_query(path="/v1/regions/list") + + +def parse_regions_list(regions_list): + return [region for id, region in regions_list.items()] + + +def main(): + argument_spec = vultr_argument_spec() + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + region_info = AnsibleVultrRegionInfo(module) + result = region_info.get_result(parse_regions_list(region_info.get_regions())) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/cloud/vultr/vultr_server_info.py b/lib/ansible/modules/cloud/vultr/vultr_server_info.py new file mode 100644 index 00000000000..b6491250208 --- /dev/null +++ b/lib/ansible/modules/cloud/vultr/vultr_server_info.py @@ -0,0 +1,192 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# (c) 2018, Yanis Guenane +# 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 + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = r''' +--- +module: vultr_server_info +short_description: Gather information about the Vultr servers available. +description: + - Gather information about servers available. +version_added: "2.9" +author: "Yanis Guenane (@Spredzy)" +extends_documentation_fragment: vultr +''' + +EXAMPLES = r''' +- name: Gather Vultr servers information + local_action: + module: vultr_server_info + register: result + +- name: Print the gathered information + debug: + var: result.vultr_server_info +''' + +RETURN = r''' +--- +vultr_api: + description: Response from Vultr API with a few additions/modification + returned: success + type: complex + contains: + api_account: + description: Account used in the ini file to select the key + returned: success + type: str + sample: default + api_timeout: + description: Timeout used for the API requests + returned: success + type: int + sample: 60 + api_retries: + description: Amount of max retries for the API requests + returned: success + type: int + sample: 5 + api_retry_max_delay: + description: Exponential backoff delay in seconds between retries up to this max delay value. + returned: success + type: int + sample: 12 + version_added: '2.9' + api_endpoint: + description: Endpoint used for the API requests + returned: success + type: str + sample: "https://api.vultr.com" +vultr_server_info: + description: Response from Vultr API + returned: success + type: complex + contains: + "vultr_server_info": [ + { + "allowed_bandwidth_gb": 1000, + "auto_backup_enabled": false, + "application": null, + "cost_per_month": 5.00, + "current_bandwidth_gb": 0, + "date_created": "2018-07-19 08:23:03", + "default_password": "p4ssw0rd!", + "disk": "Virtual 25 GB", + "firewallgroup": null, + "id": 17241096, + "internal_ip": "", + "kvm_url": "https://my.vultr.com/subs/vps/novnc/api.php?data=OFB...", + "name": "ansibletest", + "os": "CentOS 7 x64", + "pending_charges": 0.01, + "plan": "1024 MB RAM,25 GB SSD,1.00 TB BW", + "power_status": "running", + "ram": "1024 MB", + "region": "Amsterdam", + "server_state": "ok", + "status": "active", + "tag": "", + "v4_gateway": "105.178.158.1", + "v4_main_ip": "105.178.158.181", + "v4_netmask": "255.255.254.0", + "v6_main_ip": "", + "v6_network": "", + "v6_network_size": "", + "v6_networks": [], + "vcpu_count": 1 + } + ] +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.vultr import ( + Vultr, + vultr_argument_spec, +) + + +class AnsibleVultrServerInfo(Vultr): + + def __init__(self, module): + super(AnsibleVultrServerInfo, self).__init__(module, "vultr_server_info") + + self.returns = { + "APPID": dict(key='application', convert_to='int', transform=self._get_application_name), + "FIREWALLGROUPID": dict(key='firewallgroup', transform=self._get_firewallgroup_name), + "SUBID": dict(key='id', convert_to='int'), + "VPSPLANID": dict(key='plan', convert_to='int', transform=self._get_plan_name), + "allowed_bandwidth_gb": dict(convert_to='int'), + 'auto_backups': dict(key='auto_backup_enabled', convert_to='bool'), + "cost_per_month": dict(convert_to='float'), + "current_bandwidth_gb": dict(convert_to='float'), + "date_created": dict(), + "default_password": dict(), + "disk": dict(), + "gateway_v4": dict(key='v4_gateway'), + "internal_ip": dict(), + "kvm_url": dict(), + "label": dict(key='name'), + "location": dict(key='region'), + "main_ip": dict(key='v4_main_ip'), + "netmask_v4": dict(key='v4_netmask'), + "os": dict(), + "pending_charges": dict(convert_to='float'), + "power_status": dict(), + "ram": dict(), + "server_state": dict(), + "status": dict(), + "tag": dict(), + "v6_main_ip": dict(), + "v6_network": dict(), + "v6_network_size": dict(), + "v6_networks": dict(), + "vcpu_count": dict(convert_to='int'), + } + + def _get_application_name(self, application): + if application == 0: + return None + + return self.get_application(application, 'APPID').get('name') + + def _get_firewallgroup_name(self, firewallgroup): + if firewallgroup == 0: + return None + + return self.get_firewallgroup(firewallgroup, 'FIREWALLGROUPID').get('description') + + def _get_plan_name(self, plan): + return self.get_plan(plan, 'VPSPLANID').get('name') + + def get_servers(self): + return self.api_query(path="/v1/server/list") + + +def parse_servers_list(servers_list): + return [server for id, server in servers_list.items()] + + +def main(): + argument_spec = vultr_argument_spec() + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + server_info = AnsibleVultrServerInfo(module) + result = server_info.get_result(parse_servers_list(server_info.get_servers())) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/cloud/vultr/vultr_startup_script_info.py b/lib/ansible/modules/cloud/vultr/vultr_startup_script_info.py new file mode 100644 index 00000000000..b41b53a440d --- /dev/null +++ b/lib/ansible/modules/cloud/vultr/vultr_startup_script_info.py @@ -0,0 +1,132 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# (c) 2018, Yanis Guenane +# 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 + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = r''' +--- +module: vultr_startup_script_info +short_description: Gather information about the Vultr startup scripts available. +description: + - Gather information about vultr_startup_scripts available. +version_added: "2.9" +author: "Yanis Guenane (@Spredzy)" +extends_documentation_fragment: vultr +''' + +EXAMPLES = r''' +- name: Gather Vultr startup scripts information + local_action: + module: vultr_startup_script_info + register: result + +- name: Print the gathered information + debug: + var: result.vultr_startup_script_info +''' + +RETURN = r''' +--- +vultr_api: + description: Response from Vultr API with a few additions/modification + returned: success + type: complex + contains: + api_account: + description: Account used in the ini file to select the key + returned: success + type: str + sample: default + api_timeout: + description: Timeout used for the API requests + returned: success + type: int + sample: 60 + api_retries: + description: Amount of max retries for the API requests + returned: success + type: int + sample: 5 + api_retry_max_delay: + description: Exponential backoff delay in seconds between retries up to this max delay value. + returned: success + type: int + sample: 12 + version_added: '2.9' + api_endpoint: + description: Endpoint used for the API requests + returned: success + type: str + sample: "https://api.vultr.com" +vultr_startup_script_info: + description: Response from Vultr API + returned: success + type: complex + contains: + "vultr_startup_script_info": [ + { + "date_created": "2018-07-19 08:38:36", + "date_modified": "2018-07-19 08:38:36", + "id": 327133, + "name": "lolo", + "script": "#!/bin/bash\necho Hello World > /root/hello", + "type": "boot" + } + ] +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.vultr import ( + Vultr, + vultr_argument_spec, +) + + +class AnsibleVultrStartupScriptInfo(Vultr): + + def __init__(self, module): + super(AnsibleVultrStartupScriptInfo, self).__init__(module, "vultr_startup_script_info") + + self.returns = { + "SCRIPTID": dict(key='id', convert_to='int'), + "date_created": dict(), + "date_modified": dict(), + "name": dict(), + "script": dict(), + "type": dict(), + } + + def get_startupscripts(self): + return self.api_query(path="/v1/startupscript/list") + + +def parse_startupscript_list(startupscipts_list): + if not startupscipts_list: + return [] + + return [startupscript for id, startupscript in startupscipts_list.items()] + + +def main(): + argument_spec = vultr_argument_spec() + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + startupscript_info = AnsibleVultrStartupScriptInfo(module) + result = startupscript_info.get_result(parse_startupscript_list(startupscript_info.get_startupscripts())) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/test/integration/targets/vultr_dns_domain_facts/tasks/main.yml b/test/integration/targets/vultr_dns_domain_facts/tasks/main.yml deleted file mode 100644 index 31d13dfe4de..00000000000 --- a/test/integration/targets/vultr_dns_domain_facts/tasks/main.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) 2018, Yanis Guenane -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: Create the record - vultr_dns_domain: - name: '{{ dns_domain_name }}' - server_ip: '{{ dns_domain_server_ip }}' - -- name: test gather vultr dns domain facts in check mode - vultr_dns_domain_facts: - check_mode: yes - -- name: verify test gather vultr dns domain facts in check mode - assert: - that: - - ansible_facts.vultr_dns_domain_facts|selectattr('domain','equalto','{{ dns_domain_name }}') | list | count == 1 - -- name: test gather vultr dns domain facts - vultr_dns_domain_facts: - -- name: verify test gather vultr dns domain facts - assert: - that: - - ansible_facts.vultr_dns_domain_facts|selectattr('domain','equalto','{{ dns_domain_name }}') | list | count == 1 - -- name: Delete the record - vultr_dns_domain: - name: '{{ dns_domain_name }}' - server_ip: '{{ dns_domain_server_ip }}' - state: absent diff --git a/test/integration/targets/vultr_dns_domain_facts/aliases b/test/integration/targets/vultr_dns_domain_info/aliases similarity index 100% rename from test/integration/targets/vultr_dns_domain_facts/aliases rename to test/integration/targets/vultr_dns_domain_info/aliases diff --git a/test/integration/targets/vultr_dns_domain_facts/defaults/main.yml b/test/integration/targets/vultr_dns_domain_info/defaults/main.yml similarity index 100% rename from test/integration/targets/vultr_dns_domain_facts/defaults/main.yml rename to test/integration/targets/vultr_dns_domain_info/defaults/main.yml diff --git a/test/integration/targets/vultr_dns_domain_info/tasks/main.yml b/test/integration/targets/vultr_dns_domain_info/tasks/main.yml new file mode 100644 index 00000000000..d58aa108500 --- /dev/null +++ b/test/integration/targets/vultr_dns_domain_info/tasks/main.yml @@ -0,0 +1,32 @@ +# Copyright (c) 2018, Yanis Guenane +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Create the record + vultr_dns_domain: + name: '{{ dns_domain_name }}' + server_ip: '{{ dns_domain_server_ip }}' + +- name: test gather vultr dns domain info in check mode + vultr_dns_domain_info: + check_mode: yes + register: result + +- name: verify test gather vultr dns domain info in check mode + assert: + that: + - result.vultr_dns_domain_info|selectattr('domain','equalto','{{ dns_domain_name }}') | list | count == 1 + +- name: test gather vultr dns domain info + vultr_dns_domain_info: + register: result + +- name: verify test gather vultr dns domain info + assert: + that: + - result.vultr_dns_domain_info|selectattr('domain','equalto','{{ dns_domain_name }}') | list | count == 1 + +- name: Delete the record + vultr_dns_domain: + name: '{{ dns_domain_name }}' + server_ip: '{{ dns_domain_server_ip }}' + state: absent diff --git a/test/integration/targets/vultr_firewall_group_facts/tasks/main.yml b/test/integration/targets/vultr_firewall_group_facts/tasks/main.yml deleted file mode 100644 index 4d7f1ced0ae..00000000000 --- a/test/integration/targets/vultr_firewall_group_facts/tasks/main.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2018, Yanis Guenane -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather vultr firewall group facts - empty resources - vultr_firewall_group_facts: - -- name: Create the firewall group - vultr_firewall_group: - name: '{{ firewall_group_name }}' - -- name: test gather vultr firewall group facts in check mode - vultr_firewall_group_facts: - check_mode: yes - -- name: verify test gather vultr firewall group facts in check mode - assert: - that: - - ansible_facts.vultr_firewall_group_facts|selectattr('description','equalto','{{ firewall_group_name }}') | list | count == 1 - -- name: test gather vultr firewall group facts - vultr_firewall_group_facts: - -- name: verify test gather vultr firewall group facts - assert: - that: - - ansible_facts.vultr_firewall_group_facts|selectattr('description','equalto','{{ firewall_group_name }}') | list | count == 1 - -- name: Delete the firewall group - vultr_firewall_group: - name: '{{ firewall_group_name }}' - state: absent diff --git a/test/integration/targets/vultr_firewall_group_facts/aliases b/test/integration/targets/vultr_firewall_group_info/aliases similarity index 100% rename from test/integration/targets/vultr_firewall_group_facts/aliases rename to test/integration/targets/vultr_firewall_group_info/aliases diff --git a/test/integration/targets/vultr_firewall_group_facts/defaults/main.yml b/test/integration/targets/vultr_firewall_group_info/defaults/main.yml similarity index 100% rename from test/integration/targets/vultr_firewall_group_facts/defaults/main.yml rename to test/integration/targets/vultr_firewall_group_info/defaults/main.yml diff --git a/test/integration/targets/vultr_firewall_group_info/tasks/main.yml b/test/integration/targets/vultr_firewall_group_info/tasks/main.yml new file mode 100644 index 00000000000..e813afd9a37 --- /dev/null +++ b/test/integration/targets/vultr_firewall_group_info/tasks/main.yml @@ -0,0 +1,33 @@ +# Copyright (c) 2018, Yanis Guenane +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather vultr firewall group info - empty resources + vultr_firewall_group_info: + +- name: Create the firewall group + vultr_firewall_group: + name: '{{ firewall_group_name }}' + +- name: test gather vultr firewall group info in check mode + vultr_firewall_group_info: + check_mode: yes + register: result + +- name: verify test gather vultr firewall group info in check mode + assert: + that: + - result.vultr_firewall_group_info|selectattr('description','equalto','{{ firewall_group_name }}') | list | count == 1 + +- name: test gather vultr firewall group info + vultr_firewall_group_info: + register: result + +- name: verify test gather vultr firewall group info + assert: + that: + - result.vultr_firewall_group_info|selectattr('description','equalto','{{ firewall_group_name }}') | list | count == 1 + +- name: Delete the firewall group + vultr_firewall_group: + name: '{{ firewall_group_name }}' + state: absent diff --git a/test/integration/targets/vultr_network_facts/tasks/main.yml b/test/integration/targets/vultr_network_facts/tasks/main.yml deleted file mode 100644 index 3f05e751792..00000000000 --- a/test/integration/targets/vultr_network_facts/tasks/main.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) 2018, Yanis Guenane -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather vultr network facts - empty resources - vultr_network_facts: - -- name: Create the network - vultr_network: - name: '{{ vultr_network_name }}' - cidr: '{{ vultr_network_cidr }}' - region: '{{ vultr_network_region }}' - -- name: test gather vultr network facts in check mode - vultr_network_facts: - check_mode: yes - -- name: verify test gather vultr network facts in check mode - assert: - that: - - ansible_facts.vultr_network_facts|selectattr('name','equalto','{{ vultr_network_name }}') | list | count == 1 - -- name: test gather vultr network facts - vultr_network_facts: - -- name: verify test gather vultr network facts - assert: - that: - - ansible_facts.vultr_network_facts|selectattr('name','equalto','{{ vultr_network_name }}') | list | count == 1 - -- name: Delete the script - vultr_network: - name: '{{ vultr_network_name }}' - state: absent diff --git a/test/integration/targets/vultr_network_facts/aliases b/test/integration/targets/vultr_network_info/aliases similarity index 100% rename from test/integration/targets/vultr_network_facts/aliases rename to test/integration/targets/vultr_network_info/aliases diff --git a/test/integration/targets/vultr_network_facts/defaults/main.yml b/test/integration/targets/vultr_network_info/defaults/main.yml similarity index 100% rename from test/integration/targets/vultr_network_facts/defaults/main.yml rename to test/integration/targets/vultr_network_info/defaults/main.yml diff --git a/test/integration/targets/vultr_network_info/tasks/main.yml b/test/integration/targets/vultr_network_info/tasks/main.yml new file mode 100644 index 00000000000..90d45a08bce --- /dev/null +++ b/test/integration/targets/vultr_network_info/tasks/main.yml @@ -0,0 +1,35 @@ +# Copyright (c) 2018, Yanis Guenane +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather vultr network info - empty resources + vultr_network_info: + +- name: Create the network + vultr_network: + name: '{{ vultr_network_name }}' + cidr: '{{ vultr_network_cidr }}' + region: '{{ vultr_network_region }}' + +- name: test gather vultr network info in check mode + vultr_network_info: + check_mode: yes + register: result + +- name: verify test gather vultr network info in check mode + assert: + that: + - result.vultr_network_info|selectattr('name','equalto','{{ vultr_network_name }}') | list | count == 1 + +- name: test gather vultr network info + vultr_network_info: + register: result + +- name: verify test gather vultr network info + assert: + that: + - result.vultr_network_info|selectattr('name','equalto','{{ vultr_network_name }}') | list | count == 1 + +- name: Delete the script + vultr_network: + name: '{{ vultr_network_name }}' + state: absent diff --git a/test/integration/targets/vultr_plan_facts/tasks/main.yml b/test/integration/targets/vultr_plan_facts/tasks/main.yml deleted file mode 100644 index 519f3f883d8..00000000000 --- a/test/integration/targets/vultr_plan_facts/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2018, Yanis Guenane -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather vultr plan facts in check mode - vultr_plan_facts: - check_mode: yes - -- name: verify test gather vultr plan facts in check mode - assert: - that: - - ansible_facts.vultr_plan_facts|selectattr('name','equalto','16384 MB RAM,2x110 GB SSD,20.00 TB BW') | list | count == 1 - -- name: test gather vultr plan fact - vultr_plan_facts: - -- name: verify test gather vultr plan facts - assert: - that: - - ansible_facts.vultr_plan_facts|selectattr('name','equalto','16384 MB RAM,2x110 GB SSD,20.00 TB BW') | list | count == 1 diff --git a/test/integration/targets/vultr_plan_facts/aliases b/test/integration/targets/vultr_plan_info/aliases similarity index 100% rename from test/integration/targets/vultr_plan_facts/aliases rename to test/integration/targets/vultr_plan_info/aliases diff --git a/test/integration/targets/vultr_plan_info/tasks/main.yml b/test/integration/targets/vultr_plan_info/tasks/main.yml new file mode 100644 index 00000000000..6b3790325b1 --- /dev/null +++ b/test/integration/targets/vultr_plan_info/tasks/main.yml @@ -0,0 +1,21 @@ +# Copyright (c) 2018, Yanis Guenane +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather vultr plan info in check mode + vultr_plan_info: + check_mode: yes + register: result + +- name: verify test gather vultr plan info in check mode + assert: + that: + - result.vultr_plan_info|selectattr('name','equalto','16384 MB RAM,2x110 GB SSD,20.00 TB BW') | list | count == 1 + +- name: test gather vultr plan info + vultr_plan_info: + register: result + +- name: verify test gather vultr plan info + assert: + that: + - result.vultr_plan_info|selectattr('name','equalto','16384 MB RAM,2x110 GB SSD,20.00 TB BW') | list | count == 1 diff --git a/test/integration/targets/vultr_region_facts/tasks/main.yml b/test/integration/targets/vultr_region_facts/tasks/main.yml deleted file mode 100644 index df6490c820a..00000000000 --- a/test/integration/targets/vultr_region_facts/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2018, Yanis Guenane -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather vultr region facts in check mode - vultr_region_facts: - check_mode: yes - -- name: verify test gather vultr region facts in check mode - assert: - that: - - ansible_facts.vultr_region_facts|selectattr('name','equalto','Atlanta') | list | count == 1 - -- name: test gather vultr region facts - vultr_region_facts: - -- name: verify test gather vultr region facts - assert: - that: - - ansible_facts.vultr_region_facts|selectattr('name','equalto','Atlanta') | list | count == 1 diff --git a/test/integration/targets/vultr_region_facts/aliases b/test/integration/targets/vultr_region_info/aliases similarity index 100% rename from test/integration/targets/vultr_region_facts/aliases rename to test/integration/targets/vultr_region_info/aliases diff --git a/test/integration/targets/vultr_region_info/tasks/main.yml b/test/integration/targets/vultr_region_info/tasks/main.yml new file mode 100644 index 00000000000..adf8a8a46ba --- /dev/null +++ b/test/integration/targets/vultr_region_info/tasks/main.yml @@ -0,0 +1,21 @@ +# Copyright (c) 2018, Yanis Guenane +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather vultr region info in check mode + vultr_region_info: + check_mode: yes + register: result + +- name: verify test gather vultr region info in check mode + assert: + that: + - result.vultr_region_info|selectattr('name','equalto','Atlanta') | list | count == 1 + +- name: test gather vultr region info + vultr_region_info: + register: result + +- name: verify test gather vultr region info + assert: + that: + - result.vultr_region_info|selectattr('name','equalto','Atlanta') | list | count == 1 diff --git a/test/integration/targets/vultr_server_facts/aliases b/test/integration/targets/vultr_server_info/aliases similarity index 100% rename from test/integration/targets/vultr_server_facts/aliases rename to test/integration/targets/vultr_server_info/aliases diff --git a/test/integration/targets/vultr_server_facts/defaults/main.yml b/test/integration/targets/vultr_server_info/defaults/main.yml similarity index 100% rename from test/integration/targets/vultr_server_facts/defaults/main.yml rename to test/integration/targets/vultr_server_info/defaults/main.yml diff --git a/test/integration/targets/vultr_server_facts/tasks/main.yml b/test/integration/targets/vultr_server_info/tasks/main.yml similarity index 54% rename from test/integration/targets/vultr_server_facts/tasks/main.yml rename to test/integration/targets/vultr_server_info/tasks/main.yml index c2cf1995154..83deb76911c 100644 --- a/test/integration/targets/vultr_server_facts/tasks/main.yml +++ b/test/integration/targets/vultr_server_info/tasks/main.yml @@ -12,16 +12,17 @@ wait_for: when: result is changed -- name: test gather vultr server facts - empty resources - vultr_server_facts: -- name: verify test gather vultr server facts - empty resources +- name: test gather vultr server info - empty resources + vultr_server_info: + register: result +- name: verify test gather vultr server info - empty resources assert: that: - - ansible_facts.vultr_server_facts | selectattr('name','equalto',vultr_server_name) | list | count == 0 + - result.vultr_server_info | selectattr('name','equalto',vultr_server_name) | list | count == 0 - name: setup firewall group vultr_firewall_group: - name: test_vultr_server_facts + name: test_vultr_server_info - name: setup create the server vultr_server: @@ -29,24 +30,26 @@ os: '{{ vultr_server_os }}' plan: '{{ vultr_server_plan }}' region: '{{ vultr_server_region }}' - firewall_group: test_vultr_server_facts + firewall_group: test_vultr_server_info -- name: test gather vultr server facts in check mode - vultr_server_facts: +- name: test gather vultr server info in check mode + vultr_server_info: check_mode: yes + register: result -- name: verify test gather vultr server facts in check mode +- name: verify test gather vultr server info in check mode assert: that: - - ansible_facts.vultr_server_facts|selectattr('name','equalto',vultr_server_name) | list | count == 1 + - result.vultr_server_info|selectattr('name','equalto',vultr_server_name) | list | count == 1 -- name: test gather vultr server facts - vultr_server_facts: +- name: test gather vultr server info + vultr_server_info: + register: result -- name: verify test gather vultr server facts +- name: verify test gather vultr server info assert: that: - - ansible_facts.vultr_server_facts|selectattr('name','equalto',vultr_server_name) | list | count == 1 + - result.vultr_server_info|selectattr('name','equalto',vultr_server_name) | list | count == 1 - name: Pause for 5 min before deleting the VM pause: @@ -59,5 +62,5 @@ - name: cleanup firewall group vultr_firewall_group: - name: test_vultr_server_facts + name: test_vultr_server_info state: absent diff --git a/test/integration/targets/vultr_startup_script_facts/tasks/main.yml b/test/integration/targets/vultr_startup_script_facts/tasks/main.yml deleted file mode 100644 index 1db43bc831e..00000000000 --- a/test/integration/targets/vultr_startup_script_facts/tasks/main.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) 2018, Yanis Guenane -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: test gather vultr startup script facts - empty resources - vultr_startup_script_facts: - -- name: Create the script - vultr_startup_script: - name: '{{ startup_script_name }}' - script_type: '{{ startup_script_type }}' - script: '{{ startup_script_content }}' - -- name: test gather vultr startup script facts in check mode - vultr_startup_script_facts: - check_mode: yes - -- name: verify test gather vultr startup script facts in check mode - assert: - that: - - ansible_facts.vultr_startup_script_facts|selectattr('name','equalto','{{ startup_script_name }}') | list | count == 1 - -- name: test gather vultr startup script facts - vultr_startup_script_facts: - -- name: verify test gather vultr startup script facts - assert: - that: - - ansible_facts.vultr_startup_script_facts|selectattr('name','equalto','{{ startup_script_name }}') | list | count == 1 - -- name: Delete the script - vultr_startup_script: - name: '{{ startup_script_name }}' - state: absent diff --git a/test/integration/targets/vultr_startup_script_facts/aliases b/test/integration/targets/vultr_startup_script_info/aliases similarity index 100% rename from test/integration/targets/vultr_startup_script_facts/aliases rename to test/integration/targets/vultr_startup_script_info/aliases diff --git a/test/integration/targets/vultr_startup_script_facts/defaults/main.yml b/test/integration/targets/vultr_startup_script_info/defaults/main.yml similarity index 100% rename from test/integration/targets/vultr_startup_script_facts/defaults/main.yml rename to test/integration/targets/vultr_startup_script_info/defaults/main.yml diff --git a/test/integration/targets/vultr_startup_script_info/tasks/main.yml b/test/integration/targets/vultr_startup_script_info/tasks/main.yml new file mode 100644 index 00000000000..158824383bf --- /dev/null +++ b/test/integration/targets/vultr_startup_script_info/tasks/main.yml @@ -0,0 +1,35 @@ +# Copyright (c) 2018, Yanis Guenane +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather vultr startup script info - empty resources + vultr_startup_script_info: + +- name: Create the script + vultr_startup_script: + name: '{{ startup_script_name }}' + script_type: '{{ startup_script_type }}' + script: '{{ startup_script_content }}' + +- name: test gather vultr startup script info in check mode + vultr_startup_script_info: + check_mode: yes + register: result + +- name: verify test gather vultr startup script info in check mode + assert: + that: + - result.vultr_startup_script_info|selectattr('name','equalto','{{ startup_script_name }}') | list | count == 1 + +- name: test gather vultr startup script info + vultr_startup_script_info: + register: result + +- name: verify test gather vultr startup script info + assert: + that: + - result.vultr_startup_script_info|selectattr('name','equalto','{{ startup_script_name }}') | list | count == 1 + +- name: Delete the script + vultr_startup_script: + name: '{{ startup_script_name }}' + state: absent