diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
commit | a453ac31f3428614cceb99027f8efbdb9258a40b (patch) | |
tree | f61f87408f32a8511cbd91799f9cececb53e0374 /collections-debian-merged/ansible_collections/ngine_io/vultr/tests | |
parent | Initial commit. (diff) | |
download | ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.tar.xz ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.zip |
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collections-debian-merged/ansible_collections/ngine_io/vultr/tests')
73 files changed, 3473 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_account_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_account_info/aliases new file mode 100644 index 00000000..1e955564 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_account_info/aliases @@ -0,0 +1,2 @@ +cloud/vultr +smoke/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_account_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_account_info/tasks/main.yml new file mode 100644 index 00000000..1dfa8c44 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_account_info/tasks/main.yml @@ -0,0 +1,27 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test get vultr account infos in check mode + vultr_account_info: + check_mode: yes + register: result + +- name: verify test get vultr account infos in check mode + assert: + that: + - result.vultr_account_info.balance is defined + - result.vultr_account_info.last_payment_amount is defined + - result.vultr_account_info.last_payment_date is defined + - result.vultr_account_info.last_payment_amount is defined + +- name: test get vultr account fact + vultr_account_info: + register: result + +- name: verify test get vultr account infos + assert: + that: + - result.vultr_account_info.balance is defined + - result.vultr_account_info.last_payment_amount is defined + - result.vultr_account_info.last_payment_date is defined + - result.vultr_account_info.last_payment_amount is defined diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage/defaults/main.yml new file mode 100644 index 00000000..b2c0ebe3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage/defaults/main.yml @@ -0,0 +1,14 @@ +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_block_storage_name: "{{ vultr_resource_prefix }}-volume" +vultr_block_storage_size: 10 +vultr_block_storage_size_2: 12 +vultr_block_storage_size_3: 14 +vultr_block_storage_region: New Jersey + +vultr_server_name: "{{ vultr_resource_prefix }}_vm_for_attachment" +vultr_server_ssh_keys: +- name: key1 + key: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEAyWYItY+3w5b8PdGRoz0oY5mufqydW96naE+VM3JSvJFAUS08rAjQQpQ03ymoALeHQy6JVZbcgecxn6p0pAOINQdqufn4udPtOPCtMjNiPGpkSM9ah/6X5+kvyWMNrvlf+Ld4OOoszP5sAkgQzIbrFQAm41XknBUha0zkewZwfrVhain4pnDjV7wCcChId/Q/Gbi4xMtXkisznWcAJcueBs3EEZDKhJ5q0VeWSJEhYJDLFN1sOxF0AIUnMrOhfKQ/LjgREXPB6uCl899INUTXRNNjRpeMXyJ2wMMmOAbua2qEd1r13Bu1n+6A823Hzb33fyMXuqWnJwBJ4DCvMlGuEsfuOK+xk7DaBfLHbcM6fsPk0/4psTE6YLgC41remr6+u5ZWsY/faMtSnNPie8Z8Ov0DIYGdhbJjUXk1HomxRV9+ZfZ2Ob8iCwlaAQAyEUM6fs3Kxt8pBD8dx1HOkhsfBWPvuDr5y+kqE7H8/MuPDTc0QgH2pjUMpmw/XBwNDHshVEjrZvtICOjOLUJxcowLO1ivNYwPwowQxfisMy56LfYdjsOslBiqsrkAqvNGm1zu8wKHeqVN9w5l3yUELpvubfm9NKIvYcl6yWF36T0c5vE+g0DU/Jy4XpTj0hZG9QV2mRQcLJnd2pxQtJT7cPFtrn/+tgRxzjEtbDXummDV4sE= mail@renemoser.net" + +vultr_server_plan_1: 1024 MB RAM,25 GB SSD,1.00 TB BW diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage/tasks/main.yml new file mode 100644 index 00000000..3b802ace --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage/tasks/main.yml @@ -0,0 +1,315 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +- name: setup create ssh keys + vultr_ssh_key: + name: "{{ item.name }}" + ssh_key: "{{ item.key }}" + loop: "{{ vultr_server_ssh_keys }}" + +- name: Setup create server for attachment + # We'll use this server to test block storage attachment, later + # in this test suite. + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 8 x64 + plan: "{{ vultr_server_plan_1 }}" + ssh_keys: + - key1 + region: "{{ vultr_block_storage_region }}" + state: started + register: result_server_setup +- name: verify setup create server + assert: + that: + - result_server_setup is changed + +- name: test fail if missing name + vultr_block_storage: + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: name"' + +- name: test fail if missing params for state=present + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + register: result + ignore_errors: yes +- name: verify fail if missing params for state=present + assert: + that: + - result is failed + - 'result.msg == "state is present but all of the following are missing: size, region"' + +- name: test create block storage volume in check mode + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + register: result + check_mode: yes +- name: verify test create server in check mode + assert: + that: + - result is changed + +- name: test create block storage volume + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + register: result +- name: verify test create block storage volume + assert: + that: + - result is changed + - result.vultr_block_storage.name == "{{ vultr_block_storage_name }}" + - result.vultr_block_storage.region == "{{ vultr_block_storage_region }}" + - result.vultr_block_storage.size == 10 + +- name: test create block storage volume idempotence + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + register: result +- name: verify test block storage volume idempotence + assert: + that: + - result is not changed + - result.vultr_block_storage.name == "{{ vultr_block_storage_name }}" + - result.vultr_block_storage.region == "{{ vultr_block_storage_region }}" + - result.vultr_block_storage.size == 10 + +# volumes size can only be modified every 60s +- name: wait about 60s before resizing volume + wait_for: + timeout: 65 + +- name: test resize block storage volume + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size_2 }}" + region: "{{ vultr_block_storage_region }}" + register: result +- name: verify resize block storage volume + assert: + that: + - result is changed + - 'result.vultr_block_storage.size == {{ vultr_block_storage_size_2 | int }}' + +# volume size can only be modified every 60s +- name: wait about 60s before resizing volume + wait_for: + timeout: 65 + +- name: test resize block storage volume idempotency + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size_2 }}" + region: "{{ vultr_block_storage_region }}" + register: result +- name: verify resize block storage volume idempotency + assert: + that: + - not result.changed + - 'result.vultr_block_storage.size == {{ vultr_block_storage_size_2 | int }}' + +- name: test attaching fails if server id not provided + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + state: attached + register: result + ignore_errors: yes +- name: verify attaching fails if server id not provided + assert: + that: + - result is failed + - 'result.msg == "state is attached but all of the following are missing: attached_to_SUBID"' + +- name: test attach block volume in check mode + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + state: attached + attached_to_id: 1337 # dummy server id + register: result + check_mode: yes +- name: verify attach block volume in check mode + assert: + that: + - result is changed + - result.vultr_block_storage.attached_to_id == 1337 + +- name: test attach block volume + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + state: attached + attached_to_SUBID: "{{ result_server_setup.vultr_server.id | int}}" + register: result +- name: verify attach block volume + assert: + that: + - result.changed + - 'result.vultr_block_storage.attached_to_id == {{ result_server_setup.vultr_server.id | int }}' + +- name: test attach block volume idempotency + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + state: attached + attached_to_SUBID: "{{ result_server_setup.vultr_server.id | int }}" + register: result +- name: verify attach block volume idempotency + assert: + that: + - not result.changed + - 'result.vultr_block_storage.attached_to_id == {{ result_server_setup.vultr_server.id | int }}' + +# volume size can only be modified every 60s +- name: wait about 60s before resizing volume + wait_for: + timeout: 65 + +- name: test resize block storage volume while attaching + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size_3 }}" + region: "{{ vultr_block_storage_region }}" + state: attached + attached_to_SUBID: "{{ result_server_setup.vultr_server.id | int }}" + register: result +- name: verify resize block storage volume + assert: + that: + - result is changed + - 'result.vultr_block_storage.size == {{ vultr_block_storage_size_3 | int }}' + +- name: test attach block volume fails if attached somewhere else + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + state: attached + attached_to_SUBID: 1337 # some other server + register: result + ignore_errors: true +- name: verify attach block volume fails if attached somewhere else + assert: + that: + - result is failed + - 'result.msg == "Volume already attached to server {{ result_server_setup.vultr_server.id | int }}"' + +- name: test detach block volume in check mode + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + state: detached + register: result + check_mode: yes +- name: verify detach block volume + assert: + that: + - result is changed + - not result.vultr_block_storage.attached_to_id + +- name: test detach block volume + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + state: detached + register: result +- name: verify detach block volume + assert: + that: + - result is changed + - not result.vultr_block_storage.attached_to_id + +- name: test detach block volume idempotency + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + size: "{{ vultr_block_storage_size }}" + region: "{{ vultr_block_storage_region }}" + state: detached + register: result +- name: verify detach block volume idempotency + assert: + that: + - result is not changed + - not result.vultr_block_storage.attached_to_id + +- name: test destroy block storage volume in check mode + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + state: absent + register: result + check_mode: yes +- name: verify test destroy block storage volume in check mode + assert: + that: + - result is changed + - result.vultr_block_storage.name == "{{ vultr_block_storage_name }}" + +- name: test destroy block storage volume + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + state: absent + register: result +- name: verify test destroy an existing block storage volume + assert: + that: + - result is changed + - result.vultr_block_storage.name == "{{ vultr_block_storage_name }}" + +- name: test destroy an existing block storage volume idempotence + vultr_block_storage: + name: "{{ vultr_block_storage_name }}" + state: absent + register: result +- name: verify test destroy an existing block storage volume idempotence + assert: + that: + - result is not changed + +# Servers can only be destroyed 5 min after creation +- name: wait for 5 min before destroying server + wait_for: + +- name: cleanup server + vultr_server: + name: "{{ vultr_server_name }}" + state: absent + register: result +- name: verify test absent server + assert: + that: + - result is changed + +- name: cleanup ssh keys + vultr_ssh_key: + name: "{{ item.name }}" + ssh_key: "{{ item.key }}" + state: absent + loop: "{{ vultr_server_ssh_keys }}" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage_info/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage_info/defaults/main.yml new file mode 100644 index 00000000..17be33cb --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage_info/defaults/main.yml @@ -0,0 +1,5 @@ +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_block_storage_name: "{{ vultr_resource_prefix }}-volume" +vultr_block_storage_size: 10 +vultr_block_storage_region: New Jersey diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage_info/tasks/main.yml new file mode 100644 index 00000000..1777c25e --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_block_storage_info/tasks/main.yml @@ -0,0 +1,35 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather vultr block storage volume info - empty resource + vultr_block_storage_info: + +- name: Create the block storage volume + vultr_block_storage: + name: '{{ vultr_block_storage_name }}' + size: '{{ vultr_block_storage_size }}' + region: '{{ vultr_block_storage_region }}' + +- name: test gather vultr block storage volume info in check mode + vultr_block_storage_info: + check_mode: yes + register: result + +- name: verify test gather vultr block storage volume info in check mode + assert: + that: + - result.vultr_block_storage_info|selectattr('name','equalto','{{ vultr_block_storage_name }}') | list | count == 1 + +- name: test gather vultr block storage volume info + vultr_block_storage_info: + register: result + +- name: verify test gather vultr block storage volume info + assert: + that: + - result.vultr_block_storage_info|selectattr('name','equalto','{{ vultr_block_storage_name }}') | list | count == 1 + +- name: Delete the block storage volume + vultr_block_storage: + name: '{{ vultr_block_storage_name }}' + state: absent diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain/defaults/main.yml new file mode 100644 index 00000000..45cbf728 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_dns_domain_name: "{{ vultr_resource_prefix }}-example-ansible.com" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain/tasks/main.yml new file mode 100644 index 00000000..70678397 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain/tasks/main.yml @@ -0,0 +1,99 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup + vultr_dns_domain: + name: "{{ vultr_dns_domain_name }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +- name: test fail if missing name + vultr_dns_domain: + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: name"' + +- name: test fail if missing params for state=present + vultr_dns_domain: + name: "{{ vultr_dns_domain_name }}" + register: result + ignore_errors: yes +- name: verify fail if missing params for state=present + assert: + that: + - result is failed + - 'result.msg == "state is present but all of the following are missing: server_ip"' + +- name: test create dns domain in check mode + vultr_dns_domain: + name: "{{ vultr_dns_domain_name }}" + server_ip: 10.10.10.10 + register: result + check_mode: yes +- name: verify test create dns domain in check mode + assert: + that: + - result is changed + +- name: test create dns domain + vultr_dns_domain: + name: "{{ vultr_dns_domain_name }}" + server_ip: 10.10.10.10 + register: result +- name: verify test create dns domain + assert: + that: + - result is changed + - result.vultr_dns_domain.name == '{{ vultr_dns_domain_name }}' + +- name: test create dns domain idempotence + vultr_dns_domain: + name: "{{ vultr_dns_domain_name }}" + server_ip: 10.10.10.10 + register: result +- name: verify test create dns domain idempotence + assert: + that: + - result is not changed + - result.vultr_dns_domain.name == '{{ vultr_dns_domain_name }}' + +- name: test absent dns domain in check mode + vultr_dns_domain: + name: "{{ vultr_dns_domain_name }}" + state: absent + register: result + check_mode: yes +- name: verify test absent dns domain in check mode + assert: + that: + - result is changed + - result.vultr_dns_domain.name == '{{ vultr_dns_domain_name }}' + +- name: test absent dns domain + vultr_dns_domain: + name: "{{ vultr_dns_domain_name }}" + state: absent + register: result +- name: verify test absent dns domain + assert: + that: + - result is changed + - result.vultr_dns_domain.name == '{{ vultr_dns_domain_name }}' + +- name: test absent dns domain idempotence + vultr_dns_domain: + name: "{{ vultr_dns_domain_name }}" + state: absent + register: result +- name: verify test absent dns domain idempotence + assert: + that: + - result is not changed diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain_info/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain_info/defaults/main.yml new file mode 100644 index 00000000..a452ee12 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain_info/defaults/main.yml @@ -0,0 +1,4 @@ +--- +vultr_resource_prefix: "vultr-test-prefix" +dns_domain_name: "{{ vultr_resource_prefix }}-example-ansible.com" +dns_domain_server_ip: 104.24.16.59 diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain_info/tasks/main.yml new file mode 100644 index 00000000..d58aa108 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_domain_info/tasks/main.yml @@ -0,0 +1,32 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# 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/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/defaults/main.yml new file mode 100644 index 00000000..fb52cfd9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/defaults/main.yml @@ -0,0 +1,39 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_dns_domain_name: "{{ vultr_resource_prefix }}-example-ansible.com" +vultr_dns_record_items: +# Single A record +- name: test-www + data: 10.10.10.10 + ttl: 400 + update_data: 10.10.10.11 + update_ttl: 200 + +# Multiple A records +- name: test-www-multiple + data: 10.10.11.10 + update_data: 10.10.11.11 + multiple: true + update_ttl: 600 + +# CNAME +- name: test-cname + data: www.ansible.com + update_data: www.ansible.ch + record_type: CNAME + +# Single Multiple MX record +- data: mx1.example-ansible.com + priority: 10 + update_priority: 20 + record_type: MX + +# Multiple MX records +- data: mx2.example-ansible.com + priority: 10 + update_data: mx1.example-ansible.com + update_priority: 20 + record_type: MX + multiple: true diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/create_record.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/create_record.yml new file mode 100644 index 00000000..5f33eb14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/create_record.yml @@ -0,0 +1,67 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test setup dns record + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + record_type: "{{ item.record_type | default(omit) }}" + state: absent + register: result +- name: verify test setup dns record + assert: + that: + - result is successful + +- name: test create a dns record in check mode + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.data }}" + ttl: "{{ item.ttl | default(omit) }}" + record_type: "{{ item.record_type | default(omit) }}" + priority: "{{ item.priority | default(omit) }}" + check_mode: yes + register: result +- name: verify test create a dns record in check mode + assert: + that: + - result is changed + +- name: test create a dns record + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.data }}" + ttl: "{{ item.ttl | default(omit) }}" + record_type: "{{ item.record_type | default(omit) }}" + priority: "{{ item.priority | default(omit) }}" + register: result +- name: verify test create a dns record + assert: + that: + - result is changed + - result.vultr_dns_record.data == "{{ item.data }}" + - result.vultr_dns_record.name == "{{ item.name | default("") }}" + - result.vultr_dns_record.record_type == "{{ item.record_type | default('A') }}" + - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} + - result.vultr_dns_record.priority == {{ item.priority | default(0) }} + +- name: test create a dns record idempotence + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.data }}" + ttl: "{{ item.ttl | default(omit) }}" + record_type: "{{ item.record_type | default(omit) }}" + priority: "{{ item.priority | default(omit) }}" + register: result +- name: verify test create a dns record idempotence + assert: + that: + - result is not changed + - result.vultr_dns_record.data == "{{ item.data }}" + - result.vultr_dns_record.name == "{{ item.name | default("") }}" + - result.vultr_dns_record.record_type == "{{ item.record_type | default('A') }}" + - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} + - result.vultr_dns_record.priority == {{ item.priority | default(0) }} diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/main.yml new file mode 100644 index 00000000..19419efc --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/main.yml @@ -0,0 +1,17 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup dns domain + vultr_dns_domain: + name: "{{ vultr_dns_domain_name }}" + server_ip: 10.10.10.10 + register: result +- name: verify setup dns domain + assert: + that: + - result is successful + +- include_tasks: test_fail_multiple.yml + +- include_tasks: record.yml + with_items: "{{ vultr_dns_record_items }}" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/record.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/record.yml new file mode 100644 index 00000000..c8c3926d --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/record.yml @@ -0,0 +1,6 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- include_tasks: create_record.yml +- include_tasks: update_record.yml +- include_tasks: remove_record.yml diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/remove_record.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/remove_record.yml new file mode 100644 index 00000000..e776a492 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/remove_record.yml @@ -0,0 +1,114 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test remove a dns record in check mode + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.update_data | default(item.data) }}" + record_type: "{{ item.record_type | default(omit) }}" + multiple: "{{ item.multiple | default(omit) }}" + state: absent + check_mode: yes + register: result +- name: verify test remove a dns record in check mode + assert: + that: + - result is changed + - result.vultr_dns_record.data == "{{ item.update_data | default(item.data) }}" + - result.vultr_dns_record.name == "{{ item.name | default("") }}" + - result.vultr_dns_record.record_type == "{{ item.record_type | default('A') }}" + - result.vultr_dns_record.ttl == {{ item.update_ttl | default(300) }} + - result.vultr_dns_record.priority == {{ item.update_priority | default(item.priority | default(0)) }} + +- name: test remove second dns record in check mode + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.data | default(item.data) }}" + record_type: "{{ item.record_type | default(omit) }}" + multiple: "{{ item.multiple | default(omit) }}" + state: absent + check_mode: yes + register: result + when: item.multiple is defined and item.multiple == true +- name: verify test remove a dns record in check mode + assert: + that: + - result is changed + - result.vultr_dns_record.data == "{{ item.data | default(item.data) }}" + - result.vultr_dns_record.name == "{{ item.name | default("") }}" + - result.vultr_dns_record.record_type == "{{ item.record_type | default('A') }}" + - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} + - result.vultr_dns_record.priority == {{ item.priority | default(0) }} + when: item.multiple is defined and item.multiple == true + +- name: test remove a dns record + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.update_data | default(item.data) }}" + record_type: "{{ item.record_type | default(omit) }}" + multiple: "{{ item.multiple | default(omit) }}" + state: absent + register: result +- name: verify test remove a dns record + assert: + that: + - result is changed + - result.vultr_dns_record.data == "{{ item.update_data | default(item.data) }}" + - result.vultr_dns_record.name == "{{ item.name | default("") }}" + - result.vultr_dns_record.record_type == "{{ item.record_type | default('A') }}" + - result.vultr_dns_record.ttl == {{ item.update_ttl | default(300) }} + - result.vultr_dns_record.priority == {{ item.update_priority | default(item.priority | default(0)) }} + +- name: test remove second dns record + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.data }}" + record_type: "{{ item.record_type | default(omit) }}" + multiple: "{{ item.multiple | default(omit) }}" + state: absent + register: result + when: item.multiple is defined and item.multiple == true +- name: verify test remove a dns record + assert: + that: + - result is changed + - result.vultr_dns_record.data == "{{ item.data }}" + - result.vultr_dns_record.name == "{{ item.name | default("") }}" + - result.vultr_dns_record.record_type == "{{ item.record_type | default('A') }}" + - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} + - result.vultr_dns_record.priority == {{ item.priority | default(0) }} + when: item.multiple is defined and item.multiple == true + +- name: test remove a dns record idempotence + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.update_data | default(item.data) }}" + record_type: "{{ item.record_type | default(omit) }}" + multiple: "{{ item.multiple | default(omit) }}" + state: absent + register: result +- name: verify test remove a dns record idempotence + assert: + that: + - result is not changed + +- name: test remove second dns record idempotence + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.data }}" + record_type: "{{ item.record_type | default(omit) }}" + multiple: "{{ item.multiple | default(omit) }}" + state: absent + register: result + when: item.multiple is defined and item.multiple == true +- name: verify test remove a dns record idempotence + assert: + that: + - result is not changed + when: item.multiple is defined and item.multiple == true diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/test_fail_multiple.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/test_fail_multiple.yml new file mode 100644 index 00000000..a41d9db5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/test_fail_multiple.yml @@ -0,0 +1,78 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup first dns record + vultr_dns_record: + name: test-multiple + domain: "{{ vultr_dns_domain_name }}" + data: 1.2.3.4 + multiple: yes + register: result +- name: verify setup a dns record + assert: + that: + - result is successful + +- name: setup second dns record + vultr_dns_record: + name: test-multiple + domain: "{{ vultr_dns_domain_name }}" + data: 1.2.3.5 + multiple: yes + register: result +- name: verify setup second dns record + assert: + that: + - result is successful + +- name: test-multiple fail multiple identical records found + vultr_dns_record: + name: test-multiple + domain: "{{ vultr_dns_domain_name }}" + state: absent + register: result + ignore_errors: yes +- name: verify test fail multiple identical records found + assert: + that: + - result is failed + +- name: test-multiple fail absent multiple identical records but not data + vultr_dns_record: + name: test-multiple + domain: "{{ vultr_dns_domain_name }}" + state: absent + multiple: yes + register: result + ignore_errors: yes +- name: verify test-multiple success absent multiple identical records found + assert: + that: + - result is failed + - "result.msg == 'multiple is True but all of the following are missing: data'" + +- name: test-multiple success absent multiple identical records second found + vultr_dns_record: + name: test-multiple + domain: "{{ vultr_dns_domain_name }}" + data: 1.2.3.5 + state: absent + multiple: yes + register: result +- name: verify test-multiple success absent multiple identical records second found + assert: + that: + - result is changed + +- name: test-multiple success absent multiple identical records first found + vultr_dns_record: + name: test-multiple + domain: "{{ vultr_dns_domain_name }}" + data: 1.2.3.4 + state: absent + multiple: yes + register: result +- name: verify test-multiple success absent multiple identical records firstfound + assert: + that: + - result is changed diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/update_record.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/update_record.yml new file mode 100644 index 00000000..204ebda4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_dns_record/tasks/update_record.yml @@ -0,0 +1,70 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test update or add another dns record in check mode + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.update_data | default(item.data) }}" + ttl: "{{ item.update_ttl | default(omit) }}" + record_type: "{{ item.record_type | default(omit) }}" + priority: "{{ item.update_priority | default(omit) }}" + multiple: "{{ item.multiple | default(omit) }}" + check_mode: yes + register: result +- name: verify test updatein check mode + assert: + that: + - result is changed + - result.vultr_dns_record.data == "{{ item.data }}" + - result.vultr_dns_record.name == "{{ item.name | default("") }}" + - result.vultr_dns_record.record_type == "{{ item.record_type | default('A') }}" + - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} + - result.vultr_dns_record.priority == {{ item.priority | default(0) }} + when: item.multiple is undefined or item.multiple == false +- name: verify test add another dns record in check mode + assert: + that: + - result is changed + - not result.vultr_dns_record + when: item.multiple is defined and item.multiple == true + +- name: test update or add another dns record + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.update_data | default(item.data) }}" + ttl: "{{ item.update_ttl | default(omit) }}" + record_type: "{{ item.record_type | default(omit) }}" + priority: "{{ item.update_priority | default(omit) }}" + multiple: "{{ item.multiple | default(omit) }}" + register: result +- name: verify test update a dns record + assert: + that: + - result is changed + - result.vultr_dns_record.data == "{{ item.update_data | default(item.data) }}" + - result.vultr_dns_record.name == "{{ item.name | default("") }}" + - result.vultr_dns_record.ttl == {{ item.update_ttl | default(300) }} + - result.vultr_dns_record.record_type == "{{ item.record_type | default('A') }}" + - result.vultr_dns_record.priority == {{ item.update_priority | default(0) }} + +- name: test update or add another dns record idempotence + vultr_dns_record: + name: "{{ item.name | default(omit) }}" + domain: "{{ vultr_dns_domain_name }}" + data: "{{ item.update_data | default(item.data) }}" + ttl: "{{ item.update_ttl | default(omit) }}" + record_type: "{{ item.record_type | default(omit) }}" + priority: "{{ item.update_priority | default(omit) }}" + multiple: "{{ item.multiple | default(omit) }}" + register: result +- name: verify test update a dns record idempotence + assert: + that: + - result is not changed + - result.vultr_dns_record.data == "{{ item.update_data | default(item.data) }}" + - result.vultr_dns_record.name == "{{ item.name | default("") }}" + - result.vultr_dns_record.ttl == {{ item.update_ttl | default(300) }} + - result.vultr_dns_record.record_type == "{{ item.record_type | default('A') }}" + - result.vultr_dns_record.priority == {{ item.update_priority | default(0) }} diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group/defaults/main.yml new file mode 100644 index 00000000..7057b466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_firewall_group_name: "{{ vultr_resource_prefix }}_firewall-group" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group/tasks/main.yml new file mode 100644 index 00000000..577457c2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group/tasks/main.yml @@ -0,0 +1,86 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup + vultr_firewall_group: + name: "{{ vultr_firewall_group_name }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +- name: test fail if missing name + vultr_firewall_group: + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: name"' + +- name: test create firewall group in check mode + vultr_firewall_group: + name: "{{ vultr_firewall_group_name }}" + register: result + check_mode: yes +- name: verify test create firewall group in check mode + assert: + that: + - result is changed + +- name: test create firewall group + vultr_firewall_group: + name: "{{ vultr_firewall_group_name }}" + register: result +- name: verify test create firewall group + assert: + that: + - result is changed + - result.vultr_firewall_group.name == '{{ vultr_firewall_group_name }}' + +- name: test create firewall group idempotence + vultr_firewall_group: + name: "{{ vultr_firewall_group_name }}" + + register: result +- name: verify test create firewall group idempotence + assert: + that: + - result is not changed + - result.vultr_firewall_group.name == '{{ vultr_firewall_group_name }}' + +- name: test absent firewall group in check mode + vultr_firewall_group: + name: "{{ vultr_firewall_group_name }}" + state: absent + register: result + check_mode: yes +- name: verify test absent firewall group in check mode + assert: + that: + - result is changed + - result.vultr_firewall_group.name == '{{ vultr_firewall_group_name }}' + +- name: test absent firewall group + vultr_firewall_group: + name: "{{ vultr_firewall_group_name }}" + state: absent + register: result +- name: verify test absent firewall group + assert: + that: + - result is changed + - result.vultr_firewall_group.name == '{{ vultr_firewall_group_name }}' + +- name: test absent firewall group idempotence + vultr_firewall_group: + name: "{{ vultr_firewall_group_name }}" + state: absent + register: result +- name: verify test absent firewall group idempotence + assert: + that: + - result is not changed diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group_info/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group_info/defaults/main.yml new file mode 100644 index 00000000..e545fe42 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group_info/defaults/main.yml @@ -0,0 +1,3 @@ +--- +vultr_resource_prefix: "vultr-test-prefix" +firewall_group_name: "{{ vultr_resource_prefix }}_firewall-group" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group_info/tasks/main.yml new file mode 100644 index 00000000..e813afd9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_group_info/tasks/main.yml @@ -0,0 +1,33 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# 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/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_rule/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_rule/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_rule/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_rule/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_rule/defaults/main.yml new file mode 100644 index 00000000..7057b466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_rule/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_firewall_group_name: "{{ vultr_resource_prefix }}_firewall-group" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_rule/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_rule/tasks/main.yml new file mode 100644 index 00000000..44097434 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_firewall_rule/tasks/main.yml @@ -0,0 +1,475 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup firewall group + vultr_firewall_group: + name: "{{ vultr_firewall_group_name }}" + register: result +- name: verify setup firewall group + assert: + that: + - result is success + +- name: setup firewall rule tcp + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + state: absent + register: result +- name: verify setup firewal rule + assert: + that: + - result is success + +- name: setup firewall rule udp + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + state: absent + register: result +- name: verify setup firewal rule udp + assert: + that: + - result is success + +- name: setup firewall rule udp v6 + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + ip_version: v6 + state: absent + register: result +- name: verify setup firewal rule udp v6 + assert: + that: + - result is success + +- name: setup firewall rule port range + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + start_port: 8000 + end_port: 8080 + protocol: tcp + cidr: 10.100.12.0/24 + state: absent + register: result + tags: tmp +- name: verify setup firewal rule port range + assert: + that: + - result is success + +- name: setup firewall rule icmp + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + protocol: icmp + state: absent + register: result +- name: verify setup firewal rule + assert: + that: + - result is success + +- name: test fail if missing group + vultr_firewall_rule: + register: result + ignore_errors: yes +- name: verify test fail if missing group + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: group"' + +- name: test create firewall rule tcp in check mode + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + register: result + check_mode: true +- name: verify test create firewall rule tcp in check mode + assert: + that: + - result is changed + +- name: test create firewall rule tcp + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + register: result +- name: verify test create firewall rule tcp + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "tcp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "0.0.0.0/0" + +- name: test create firewall rule tcp idempotence + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + register: result +- name: verify test create firewall rule tcp idempotence + assert: + that: + - result is not changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "tcp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "0.0.0.0/0" + +- name: test create firewall rule udp in check mode + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + register: result + check_mode: true +- name: verify test create firewall rule udp in check mode + assert: + that: + - result is changed + +- name: test create firewall rule udp + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + register: result +- name: verify test create firewall rule udp + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "udp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "0.0.0.0/0" + +- name: test create firewall rule udp idempotence + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + register: result +- name: verify test create firewall rule udp idempotence + assert: + that: + - result is not changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "udp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "0.0.0.0/0" + +- name: test create firewall rule udp v6 in check mode + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + ip_version: v6 + register: result + check_mode: true +- name: verify test create firewall rule udp v6 in check mode + assert: + that: + - result is changed + +- name: test create firewall rule udp v6 + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + ip_version: v6 + register: result +- name: verify test create firewall rule udp v6 + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "udp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "::/0" + +- name: test create firewall rule udp v6 idempotence + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + ip_version: v6 + register: result +- name: verify test create firewall rule udp v6 idempotence + assert: + that: + - result is not changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "udp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "::/0" + +- name: test create firewall rule port range in check mode + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + start_port: 8000 + end_port: 8080 + protocol: tcp + cidr: 10.100.12.0/24 + register: result + check_mode: true +- name: verify test create firewall rule port range in check mode + assert: + that: + - result is changed + +- name: test create firewall rule port range + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + start_port: 8000 + end_port: 8080 + protocol: tcp + cidr: 10.100.12.0/24 + register: result +- name: verify test create firewall rule port range + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "tcp" + - result.vultr_firewall_rule.start_port == 8000 + - result.vultr_firewall_rule.end_port == 8080 + - result.vultr_firewall_rule.cidr == "10.100.12.0/24" + +- name: test create firewall rule port range idempotence + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + start_port: 8000 + end_port: 8080 + protocol: tcp + cidr: 10.100.12.0/24 + register: result +- name: test create firewall rule port range idempotence + assert: + that: + - result is not changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "tcp" + - result.vultr_firewall_rule.start_port == 8000 + - result.vultr_firewall_rule.end_port == 8080 + - result.vultr_firewall_rule.cidr == "10.100.12.0/24" + +- name: test create firewall rule icmp in check mode + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + protocol: icmp + register: result + check_mode: true +- name: test create firewall rule icmp in check mode + assert: + that: + - result is changed + +- name: test create firewall rule icmp + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + protocol: icmp + register: result +- name: test create firewall rule icmp + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "icmp" + +- name: test create firewall rule icmp idempotence + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + protocol: icmp + register: result +- name: test create firewall rule icmp idempotence + assert: + that: + - result is not changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "icmp" + +- name: test remove firewall rule icmp in check mode + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + protocol: icmp + state: absent + register: result + check_mode: true +- name: test remove firewall rule icmp in check mode + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "icmp" + +- name: test remove firewall rule icmp + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + protocol: icmp + state: absent + register: result +- name: test remove firewall rule icmp + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "icmp" + +- name: test remove firewall rule icmp idempotence + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + protocol: icmp + state: absent + register: result +- name: test remove firewall rule icmp idempotence + assert: + that: + - result is not changed + +- name: test remove firewall rule tcp in check mode + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + state: absent + register: result + check_mode: true +- name: verify test remove firewall rule tcp in check mode + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "tcp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "0.0.0.0/0" + +- name: test remove firewall rule tcp + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + state: absent + register: result +- name: verify test remove firewall rule tcp + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "tcp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "0.0.0.0/0" + +- name: test remove firewall rule tcp idempotence + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + state: absent + register: result +- name: verify test remove firewall rule tcp idempotence + assert: + that: + - result is not changed + +- name: test remove firewall rule udp v6 in check mode + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + ip_version: v6 + state: absent + register: result + check_mode: true +- name: verify test remove firewall rule udp v6 in check mode + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "udp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "::/0" + +- name: test remove firewall rule udp v6 + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + ip_version: v6 + state: absent + register: result +- name: verify test remove firewall rule udp v6 + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "udp" + - result.vultr_firewall_rule.start_port == 53 + - result.vultr_firewall_rule.cidr == "::/0" + +- name: test remove firewall rule udp v6 idempotence + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + port: 53 + protocol: udp + ip_version: v6 + state: absent + register: result +- name: verify test remove firewall rule udp v6 idempotence + assert: + that: + - result is not changed + +- name: test remove firewall rule port range in check mode + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + start_port: 8000 + end_port: 8080 + protocol: tcp + cidr: 10.100.12.0/24 + state: absent + register: result + check_mode: true +- name: verify test remove firewall rule port range in check mode + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "tcp" + - result.vultr_firewall_rule.start_port == 8000 + - result.vultr_firewall_rule.end_port == 8080 + - result.vultr_firewall_rule.cidr == "10.100.12.0/24" + +- name: test remove firewall rule port range + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + start_port: 8000 + end_port: 8080 + protocol: tcp + cidr: 10.100.12.0/24 + state: absent + register: result +- name: verify test remove firewall rule port range + assert: + that: + - result is changed + - result.vultr_firewall_rule.action == "accept" + - result.vultr_firewall_rule.protocol == "tcp" + - result.vultr_firewall_rule.start_port == 8000 + - result.vultr_firewall_rule.end_port == 8080 + - result.vultr_firewall_rule.cidr == "10.100.12.0/24" + +- name: test remove firewall rule port range idempotence + vultr_firewall_rule: + group: "{{ vultr_firewall_group_name }}" + start_port: 8000 + end_port: 8080 + protocol: tcp + cidr: 10.100.12.0/24 + state: absent + register: result +- name: verify test remove firewall rule port range idempotence + assert: + that: + - result is not changed diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network/defaults/main.yml new file mode 100644 index 00000000..a3d9e592 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network/defaults/main.yml @@ -0,0 +1,5 @@ +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_network_name: "{{ vultr_resource_prefix }}_network" +vultr_network_cidr: 192.168.42.0/24 +vultr_network_region: New Jersey diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network/tasks/main.yml new file mode 100644 index 00000000..7a7b0b1b --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network/tasks/main.yml @@ -0,0 +1,113 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup + vultr_network: + name: "{{ vultr_network_name }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +- name: test fail if missing name + vultr_network: + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: name"' + +- name: test fail if missing params for state=present + vultr_network: + name: "{{ vultr_network_name }}" + register: result + ignore_errors: yes +- name: verify fail if missing params for state=present + assert: + that: + - result is failed + - 'result.msg == "state is present but all of the following are missing: cidr, region"' + +- name: test create network in check mode + vultr_network: + name: "{{ vultr_network_name }}" + cidr: "{{ vultr_network_cidr }}" + region: "{{ vultr_network_region }}" + register: result + check_mode: yes +- name: verify test create server in check mode + assert: + that: + - result is changed + +- name: test create network + vultr_network: + name: "{{ vultr_network_name }}" + cidr: "{{ vultr_network_cidr }}" + region: "{{ vultr_network_region }}" + register: result + +- name: verify test create network + assert: + that: + - result is changed + - result.vultr_network.name == "{{ vultr_network_name }}" + - result.vultr_network.region == "{{ vultr_network_region }}" + - result.vultr_network.v4_subnet == "{{ vultr_network_cidr.split('/')[0] }}" + - result.vultr_network.v4_subnet_mask == 24 + +- name: test create network idempotence + vultr_network: + name: "{{ vultr_network_name }}" + cidr: "{{ vultr_network_cidr }}" + region: "{{ vultr_network_region }}" + register: result + +- name: verify test network idempotence + assert: + that: + - result is not changed + - result.vultr_network.name == "{{ vultr_network_name }}" + - result.vultr_network.region == "{{ vultr_network_region }}" + - result.vultr_network.v4_subnet == "{{ vultr_network_cidr.split('/')[0] }}" + - result.vultr_network.v4_subnet_mask == 24 + +- name: test destroy network in check mode + vultr_network: + name: "{{ vultr_network_name }}" + state: absent + register: result + check_mode: yes + +- name: verify test destroy network in check mode + assert: + that: + - result is changed + - result.vultr_network.name == "{{ vultr_network_name }}" + +- name: test destroy network volume + vultr_network: + name: "{{ vultr_network_name }}" + state: absent + register: result + +- name: verify test destroy an existing network + assert: + that: + - result is changed + - result.vultr_network.name == "{{ vultr_network_name }}" + +- name: test destroy an existing network idempotence + vultr_network: + name: "{{ vultr_network_name }}" + state: absent + register: result + +- name: verify test destroy an existing network idempotence + assert: + that: + - result is not changed diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network_info/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network_info/defaults/main.yml new file mode 100644 index 00000000..28e3e705 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network_info/defaults/main.yml @@ -0,0 +1,5 @@ +--- +vultr_resource_prefix: "vultr_test_prefix" +vultr_network_name: "{{ vultr_resource_prefix }}_network" +vultr_network_cidr: 192.168.42.0/24 +vultr_network_region: New Jersey diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network_info/tasks/main.yml new file mode 100644 index 00000000..90d45a08 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_network_info/tasks/main.yml @@ -0,0 +1,35 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# 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/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_os_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_os_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_os_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_os_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_os_info/tasks/main.yml new file mode 100644 index 00000000..a48133e4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_os_info/tasks/main.yml @@ -0,0 +1,22 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# Copyright (c) 2019, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test get vultr os infos in check mode + vultr_os_info: + check_mode: yes + register: result + +- name: verify test get vultr os infos in check mode + assert: + that: + - result.vultr_os_info|selectattr('name','equalto', 'CentOS 7 x64') | list | count == 1 + +- name: test get vultr os fact + vultr_os_info: + register: result + +- name: verify test get vultr os infos + assert: + that: + - result.vultr_os_info|selectattr('name','equalto', 'CentOS 7 x64') | list | count == 1 diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_baremetal_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_baremetal_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_baremetal_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_baremetal_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_baremetal_info/tasks/main.yml new file mode 100644 index 00000000..372123bb --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_baremetal_info/tasks/main.yml @@ -0,0 +1,22 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# Copyright (c) 2020, Simon Bärlocher <s.baerlocher@sbaerlocher.ch> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test gather vultr plan baremetal info in check mode + vultr_plan_baremetal_info: + check_mode: yes + register: result + +- name: verify test gather vultr plan baremetal info in check mode + assert: + that: + - result.vultr_plan_baremetal_info|selectattr('name','equalto','65536 MB RAM,2x 240 GB SSD,5.00 TB BW') | list | count == 1 + +- name: test gather vultr plan baremetal info + vultr_plan_baremetal_info: + register: result + +- name: verify test gather vultr plan baremetal info + assert: + that: + - result.vultr_plan_baremetal_info|selectattr('name','equalto','65536 MB RAM,2x 240 GB SSD,5.00 TB BW') | list | count == 1 diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_info/tasks/main.yml new file mode 100644 index 00000000..6b379032 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_plan_info/tasks/main.yml @@ -0,0 +1,21 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# 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/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_region_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_region_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_region_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_region_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_region_info/tasks/main.yml new file mode 100644 index 00000000..adf8a8a4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_region_info/tasks/main.yml @@ -0,0 +1,21 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# 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/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server/defaults/main.yml new file mode 100644 index 00000000..2b685295 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server/defaults/main.yml @@ -0,0 +1,13 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_server_name: "{{ vultr_resource_prefix }}_vm" +vultr_server_ssh_keys: +- name: key1 + key: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEAyWYItY+3w5b8PdGRoz0oY5mufqydW96naE+VM3JSvJFAUS08rAjQQpQ03ymoALeHQy6JVZbcgecxn6p0pAOINQdqufn4udPtOPCtMjNiPGpkSM9ah/6X5+kvyWMNrvlf+Ld4OOoszP5sAkgQzIbrFQAm41XknBUha0zkewZwfrVhain4pnDjV7wCcChId/Q/Gbi4xMtXkisznWcAJcueBs3EEZDKhJ5q0VeWSJEhYJDLFN1sOxF0AIUnMrOhfKQ/LjgREXPB6uCl899INUTXRNNjRpeMXyJ2wMMmOAbua2qEd1r13Bu1n+6A823Hzb33fyMXuqWnJwBJ4DCvMlGuEsfuOK+xk7DaBfLHbcM6fsPk0/4psTE6YLgC41remr6+u5ZWsY/faMtSnNPie8Z8Ov0DIYGdhbJjUXk1HomxRV9+ZfZ2Ob8iCwlaAQAyEUM6fs3Kxt8pBD8dx1HOkhsfBWPvuDr5y+kqE7H8/MuPDTc0QgH2pjUMpmw/XBwNDHshVEjrZvtICOjOLUJxcowLO1ivNYwPwowQxfisMy56LfYdjsOslBiqsrkAqvNGm1zu8wKHeqVN9w5l3yUELpvubfm9NKIvYcl6yWF36T0c5vE+g0DU/Jy4XpTj0hZG9QV2mRQcLJnd2pxQtJT7cPFtrn/+tgRxzjEtbDXummDV4sE= mail@renemoser.net" +- name: key2 + key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoQ9S7V+CufAgwoehnf2TqsJ9LTsu8pUA3FgpS2mdVwcMcTs++8P5sQcXHLtDmNLpWN4k7NQgxaY1oXy5e25x/4VhXaJXWEt3luSw+Phv/PB2+aGLvqCUirsLTAD2r7ieMhd/pcVf/HlhNUQgnO1mupdbDyqZoGD/uCcJiYav8i/V7nJWJouHA8yq31XS2yqXp9m3VC7UZZHzUsVJA9Us5YqF0hKYeaGruIHR2bwoDF9ZFMss5t6/pzxMljU/ccYwvvRDdI7WX4o4+zLuZ6RWvsU6LGbbb0pQdB72tlV41fSefwFsk4JRdKbyV3Xjf25pV4IXOTcqhy+4JTB/jXxrF torwalds@github.com" + +vultr_server_plan_1: 1024 MB RAM,25 GB SSD,1.00 TB BW +vultr_server_plan_2: 2048 MB RAM,55 GB SSD,2.00 TB BW diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server/tasks/main.yml new file mode 100644 index 00000000..ac6a6f3f --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server/tasks/main.yml @@ -0,0 +1,551 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup + vultr_server: + name: "{{ vultr_server_name }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +# Servers can only be destroyed 5 min after creation +- name: wait for 5 min + wait_for: + when: result is changed + +- name: test fail if missing name + vultr_server: + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: name"' + +- name: test fail if missing params for state=present + vultr_server: + name: "{{ vultr_server_name }}" + register: result + ignore_errors: yes +- name: verify fail if missing params for state=present + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: os, plan, region"' + +- name: test fail if plan does not exist + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: does_not_exist + region: Amsterdam + register: result + ignore_errors: yes +- name: verify test fail if plan does not exist + assert: + that: + - result is failed + - 'result.msg == "Could not find plans with ID or name: does_not_exist"' + +- name: setup create ssh keys + vultr_ssh_key: + name: "{{ item.name }}" + ssh_key: "{{ item.key }}" + loop: "{{ vultr_server_ssh_keys }}" + +- name: test create server in check mode + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_1 }}" + ssh_keys: + - key1 + - key2 + region: Amsterdam + state: started + register: result + check_mode: yes +- name: verify test create server in check mode + assert: + that: + - result is changed + +- name: test create server + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_1 }}" + ssh_keys: + - key1 + - key2 + region: Amsterdam + state: started + register: result +- name: verify test create server + assert: + that: + - result is changed + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_1 + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.power_status == 'running' + +- name: test create server idempotence + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_1 }}" + ssh_keys: + - key1 + - key2 + region: Amsterdam + state: started + register: result +- name: verify test create server idempotence + assert: + that: + - result is not changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_1 + - result.vultr_server.region == 'Amsterdam' + +- name: test stop an existing server in check mode + vultr_server: + name: "{{ vultr_server_name }}" + state: stopped + register: result + check_mode: yes +- name: verify test stop server in check mode + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +- name: test stop an existing server + vultr_server: + name: "{{ vultr_server_name }}" + state: stopped + register: result +- name: verify test stop an existing server + assert: + that: + - result is changed + - result.vultr_server.power_status == 'stopped' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +- name: test stop an existing server idempotence + vultr_server: + name: "{{ vultr_server_name }}" + state: stopped + register: result +- name: verify test stop an existing server idempotence + assert: + that: + - result is not changed + - result.vultr_server.power_status == 'stopped' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +- name: test start an existing server in check mode + vultr_server: + name: "{{ vultr_server_name }}" + state: started + register: result + check_mode: yes +- name: verify test start an existing server in check mode + assert: + that: + - result is changed + - result.vultr_server.power_status == 'stopped' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +- name: test start an existing server + vultr_server: + name: "{{ vultr_server_name }}" + state: started + register: result +- name: verify test start an existing server + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +- name: test start an existing server idempotence + vultr_server: + name: "{{ vultr_server_name }}" + state: started + register: result +- name: verify test start an existing server idempotence + assert: + that: + - result is not changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +- name: test update plan for server in check mode without force + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_2 }}" + region: Amsterdam + register: result + check_mode: yes +- name: verify test update plan for server in check mode without force + assert: + that: + - result is not changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_1 + - result.vultr_server.region == 'Amsterdam' + +- name: test update plan for server without force + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_2 }}" + region: Amsterdam + register: result +- name: verify test update plan for server without force + assert: + that: + - result is not changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_1 + - result.vultr_server.region == 'Amsterdam' + +- name: setup firewall group + vultr_firewall_group: + name: test_firewall_group + register: result +- name: verify test create firewall group + assert: + that: + - result is success + +- name: test fail with unknown firewall group + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + region: Amsterdam + firewall_group: does not exist + tag: test_tag + register: result + ignore_errors: yes + check_mode: yes +- name: verify test fail with unknown firewall group + assert: + that: + - result is failed + - result.msg.startswith('Could not find') + +- name: test update tag, firewall group for server in check mode without force + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + region: Amsterdam + firewall_group: test_firewall_group + tag: test_tag + register: result + check_mode: yes +- name: verify test update tag, firewall group for server in check mode without force + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_1 + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.tag == '' + - result.vultr_server.firewall_group != 'test_firewall_group' + +- name: test update tag, firewall group for server without force + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + region: Amsterdam + firewall_group: test_firewall_group + tag: test_tag + register: result +- name: verify test update tag, firewall group for server without force + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.tag == 'test_tag' + - result.vultr_server.firewall_group == 'test_firewall_group' + +- name: test update tag, firewall group for server without force idempotence + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + region: Amsterdam + firewall_group: test_firewall_group + tag: test_tag + register: result +- name: verify test update tag, firewall group for server without force idempotence + assert: + that: + - result is not changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.tag == 'test_tag' + - result.vultr_server.firewall_group == 'test_firewall_group' + +- name: test update server in check mode with force + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_2 }}" + auto_backup_enabled: yes + private_network_enabled: yes + region: Amsterdam + force: yes + register: result + check_mode: yes +- name: verify test update server in check mode with force + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_1 + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.auto_backup_enabled == false + - result.vultr_server.internal_ip == '' + +- name: test update server with force + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_2 }}" + auto_backup_enabled: yes + private_network_enabled: yes + region: Amsterdam + force: yes + register: result +- name: verify test update server with force + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_2 + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.auto_backup_enabled == true + - result.vultr_server.internal_ip != '' + +- name: test update server idempotence with force + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_2 }}" + auto_backup_enabled: yes + private_network_enabled: yes + region: Amsterdam + force: yes + register: result +- name: verify test update server idempotence with force + assert: + that: + - result is not changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_2 + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.auto_backup_enabled == true + - result.vultr_server.internal_ip != '' + +- name: test update server with IDs idempotence with force + vultr_server: + name: "{{ vultr_server_name }}" + os: "127" + plan: "202" + auto_backup_enabled: yes + private_network_enabled: yes + region: "7" + force: yes + register: result +- name: verify test update server idempotence with force + assert: + that: + - result is not changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_2 + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.auto_backup_enabled == true + - result.vultr_server.internal_ip != '' + +- name: test update server to stopped in check mode + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_2 }}" + ipv6_enabled: yes + region: Amsterdam + state: stopped + register: result + check_mode: yes +- name: verify test update server to stopped in check mode + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_2 + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.v6_main_ip == '' + +- name: test update server to stopped + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_2 }}" + ipv6_enabled: yes + region: Amsterdam + state: stopped + register: result +- name: verify test update server to stopped + assert: + that: + - result is changed + - result.vultr_server.power_status == 'stopped' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_2 + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.v6_main_ip != '' + +- name: test update server to stopped idempotence + vultr_server: + name: "{{ vultr_server_name }}" + os: CentOS 6 x64 + plan: "{{ vultr_server_plan_2 }}" + ipv6_enabled: yes + region: Amsterdam + state: stopped + register: result +- name: verify test update server to stopped idempotence + assert: + that: + - result is not changed + - result.vultr_server.power_status == 'stopped' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.plan == vultr_server_plan_2 + - result.vultr_server.region == 'Amsterdam' + - result.vultr_server.v6_main_ip != '' + +- name: test restart an existing server in check mode + vultr_server: + name: "{{ vultr_server_name }}" + state: restarted + register: result + check_mode: yes +- name: verify test restart an existing server in check mode + assert: + that: + - result is changed + - result.vultr_server.power_status == 'stopped' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +- name: test restart an existing server + vultr_server: + name: "{{ vultr_server_name }}" + state: restarted + register: result +- name: verify test restart an existing server + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +- name: test absent server in check mode + vultr_server: + name: "{{ vultr_server_name }}" + state: absent + register: result + check_mode: yes +- name: verify test absent server in check mode + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +# Servers can only be destroyed 5 min after creation +- name: wait for 5 min + wait_for: + +- name: test absent server + vultr_server: + name: "{{ vultr_server_name }}" + state: absent + register: result +- name: verify test absent server + assert: + that: + - result is changed + - result.vultr_server.power_status == 'running' + - result.vultr_server.name == vultr_server_name + - result.vultr_server.os == 'CentOS 6 x64' + - result.vultr_server.region == 'Amsterdam' + +- name: test absent server idempotence + vultr_server: + name: "{{ vultr_server_name }}" + state: absent + register: result +- name: verify test absent server idempotence + assert: + that: + - result is not changed + +- name: cleanup ssh keys + vultr_ssh_key: + name: "{{ item.name }}" + ssh_key: "{{ item.key }}" + state: absent + loop: "{{ vultr_server_ssh_keys }}" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_baremetal/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_baremetal/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_baremetal/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_baremetal/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_baremetal/defaults/main.yml new file mode 100644 index 00000000..0be096a5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_baremetal/defaults/main.yml @@ -0,0 +1,13 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# Copyright (c) 2020, Simon Bärlocher <s.baerlocher@sbaerlocher.ch> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_resource_prefix: 'vultr-test-prefix' +vultr_server_baremetal_name: '{{ vultr_resource_prefix }}_baremetal' +vultr_server_baremetal_ssh_keys: + - name: key1 + key: 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEAyWYItY+3w5b8PdGRoz0oY5mufqydW96naE+VM3JSvJFAUS08rAjQQpQ03ymoALeHQy6JVZbcgecxn6p0pAOINQdqufn4udPtOPCtMjNiPGpkSM9ah/6X5+kvyWMNrvlf+Ld4OOoszP5sAkgQzIbrFQAm41XknBUha0zkewZwfrVhain4pnDjV7wCcChId/Q/Gbi4xMtXkisznWcAJcueBs3EEZDKhJ5q0VeWSJEhYJDLFN1sOxF0AIUnMrOhfKQ/LjgREXPB6uCl899INUTXRNNjRpeMXyJ2wMMmOAbua2qEd1r13Bu1n+6A823Hzb33fyMXuqWnJwBJ4DCvMlGuEsfuOK+xk7DaBfLHbcM6fsPk0/4psTE6YLgC41remr6+u5ZWsY/faMtSnNPie8Z8Ov0DIYGdhbJjUXk1HomxRV9+ZfZ2Ob8iCwlaAQAyEUM6fs3Kxt8pBD8dx1HOkhsfBWPvuDr5y+kqE7H8/MuPDTc0QgH2pjUMpmw/XBwNDHshVEjrZvtICOjOLUJxcowLO1ivNYwPwowQxfisMy56LfYdjsOslBiqsrkAqvNGm1zu8wKHeqVN9w5l3yUELpvubfm9NKIvYcl6yWF36T0c5vE+g0DU/Jy4XpTj0hZG9QV2mRQcLJnd2pxQtJT7cPFtrn/+tgRxzjEtbDXummDV4sE= mail@renemoser.net' + - name: key2 + key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoQ9S7V+CufAgwoehnf2TqsJ9LTsu8pUA3FgpS2mdVwcMcTs++8P5sQcXHLtDmNLpWN4k7NQgxaY1oXy5e25x/4VhXaJXWEt3luSw+Phv/PB2+aGLvqCUirsLTAD2r7ieMhd/pcVf/HlhNUQgnO1mupdbDyqZoGD/uCcJiYav8i/V7nJWJouHA8yq31XS2yqXp9m3VC7UZZHzUsVJA9Us5YqF0hKYeaGruIHR2bwoDF9ZFMss5t6/pzxMljU/ccYwvvRDdI7WX4o4+zLuZ6RWvsU6LGbbb0pQdB72tlV41fSefwFsk4JRdKbyV3Xjf25pV4IXOTcqhy+4JTB/jXxrF torwalds@github.com' + +vultr_server_baremetal_plan_1: 65536 MB RAM,2x 240 GB SSD,5.00 TB BW diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_baremetal/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_baremetal/tasks/main.yml new file mode 100644 index 00000000..f4dd752f --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_baremetal/tasks/main.yml @@ -0,0 +1,366 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +# Servers can only be destroyed 5 min after creation +- name: wait for 5 min + wait_for: + when: result is changed + +- name: test fail if missing name + vultr_server_baremetal: + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: name"' + +- name: test fail if missing params for state=present + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + register: result + ignore_errors: yes +- name: verify fail if missing params for state=present + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: os, plan, region"' + +- name: test fail if plan does not exist + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + os: CentOS 6 x64 + plan: does_not_exist + region: Amsterdam + register: result + ignore_errors: yes +- name: verify test fail if plan does not exist + assert: + that: + - result is failed + - 'result.msg == "Could not find plans with ID or name: does_not_exist"' + +- name: setup create ssh keys + vultr_ssh_key: + name: '{{ item.name }}' + ssh_key: '{{ item.key }}' + loop: '{{ vultr_server_baremetal_ssh_keys }}' + +- name: test create server in check mode + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + os: CentOS 6 x64 + plan: '{{ vultr_server_baremetal_plan_1 }}' + ssh_keys: + - key1 + - key2 + region: Amsterdam + state: started + register: result + check_mode: yes +- name: verify test create server in check mode + assert: + that: + - result is changed + +- name: test create server + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + os: CentOS 6 x64 + plan: '{{ vultr_server_baremetal_plan_1 }}' + ssh_keys: + - key1 + - key2 + region: Amsterdam + state: started + register: result +- name: verify test create server + assert: + that: + - result is changed + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.plan == vultr_server_baremetal_plan_1 + - result.vultr_server_baremetal.region == 'Amsterdam' + - result.vultr_server_baremetal.power_status == 'running' + +- name: test create server idempotence + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + os: CentOS 6 x64 + plan: '{{ vultr_server_baremetal_plan_1 }}' + ssh_keys: + - key1 + - key2 + region: Amsterdam + state: started + register: result +- name: verify test create server idempotence + assert: + that: + - result is not changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.plan == vultr_server_baremetal_plan_1 + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: test stop an existing server in check mode + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: stopped + register: result + check_mode: yes +- name: verify test stop server in check mode + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: test stop an existing server + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: stopped + register: result +- name: verify test stop an existing server + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'stopped' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: test stop an existing server idempotence + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: stopped + register: result +- name: verify test stop an existing server idempotence + assert: + that: + - result is not changed + - result.vultr_server_baremetal.power_status == 'stopped' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: test start an existing server in check mode + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: started + register: result + check_mode: yes +- name: verify test start an existing server in check mode + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'stopped' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: test start an existing server + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: started + register: result +- name: verify test start an existing server + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: test start an existing server idempotence + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: started + register: result +- name: verify test start an existing server idempotence + assert: + that: + - result is not changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: setup firewall group + vultr_firewall_group: + name: test_firewall_group + register: result +- name: verify test create firewall group + assert: + that: + - result is success + +- name: test fail with unknown firewall group + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + os: CentOS 6 x64 + region: Amsterdam + firewall_group: does not exist + tag: test_tag + register: result + ignore_errors: yes + check_mode: yes +- name: verify test fail with unknown firewall group + assert: + that: + - result is failed + - result.msg.startswith('Could not find') + +- name: test update tag, firewall group for server in check mode without force + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + os: CentOS 6 x64 + region: Amsterdam + firewall_group: test_firewall_group + tag: test_tag + register: result + check_mode: yes +- name: verify test update tag, firewall group for server in check mode without force + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.plan == vultr_server_baremetal_plan_1 + - result.vultr_server_baremetal.region == 'Amsterdam' + - result.vultr_server_baremetal.tag == '' + - result.vultr_server_baremetal.firewall_group != 'test_firewall_group' + +- name: test update tag, firewall group for server without force + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + os: CentOS 6 x64 + region: Amsterdam + firewall_group: test_firewall_group + tag: test_tag + register: result +- name: verify test update tag, firewall group for server without force + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + - result.vultr_server_baremetal.tag == 'test_tag' + - result.vultr_server_baremetal.firewall_group == 'test_firewall_group' + +- name: test update tag, firewall group for server without force idempotence + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + os: CentOS 6 x64 + region: Amsterdam + firewall_group: test_firewall_group + tag: test_tag + register: result +- name: verify test update tag, firewall group for server without force idempotence + assert: + that: + - result is not changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + - result.vultr_server_baremetal.tag == 'test_tag' + - result.vultr_server_baremetal.firewall_group == 'test_firewall_group' + +- name: test restart an existing server in check mode + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: restarted + register: result + check_mode: yes +- name: verify test restart an existing server in check mode + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'stopped' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: test restart an existing server + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: restarted + register: result +- name: verify test restart an existing server + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: test absent server in check mode + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: absent + register: result + check_mode: yes +- name: verify test absent server in check mode + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +# Servers can only be destroyed 5 min after creation +- name: wait for 5 min + wait_for: + +- name: test absent server + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: absent + register: result +- name: verify test absent server + assert: + that: + - result is changed + - result.vultr_server_baremetal.power_status == 'running' + - result.vultr_server_baremetal.name == vultr_server_baremetal_name + - result.vultr_server_baremetal.os == 'CentOS 6 x64' + - result.vultr_server_baremetal.region == 'Amsterdam' + +- name: test absent server idempotence + vultr_server_baremetal: + name: '{{ vultr_server_baremetal_name }}' + state: absent + register: result +- name: verify test absent server idempotence + assert: + that: + - result is not changed + +- name: cleanup ssh keys + vultr_ssh_key: + name: '{{ item.name }}' + ssh_key: '{{ item.key }}' + state: absent + loop: '{{ vultr_server_baremetal_ssh_keys }}' diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_info/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_info/defaults/main.yml new file mode 100644 index 00000000..37134a1f --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_info/defaults/main.yml @@ -0,0 +1,6 @@ +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_server_name: "{{ vultr_resource_prefix }}_vm" +vultr_server_os: CentOS 7 x64 +vultr_server_plan: 1024 MB RAM,25 GB SSD,1.00 TB BW +vultr_server_region: Amsterdam diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_info/tasks/main.yml new file mode 100644 index 00000000..83deb769 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_server_info/tasks/main.yml @@ -0,0 +1,66 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup ensure VM is absent + vultr_server: + name: "{{ vultr_server_name }}" + state: absent + register: result + +# Servers can only be destroyed 5 min after creation +- name: wait for 5 min until VM is absent + wait_for: + when: result is changed + +- name: test gather vultr server info - empty resources + vultr_server_info: + register: result +- name: verify test gather vultr server info - empty resources + assert: + that: + - result.vultr_server_info | selectattr('name','equalto',vultr_server_name) | list | count == 0 + +- name: setup firewall group + vultr_firewall_group: + name: test_vultr_server_info + +- name: setup create the server + vultr_server: + name: '{{ vultr_server_name }}' + os: '{{ vultr_server_os }}' + plan: '{{ vultr_server_plan }}' + region: '{{ vultr_server_region }}' + firewall_group: test_vultr_server_info + +- name: test gather vultr server info in check mode + vultr_server_info: + check_mode: yes + register: result + +- name: verify test gather vultr server info in check mode + assert: + that: + - result.vultr_server_info|selectattr('name','equalto',vultr_server_name) | list | count == 1 + +- name: test gather vultr server info + vultr_server_info: + register: result + +- name: verify test gather vultr server info + assert: + that: + - result.vultr_server_info|selectattr('name','equalto',vultr_server_name) | list | count == 1 + +- name: Pause for 5 min before deleting the VM + pause: + minutes: 5 + +- name: cleanup the server + vultr_server: + name: '{{ vultr_server_name }}' + state: absent + +- name: cleanup firewall group + vultr_firewall_group: + name: test_vultr_server_info + state: absent diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key/defaults/main.yml new file mode 100644 index 00000000..53cce567 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key/defaults/main.yml @@ -0,0 +1,7 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_ssh_key_name: "{{ vultr_resource_prefix }}_ansible-ssh-key" +vultr_ssh_key: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEAyWYItY+3w5b8PdGRoz0oY5mufqydW96naE+VM3JSvJFAUS08rAjQQpQ03ymoALeHQy6JVZbcgecxn6p0pAOINQdqufn4udPtOPCtMjNiPGpkSM9ah/6X5+kvyWMNrvlf+Ld4OOoszP5sAkgQzIbrFQAm41XknBUha0zkewZwfrVhain4pnDjV7wCcChId/Q/Gbi4xMtXkisznWcAJcueBs3EEZDKhJ5q0VeWSJEhYJDLFN1sOxF0AIUnMrOhfKQ/LjgREXPB6uCl899INUTXRNNjRpeMXyJ2wMMmOAbua2qEd1r13Bu1n+6A823Hzb33fyMXuqWnJwBJ4DCvMlGuEsfuOK+xk7DaBfLHbcM6fsPk0/4psTE6YLgC41remr6+u5ZWsY/faMtSnNPie8Z8Ov0DIYGdhbJjUXk1HomxRV9+ZfZ2Ob8iCwlaAQAyEUM6fs3Kxt8pBD8dx1HOkhsfBWPvuDr5y+kqE7H8/MuPDTc0QgH2pjUMpmw/XBwNDHshVEjrZvtICOjOLUJxcowLO1ivNYwPwowQxfisMy56LfYdjsOslBiqsrkAqvNGm1zu8wKHeqVN9w5l3yUELpvubfm9NKIvYcl6yWF36T0c5vE+g0DU/Jy4XpTj0hZG9QV2mRQcLJnd2pxQtJT7cPFtrn/+tgRxzjEtbDXummDV4sE= ansible@example.com" +vultr_ssh_key2: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoQ9S7V+CufAgwoehnf2TqsJ9LTsu8pUA3FgpS2mdVwcMcTs++8P5sQcXHLtDmNLpWN4k7NQgxaY1oXy5e25x/4VhXaJXWEt3luSw+Phv/PB2+aGLvqCUirsLTAD2r7ieMhd/pcVf/HlhNUQgnO1mupdbDyqZoGD/uCcJiYav8i/V7nJWJouHA8yq31XS2yqXp9m3VC7UZZHzUsVJA9Us5YqF0hKYeaGruIHR2bwoDF9ZFMss5t6/pzxMljU/ccYwvvRDdI7WX4o4+zLuZ6RWvsU6LGbbb0pQdB72tlV41fSefwFsk4JRdKbyV3Xjf25pV4IXOTcqhy+4JTB/jXxrF torwalds@github.com" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key/tasks/main.yml new file mode 100644 index 00000000..ce46970e --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key/tasks/main.yml @@ -0,0 +1,140 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +- name: test fail if missing name + vultr_ssh_key: + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: name"' + +- name: test fail if missing params for state=present + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + register: result + ignore_errors: yes +- name: verify fail if missing params for state=present + assert: + that: + - result is failed + - 'result.msg == "state is present but all of the following are missing: ssh_key"' + +- name: test create ssh key in check mode + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + ssh_key: "{{ vultr_ssh_key }}" + register: result + check_mode: yes +- name: verify test create ssh key in check mode + assert: + that: + - result is changed + +- name: test create ssh key + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + ssh_key: "{{ vultr_ssh_key }}" + register: result +- name: verify test create ssh key + assert: + that: + - result is changed + - result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}' + - result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key }}' + +- name: test create ssh key idempotence + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + ssh_key: "{{ vultr_ssh_key }}" + register: result +- name: verify test create ssh key idempotence + assert: + that: + - result is not changed + - result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}' + - result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key }}' + +- name: test update ssh key in check mode + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + ssh_key: "{{ vultr_ssh_key2 }}" + register: result + check_mode: yes +- name: verify test update ssh key in check mode + assert: + that: + - result is changed + - result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}' + - result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key }}' + +- name: test update ssh key + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + ssh_key: "{{ vultr_ssh_key2 }}" + register: result +- name: verify test update ssh key + assert: + that: + - result is changed + - result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}' + - result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key2 }}' + +- name: test update ssh key idempotence + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + ssh_key: "{{ vultr_ssh_key2 }}" + register: result +- name: verify test update ssh key idempotence + assert: + that: + - result is not changed + - result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}' + - result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key2 }}' + +- name: test absent ssh key in check mode + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + state: absent + register: result + check_mode: yes +- name: verify test absent ssh key in check mode + assert: + that: + - result is changed + - result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}' + - result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key2 }}' + +- name: test absent ssh key + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + state: absent + register: result +- name: verify test absent ssh key + assert: + that: + - result is changed + - result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}' + - result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key2 }}' + +- name: test absent ssh key idempotence + vultr_ssh_key: + name: "{{ vultr_ssh_key_name }}" + state: absent + register: result +- name: verify test absent ssh key idempotence + assert: + that: + - result is not changed diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key_info/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key_info/defaults/main.yml new file mode 100644 index 00000000..63bda99f --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key_info/defaults/main.yml @@ -0,0 +1,4 @@ +--- +vultr_resource_prefix: "vultr_test_prefix" +ssh_key_name: "{{ vultr_resource_prefix }}-sshkey" +ssh_key_content: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+ZFQv3MyjtL1BMpSA0o0gIkzLVVC711rthT29hBNeORdNowQ7FSvVWUdAbTq00U7Xzak1ANIYLJyn+0r7olsdG4XEiUR0dqgC99kbT/QhY5mLe5lpl7JUjW9ctn00hNmt+TswpatCKWPNwdeAJT2ERynZaqPobENgvIq7jfOFWQIVew7qrewtqwerqwrewUr2Cdq7Nb7U0XFXh3x1p0v0+MbL4tiJwPlMAGvFTKIMt+EaA+AsRIxiOo9CMk5ZuOl9pT8h5vNuEOcvS0qx4v44EAD2VOsCVCcrPNMcpuSzZP8dRTGU9wRREAWXngD0Zq9YJMH38VTxHiskoBw1NnPz ansibletest-{{ vultr_resource_prefix }}@sshkey diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key_info/tasks/main.yml new file mode 100644 index 00000000..6a44144b --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_ssh_key_info/tasks/main.yml @@ -0,0 +1,44 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# Copyright (c) 2019, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: test get vultr ssh key info - empty resources + vultr_ssh_key_info: + register: result + +- name: verify test get vultr ssh key infos in check mode + assert: + that: + - result.vultr_ssh_key_info|selectattr('name','equalto','{{ ssh_key_name }}') | list | count == 0 + - result.vultr_ssh_key_info|selectattr('ssh_key','equalto','{{ ssh_key_content }}') | list | count == 0 + +- name: Upload an ssh key + vultr_ssh_key: + name: '{{ ssh_key_name }}' + ssh_key: '{{ ssh_key_content }}' + +- name: test get vultr ssh key infos in check mode + vultr_ssh_key_info: + check_mode: yes + register: result + +- name: verify test get vultr ssh key infos in check mode + assert: + that: + - result.vultr_ssh_key_info|selectattr('name','equalto','{{ ssh_key_name }}') | list | count == 1 + - result.vultr_ssh_key_info|selectattr('ssh_key','equalto','{{ ssh_key_content }}') | list | count == 1 + +- name: test get vultr ssh key info + vultr_ssh_key_info: + register: result + +- name: verify test get vultr ssh key infos + assert: + that: + - result.vultr_ssh_key_info|selectattr('name','equalto','{{ ssh_key_name }}') | list | count == 1 + - result.vultr_ssh_key_info|selectattr('ssh_key','equalto','{{ ssh_key_content }}') | list | count == 1 + +- name: Destroy the ssh key + vultr_ssh_key: + name: '{{ ssh_key_name }}' + state: absent diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script/defaults/main.yml new file mode 100644 index 00000000..38b68a69 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script/defaults/main.yml @@ -0,0 +1,7 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_startup_script_name: "{{ vultr_resource_prefix }}_script" +vultr_startup_script: "#!/bin/bash\necho Hello World > /root/hello" +vultr_startup_script2: "#!/bin/bash\necho Hello to my World > /root/hello" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script/tasks/main.yml new file mode 100644 index 00000000..09929beb --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script/tasks/main.yml @@ -0,0 +1,140 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +- name: test fail if missing name + vultr_startup_script: + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: name"' + +- name: test fail if missing params for state=present + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + register: result + ignore_errors: yes +- name: verify fail if missing params for state=present + assert: + that: + - result is failed + - 'result.msg == "state is present but all of the following are missing: script"' + +- name: test create startup script in check mode + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + script: "{{ vultr_startup_script }}" + register: result + check_mode: yes +- name: verify test create startup script in check mode + assert: + that: + - result is changed + +- name: test create startup script + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + script: "{{ vultr_startup_script }}" + register: result +- name: verify test create startup script + assert: + that: + - result is changed + - result.vultr_startup_script.name == '{{ vultr_startup_script_name }}' + - result.vultr_startup_script.script == '{{ vultr_startup_script }}' + +- name: test create startup script idempotence + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + script: "{{ vultr_startup_script }}" + register: result +- name: verify test create startup script idempotence + assert: + that: + - result is not changed + - result.vultr_startup_script.name == '{{ vultr_startup_script_name }}' + - result.vultr_startup_script.script == '{{ vultr_startup_script }}' + +- name: test update startup script in check mode + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + script: "{{ vultr_startup_script2 }}" + register: result + check_mode: yes +- name: verify test update startup script in check mode + assert: + that: + - result is changed + - result.vultr_startup_script.name == '{{ vultr_startup_script_name }}' + - result.vultr_startup_script.script == '{{ vultr_startup_script }}' + +- name: test update startup script + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + script: "{{ vultr_startup_script2 }}" + register: result +- name: verify test update startup script + assert: + that: + - result is changed + - result.vultr_startup_script.name == '{{ vultr_startup_script_name }}' + - result.vultr_startup_script.script == '{{ vultr_startup_script2 }}' + +- name: test update startup script idempotence + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + script: "{{ vultr_startup_script2 }}" + register: result +- name: verify test update startup script idempotence + assert: + that: + - result is not changed + - result.vultr_startup_script.name == '{{ vultr_startup_script_name }}' + - result.vultr_startup_script.script == '{{ vultr_startup_script2 }}' + +- name: test absent startup script in check mode + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + state: absent + register: result + check_mode: yes +- name: verify test absent startup script in check mode + assert: + that: + - result is changed + - result.vultr_startup_script.name == '{{ vultr_startup_script_name }}' + - result.vultr_startup_script.script == '{{ vultr_startup_script2 }}' + +- name: test absent startup script + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + state: absent + register: result +- name: verify test absent startup script + assert: + that: + - result is changed + - result.vultr_startup_script.name == '{{ vultr_startup_script_name }}' + - result.vultr_startup_script.script == '{{ vultr_startup_script2 }}' + +- name: test absent startup script idempotence + vultr_startup_script: + name: "{{ vultr_startup_script_name }}" + state: absent + register: result +- name: verify test absent startup script idempotence + assert: + that: + - result is not changed diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script_info/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script_info/defaults/main.yml new file mode 100644 index 00000000..017cff1a --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script_info/defaults/main.yml @@ -0,0 +1,4 @@ +vultr_resource_prefix: "vultr_test_prefix" +startup_script_name: "{{ vultr_resource_prefix }}_script" +startup_script_type: boot +startup_script_content: "#!/bin/bash\necho Hello World > /root/hello" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script_info/tasks/main.yml new file mode 100644 index 00000000..15882438 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_startup_script_info/tasks/main.yml @@ -0,0 +1,35 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# 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 diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user/defaults/main.yml new file mode 100644 index 00000000..9050a68f --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_resource_prefix: "vultr-test-prefix" +vultr_user_name: "{{ vultr_resource_prefix }}_user" diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user/tasks/main.yml new file mode 100644 index 00000000..8c3684c1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user/tasks/main.yml @@ -0,0 +1,225 @@ +--- +# Copyright (c) 2018, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +- name: setup + vultr_user: + name: "{{ vultr_user_name }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +- name: test fail if missing name + vultr_user: + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: name"' + +- name: test fail if missing params for state=present + vultr_user: + name: "{{ vultr_user_name }}" + register: result + ignore_errors: yes +- name: verify fail if missing params for state=present + assert: + that: + - result is failed + - 'result.msg.startswith("state is present but all of the following are missing")' + +- name: test fail param not in choices + vultr_user: + name: "{{ vultr_user_name }}" + email: john.doe@example.com + password: s3cr3t + acls: + - bad + - dns + - manage_users + register: result + ignore_errors: yes +- name: verify test fail if missing name + assert: + that: + - result is failed + - 'result.msg.startswith("value of acls must be one or more of")' + +- name: test create user in check mode + vultr_user: + name: "{{ vultr_user_name }}" + email: john.doe@example.com + password: s3cr3t + acls: + - upgrade + - dns + - manage_users + register: result + check_mode: yes +- name: verify test create user in check mode + assert: + that: + - result is changed + +- name: test create user + vultr_user: + name: "{{ vultr_user_name }}" + email: john.doe@example.com + password: s3cr3t + acls: + - upgrade + - dns + - manage_users + register: result +- name: verify test create user + assert: + that: + - result is changed + - result.vultr_user.name == '{{ vultr_user_name }}' + - result.vultr_user.email == 'john.doe@example.com' + - result.vultr_user.api_enabled == true + - "'upgrade' in result.vultr_user.acls" + - "'manage_users' in result.vultr_user.acls" + - "'dns' in result.vultr_user.acls" + - result.vultr_user.api_key is defined + +- name: test create user idempotence + vultr_user: + name: "{{ vultr_user_name }}" + email: john.doe@example.com + password: s3cr3t + acls: + - upgrade + - dns + - manage_users + register: result +- name: verify test create user idempotence + assert: + that: + - result is not changed + - result.vultr_user.name == '{{ vultr_user_name }}' + - result.vultr_user.email == 'john.doe@example.com' + - result.vultr_user.api_enabled == true + - "'upgrade' in result.vultr_user.acls" + - "'manage_users' in result.vultr_user.acls" + - "'dns' in result.vultr_user.acls" + - result.vultr_user.api_key is not defined + +- name: test update user in check mode + vultr_user: + name: "{{ vultr_user_name }}" + email: jimmy@example.com + password: s3cr3t + api_enabled: false + acls: + - manage_users + - upgrade + - support + register: result + check_mode: yes +- name: verify test update user in check mode + assert: + that: + - result is changed + - result.vultr_user.name == '{{ vultr_user_name }}' + - result.vultr_user.email == 'john.doe@example.com' + - "'upgrade' in result.vultr_user.acls" + - "'manage_users' in result.vultr_user.acls" + - "'dns' in result.vultr_user.acls" + - result.vultr_user.api_enabled == true + - result.vultr_user.api_key is not defined + +- name: test update user + vultr_user: + name: "{{ vultr_user_name }}" + email: jimmy@example.com + password: s3cr3t + api_enabled: false + acls: + - manage_users + - upgrade + - support + register: result +- name: verify test update user + assert: + that: + - result is changed + - result.vultr_user.name == '{{ vultr_user_name }}' + - result.vultr_user.email == 'jimmy@example.com' + - "'upgrade' in result.vultr_user.acls" + - "'manage_users' in result.vultr_user.acls" + - "'support' in result.vultr_user.acls" + - result.vultr_user.api_enabled == false + - result.vultr_user.api_key is not defined + +- name: test update user idempotence + vultr_user: + name: "{{ vultr_user_name }}" + email: jimmy@example.com + password: s3cr3t + api_enabled: false + acls: + - manage_users + - upgrade + - support + register: result +- name: verify test update user idempotence + assert: + that: + - result is not changed + - result.vultr_user.name == '{{ vultr_user_name }}' + - result.vultr_user.email == 'jimmy@example.com' + - "'upgrade' in result.vultr_user.acls" + - "'manage_users' in result.vultr_user.acls" + - "'support' in result.vultr_user.acls" + - result.vultr_user.api_enabled == false + - result.vultr_user.api_key is not defined + +- name: test absent user in check mode + vultr_user: + name: "{{ vultr_user_name }}" + state: absent + register: result + check_mode: yes +- name: verify test absent user in check mode + assert: + that: + - result is changed + - result.vultr_user.name == '{{ vultr_user_name }}' + - result.vultr_user.email == 'jimmy@example.com' + - "'upgrade' in result.vultr_user.acls" + - "'manage_users' in result.vultr_user.acls" + - "'support' in result.vultr_user.acls" + - result.vultr_user.api_enabled == false + - result.vultr_user.api_key is not defined + +- name: test absent user + vultr_user: + name: "{{ vultr_user_name }}" + state: absent + register: result +- name: verify test absent user + assert: + that: + - result is changed + - result.vultr_user.name == '{{ vultr_user_name }}' + - result.vultr_user.email == 'jimmy@example.com' + - "'upgrade' in result.vultr_user.acls" + - "'manage_users' in result.vultr_user.acls" + - "'support' in result.vultr_user.acls" + - result.vultr_user.api_enabled == false + - result.vultr_user.api_key is not defined + +- name: test absent user idempotence + vultr_user: + name: "{{ vultr_user_name }}" + state: absent + register: result +- name: verify test absent user idempotence + assert: + that: + - result is not changed diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user_info/aliases b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user_info/aliases new file mode 100644 index 00000000..bf469bb9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user_info/aliases @@ -0,0 +1 @@ +cloud/vultr diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user_info/defaults/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user_info/defaults/main.yml new file mode 100644 index 00000000..5922f6fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user_info/defaults/main.yml @@ -0,0 +1,10 @@ +--- +vultr_resource_prefix: "vultr-test-prefix" +user_name: "{{ vultr_resource_prefix }}_user" +user_email: mytestuser-{{ vultr_resource_prefix }}@example.com +user_password: "{{ vultr_resource_prefix }}aP4ssw0rd!" +user_acls: + - upgrade + - dns + - manage_users + - subscriptions diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user_info/tasks/main.yml b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user_info/tasks/main.yml new file mode 100644 index 00000000..164c22fc --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/integration/targets/vultr_user_info/tasks/main.yml @@ -0,0 +1,34 @@ +# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org> +# Copyright (c) 2019, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Create the user + vultr_user: + name: '{{ user_name }}' + email: '{{ user_email }}' + password: '{{ user_password }}' + acls: '{{ user_acls }}' + +- name: test get vultr user info in check mode + vultr_user_info: + register: result + check_mode: yes + +- name: verify test get vultr user info in check mode + assert: + that: + - result.vultr_user_info|selectattr('name','equalto','{{ user_name }}') | list | count == 1 + +- name: test get vultr user info + vultr_user_info: + register: result + +- name: verify test get vultr user info + assert: + that: + - result.vultr_user_info|selectattr('name','equalto','{{ user_name }}') | list | count == 1 + +- name: Delete the user + vultr_user: + name: '{{ user_name }}' + state: absent diff --git a/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/sanity/ignore-2.10.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/ngine_io/vultr/tests/sanity/ignore-2.10.txt |