diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
commit | 7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch) | |
tree | efb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/vultr/cloud/tests/integration | |
parent | Releasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff) | |
download | ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip |
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/vultr/cloud/tests/integration')
53 files changed, 991 insertions, 145 deletions
diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/_reset_cloud/aliases b/ansible_collections/vultr/cloud/tests/integration/targets/_reset_cloud/aliases new file mode 100644 index 000000000..8a729dddd --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/_reset_cloud/aliases @@ -0,0 +1,2 @@ +cloud/vultr +needs/target/cleanup diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/_reset_cloud/tasks/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/_reset_cloud/tasks/main.yml new file mode 100644 index 000000000..39bfc64b3 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/_reset_cloud/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- ansible.builtin.import_role: + name: cleanup + tasks_from: cleanup_all diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/aliases b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/aliases new file mode 100644 index 000000000..c749ce7ca --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/aliases @@ -0,0 +1,3 @@ +cloud/vultr +needs/target/common +needs/target/cleanup diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/defaults/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/defaults/main.yml new file mode 100644 index 000000000..796d8b9f2 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/defaults/main.yml @@ -0,0 +1,46 @@ +# Copyright (c) 2023, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +vultr_bare_metal_ssh_key_name: "{{ vultr_resource_prefix }}_bare_metal_sshkey" +vultr_bare_metal_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_bare_metals: + - label: "{{ vultr_resource_prefix }}_bm1" + hostname: myhostname + user_data: | + #cloud-config + packages: + - htop + user_data_update: | + #cloud-config + packages: + - htop + - vim + plan: vbm-6c-32gb + plan_update: vbm-6c-32gb + ssh_keys: + - "{{ vultr_bare_metal_ssh_key_name }}" + tags: + - one + - two + tags_update: + - three + - four + region: ams + os: Debian 12 x64 (bookworm) + enable_ipv6: false + enable_ipv6_update: true + # vpc2s: + # - "{{ vultr_resource_prefix }}_instance_vpc2_1" + # vpc2s_update: + # - "{{ vultr_resource_prefix }}_instance_vpc2_2" + +vutr_bare_metal_vpc2s: [] + # - description: "{{ vultr_resource_prefix }}_instance_vpc2_1" + # subnet: 192.168.42.0 + # cidr: 24 + # region: ams + # - description: "{{ vultr_resource_prefix }}_instance_vpc2_2" + # subnet: 192.168.23.0 + # cidr: 24 + # region: ams diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/meta/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/meta/main.yml new file mode 100644 index 000000000..2083f0e12 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/absent.yml b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/absent.yml new file mode 100644 index 000000000..bee8df6f9 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/absent.yml @@ -0,0 +1,38 @@ +--- +- name: bare metal info + ansible.builtin.debug: + var: bare_metal + +- name: test absent bare metal in check mode + vultr.cloud.bare_metal: + label: "{{ bare_metal.label }}" + region: "{{ bare_metal.region }}" + state: absent + register: result + check_mode: true +- name: verify test absent bare metal in check mode + ansible.builtin.assert: + that: + - result is changed + +- name: test absent bare metal + vultr.cloud.bare_metal: + label: "{{ bare_metal.label }}" + region: "{{ bare_metal.region }}" + state: absent + register: result +- name: verify test absent bare metal + ansible.builtin.assert: + that: + - result is changed + +- name: test absent bare metal idempotence + vultr.cloud.bare_metal: + label: "{{ bare_metal.label }}" + region: "{{ bare_metal.region }}" + state: absent + register: result +- name: verify test absent bare metal idempotence + ansible.builtin.assert: + that: + - result is not changed diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/failures.yml b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/failures.yml new file mode 100644 index 000000000..769dbe02b --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/failures.yml @@ -0,0 +1,55 @@ +--- +- name: test fail if missing arguments + vultr.cloud.bare_metal: + register: result + ignore_errors: true +- name: verify test fail if missing arguments + ansible.builtin.assert: + that: + - result is failed + - 'result.msg == "missing required arguments: label, region"' + +- name: test fail if missing arguments required one of + vultr.cloud.bare_metal: + label: my label + plan: a plan + region: a region + register: result + ignore_errors: true +- name: verify test fail if missing arguments required one of + ansible.builtin.assert: + that: + - result is failed + - '"one of the following required" in result.msg' + +- name: test fail if ssh key not found + vultr.cloud.bare_metal: + label: my label + plan: a plan + region: a region + os: Debian 12 x64 (bookworm) + ssh_keys: + - does-not-exist + register: result + ignore_errors: true +- name: verify test fail if ssh key not found + ansible.builtin.assert: + that: + - result is failed + - '"SSH key names not found: does-not-exist" in result.msg' + +- name: test fail if vpc not found + vultr.cloud.bare_metal: + label: my label + plan: a plan + region: a region + os: Debian 12 x64 (bookworm) + vpc2s: + - does-not-exist + register: result + ignore_errors: true +- name: verify test fail if vpc not found + ansible.builtin.assert: + that: + - result is failed + - '"VPCs (v2) not found: does-not-exist" in result.msg' diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/main.yml new file mode 100644 index 000000000..856d7e307 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/main.yml @@ -0,0 +1,13 @@ +--- +- block: + - ansible.builtin.import_tasks: tests.yml + always: + - ansible.builtin.import_role: + name: cleanup + tasks_from: cleanup_bare_metal + - ansible.builtin.import_role: + name: cleanup + tasks_from: cleanup_ssh_key + - ansible.builtin.import_role: + name: cleanup + tasks_from: cleanup_vpc2 diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/present.yml b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/present.yml new file mode 100644 index 000000000..e3915ee45 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/present.yml @@ -0,0 +1,152 @@ +--- +- name: bare_metal info + ansible.builtin.debug: + var: bare_metal + +- name: test create bare_metal in check mode + vultr.cloud.bare_metal: + label: "{{ bare_metal.label }}" + hostname: "{{ bare_metal.hostname | default(omit) }}" + user_data: "{{ bare_metal.user_data | default(omit) }}" + ssh_keys: "{{ bare_metal.ssh_keys | default(omit) }}" + plan: "{{ bare_metal.plan }}" + enable_ipv6: "{{ bare_metal.enable_ipv6 | default(omit) }}" + tags: "{{ bare_metal.tags | default(omit) }}" + region: "{{ bare_metal.region }}" + os: "{{ bare_metal.os | default(omit) }}" + app: "{{ bare_metal.app | default(omit) }}" + image: "{{ bare_metal.image | default(omit) }}" + snapshot: "{{ bare_metal.snapshot | default(omit) }}" + vpc2s: "{{ bare_metal.vpc2s | default(omit) }}" + register: result + check_mode: true +- name: verify test create bare_metal in check mode + ansible.builtin.assert: + that: + - result is changed + +- name: test create bare_metal + vultr.cloud.bare_metal: + label: "{{ bare_metal.label }}" + hostname: "{{ bare_metal.hostname | default(omit) }}" + user_data: "{{ bare_metal.user_data | default(omit) }}" + ssh_keys: "{{ bare_metal.ssh_keys | default(omit) }}" + plan: "{{ bare_metal.plan }}" + enable_ipv6: "{{ bare_metal.enable_ipv6 | default(omit) }}" + tags: "{{ bare_metal.tags | default(omit) }}" + region: "{{ bare_metal.region }}" + os: "{{ bare_metal.os | default(omit) }}" + app: "{{ bare_metal.app | default(omit) }}" + image: "{{ bare_metal.image | default(omit) }}" + snapshot: "{{ bare_metal.snapshot | default(omit) }}" + vpc2s: "{{ bare_metal.vpc2s | default(omit) }}" + register: result +- name: verify test create bare_metal + ansible.builtin.assert: + that: + - result is changed + - result.vultr_bare_metal.plan == bare_metal.plan + - result.vultr_bare_metal.region == bare_metal.region + - result.vultr_bare_metal.enable_ipv6 == bare_metal.enable_ipv6 + # - result.vultr_bare_metal.vpc2s | selectattr('description','equalto','{{ vultr_resource_prefix }}_bare_metal_vpc2_1') | list | count == 1 + +- name: test create bare_metal idempotence + vultr.cloud.bare_metal: + label: "{{ bare_metal.label }}" + hostname: "{{ bare_metal.hostname | default(omit) }}" + user_data: "{{ bare_metal.user_data | default(omit) }}" + ssh_keys: "{{ bare_metal.ssh_keys | default(omit) }}" + plan: "{{ bare_metal.plan }}" + enable_ipv6: "{{ bare_metal.enable_ipv6 | default(omit) }}" + tags: "{{ bare_metal.tags | default(omit) }}" + region: "{{ bare_metal.region }}" + os: "{{ bare_metal.os | default(omit) }}" + app: "{{ bare_metal.app | default(omit) }}" + image: "{{ bare_metal.image | default(omit) }}" + snapshot: "{{ bare_metal.snapshot | default(omit) }}" + vpc2s: "{{ bare_metal.vpc2s | default(omit) }}" + register: result +- name: verify test create bare_metal idempotence + ansible.builtin.assert: + that: + - result is not changed + - result.vultr_bare_metal.plan == bare_metal.plan + - result.vultr_bare_metal.region == bare_metal.region + - result.vultr_bare_metal.enable_ipv6 == bare_metal.enable_ipv6 + # - result.vultr_bare_metal.vpc2s | selectattr('description','equalto','{{ vultr_resource_prefix }}_bare_metal_vpc2_1') | list | count == 1 + +- name: test update bare_metal in check mode + vultr.cloud.bare_metal: + label: "{{ bare_metal.label }}" + hostname: "{{ bare_metal.hostname | default(omit) }}" + user_data: "{{ bare_metal.user_data_update | default(omit) }}" + ssh_keys: "{{ bare_metal.ssh_keys | default(omit) }}" + plan: "{{ bare_metal.plan_update }}" + enable_ipv6: "{{ bare_metal.enable_ipv6_update | default(omit) }}" + tags: "{{ bare_metal.tags_update | default(omit) }}" + region: "{{ bare_metal.region }}" + os: "{{ bare_metal.os | default(omit) }}" + app: "{{ bare_metal.app | default(omit) }}" + image: "{{ bare_metal.image | default(omit) }}" + snapshot: "{{ bare_metal.snapshot | default(omit) }}" + vpc2s: "{{ bare_metal.vpc2s_update | default(omit) }}" + register: result + check_mode: true +- name: verify test update bare_metal in check mode + ansible.builtin.assert: + that: + - result is changed + - result.vultr_bare_metal.plan == bare_metal.plan + - result.vultr_bare_metal.region == bare_metal.region + - result.vultr_bare_metal.enable_ipv6 == bare_metal.enable_ipv6 + # - result.vultr_bare_metal.vpc2s | selectattr('description','equalto','{{ vultr_resource_prefix }}_bare_metal_vpc2_2') | list | count == 1 + +- name: test update bare_metal + vultr.cloud.bare_metal: + label: "{{ bare_metal.label }}" + hostname: "{{ bare_metal.hostname | default(omit) }}" + user_data: "{{ bare_metal.user_data_update | default(omit) }}" + ssh_keys: "{{ bare_metal.ssh_keys | default(omit) }}" + plan: "{{ bare_metal.plan_update }}" + enable_ipv6: "{{ bare_metal.enable_ipv6_update | default(omit) }}" + tags: "{{ bare_metal.tags_update | default(omit) }}" + region: "{{ bare_metal.region }}" + os: "{{ bare_metal.os | default(omit) }}" + app: "{{ bare_metal.app | default(omit) }}" + image: "{{ bare_metal.image | default(omit) }}" + snapshot: "{{ bare_metal.snapshot | default(omit) }}" + vpc2s: "{{ bare_metal.vpc2s_update | default(omit) }}" + register: result +- name: verify test update bare_metal + ansible.builtin.assert: + that: + - result is changed + - result.vultr_bare_metal.plan == bare_metal.plan_update + - result.vultr_bare_metal.region == bare_metal.region + - result.vultr_bare_metal.enable_ipv6 == bare_metal.enable_ipv6_update + # - result.vultr_bare_metal.vpc2s | selectattr('description','equalto','{{ vultr_resource_prefix }}_bare_metal_vpc2_2') | list | count == 1 + +- name: test update bare_metal idempotence + vultr.cloud.bare_metal: + label: "{{ bare_metal.label }}" + hostname: "{{ bare_metal.hostname | default(omit) }}" + user_data: "{{ bare_metal.user_data_update | default(omit) }}" + ssh_keys: "{{ bare_metal.ssh_keys | default(omit) }}" + plan: "{{ bare_metal.plan_update }}" + enable_ipv6: "{{ bare_metal.enable_ipv6_update | default(omit) }}" + tags: "{{ bare_metal.tags_update | default(omit) }}" + region: "{{ bare_metal.region }}" + os: "{{ bare_metal.os | default(omit) }}" + app: "{{ bare_metal.app | default(omit) }}" + image: "{{ bare_metal.image | default(omit) }}" + snapshot: "{{ bare_metal.snapshot | default(omit) }}" + vpc2s: "{{ bare_metal.vpc2s_update | default(omit) }}" + register: result +- name: verify test update bare_metal idempotence + ansible.builtin.assert: + that: + - result is not changed + - result.vultr_bare_metal.plan == bare_metal.plan_update + - result.vultr_bare_metal.region == bare_metal.region + - result.vultr_bare_metal.enable_ipv6 == bare_metal.enable_ipv6_update + # - result.vultr_bare_metal.vpc2s | selectattr('description','equalto','{{ vultr_resource_prefix }}_bare_metal_vpc2_2') | list | count == 1 diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/tests.yml new file mode 100644 index 000000000..1f061896a --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/bare_metal/tasks/tests.yml @@ -0,0 +1,52 @@ +# Copyright (c) 2023, 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.cloud.bare_metal: + label: "{{ bare_metal.label }}" + region: "{{ bare_metal.region }}" + state: absent + with_items: "{{ vultr_bare_metals }}" + loop_control: + loop_var: bare_metal + +- ansible.builtin.import_tasks: failures.yml + +# - name: setup ssh key +# vultr.cloud.ssh_key: +# name: "{{ vultr_bare_metal_ssh_key_name }}" +# ssh_key: "{{ vultr_bare_metal_ssh_key }}" + +# - name: setup vpc2s +# vultr.cloud.vpc2: +# description: "{{ item.description }}" +# ip_block: "{{ item.subnet }}" +# prefix_length: "{{ item.cidr }}" +# region: "{{ item.region }}" +# with_items: "{{ vutr_bare_metal_vpc2s }}" + +# - ansible.builtin.include_tasks: present.yml +# with_items: "{{ vultr_bare_metals }}" +# loop_control: +# loop_var: bare_metal + +# - ansible.builtin.include_tasks: absent.yml +# with_items: "{{ vultr_bare_metals }}" +# loop_control: +# loop_var: bare_metal + +# - name: cleanup ssh key +# vultr.cloud.ssh_key: +# name: "{{ vultr_bare_metal_ssh_key_name }}" +# state: absent + +# - name: cleanup vpc2s +# vultr.cloud.vpc: +# description: "{{ item.description }}" +# region: "{{ item.region }}" +# state: absent +# with_items: "{{ vutr_bare_metal_vpc2s }}" +# retries: 5 +# delay: 3 +# register: result +# until: result is not failed diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/block_storage_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/block_storage_info/tasks/tests.yml index 2f836ea09..40e599378 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/block_storage_info/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/block_storage_info/tasks/tests.yml @@ -19,7 +19,7 @@ - name: verify test gather vultr block storage volume info in check mode ansible.builtin.assert: that: - - result.vultr_block_storage_info|selectattr('label','equalto','{{ vultr_block_storage_name }}') | list | count == 1 + - result.vultr_block_storage_info|selectattr('label','equalto',vultr_block_storage_name) | list | count == 1 - name: test gather vultr block storage volume info vultr.cloud.block_storage_info: @@ -28,7 +28,7 @@ - name: verify test gather vultr block storage volume info ansible.builtin.assert: that: - - result.vultr_block_storage_info|selectattr('label','equalto','{{ vultr_block_storage_name }}') | list | count == 1 + - result.vultr_block_storage_info|selectattr('label','equalto',vultr_block_storage_name) | list | count == 1 - name: Delete the block storage volume vultr.cloud.block_storage: diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_all.yml b/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_all.yml new file mode 100644 index 000000000..b3e84c6f1 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_all.yml @@ -0,0 +1,19 @@ +- set_fact: + vultr_resource_prefix: ansible-test- + +- debug: + msg: Cleaning up resources with prefix {{ vultr_resource_prefix }} + +- ansible.builtin.import_tasks: cleanup_instance.yml +- ansible.builtin.import_tasks: cleanup_bare_metal.yml +- ansible.builtin.import_tasks: cleanup_ssh_key.yml +- ansible.builtin.import_tasks: cleanup_vpc.yml +- ansible.builtin.import_tasks: cleanup_vpc2.yml +- ansible.builtin.import_tasks: cleanup_firewall_group.yml +- ansible.builtin.import_tasks: cleanup_snapshot.yml +- ansible.builtin.import_tasks: cleanup_user.yml +- ansible.builtin.import_tasks: cleanup_dns_domain.yml +- ansible.builtin.import_tasks: cleanup_block_storage.yml +- ansible.builtin.import_tasks: cleanup_startup_script.yml +- ansible.builtin.import_tasks: cleanup_reserved_ip.yml +- ansible.builtin.import_tasks: cleanup_network.yml diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_bare_metal.yml b/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_bare_metal.yml new file mode 100644 index 000000000..21c158669 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_bare_metal.yml @@ -0,0 +1,29 @@ +--- +- name: cleanup + when: vultr_api_key + block: + - name: List bare metals + ansible.builtin.uri: + url: "{{ vultr_api_url }}/bare-metals" + headers: + Authorization: Bearer {{ vultr_api_key }} + status_code: 200 + register: res + no_log: true + + - name: Found resources + ansible.builtin.debug: + var: res.json + + - name: Remove all bare metals created by this test run + ansible.builtin.uri: + url: "{{ vultr_api_url }}/bare-metals/{{ item.id }}" + method: "DELETE" + headers: + Authorization: Bearer {{ vultr_api_key }} + status_code: 204 + when: vultr_resource_prefix in item.label + with_items: "{{ res.json.bare_metals }}" + loop_control: + label: "{{ item.label }}" + no_log: true diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_object_storage.yml b/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_object_storage.yml new file mode 100644 index 000000000..555aefaf8 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_object_storage.yml @@ -0,0 +1,29 @@ +--- +- name: cleanup + when: vultr_api_key + block: + - name: List object storages + ansible.builtin.uri: + url: "{{ vultr_api_url }}/object-storage" + headers: + Authorization: Bearer {{ vultr_api_key }} + status_code: 200 + register: res + no_log: true + + - name: Found resources + ansible.builtin.debug: + var: res.json + + - name: Remove all object storages created by this test run + ansible.builtin.uri: + url: "{{ vultr_api_url }}/object-storage/{{ item.id }}" + method: "DELETE" + headers: + Authorization: Bearer {{ vultr_api_key }} + status_code: 204 + when: vultr_resource_prefix in item.label + with_items: "{{ res.json.object_storages }}" + loop_control: + label: "{{ item.label }}" + no_log: true diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_vpc2.yml b/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_vpc2.yml new file mode 100644 index 000000000..30b002d92 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/cleanup/tasks/cleanup_vpc2.yml @@ -0,0 +1,28 @@ +--- +- name: cleanup + when: vultr_api_key + block: + - name: List vpc2s + ansible.builtin.uri: + url: "{{ vultr_api_url }}/vpc2" + headers: + Authorization: Bearer {{ vultr_api_key }} + status_code: 200 + register: res + no_log: true + + - name: Found resources + ansible.builtin.debug: + var: res.json + + - name: Remove all vpc2s created by this test run + ansible.builtin.uri: + url: "{{ vultr_api_url }}/vpc2/{{ item.id }}" + method: "DELETE" + headers: + Authorization: Bearer {{ vultr_api_key }} + status_code: 204 + when: vultr_resource_prefix in item.description + with_items: "{{ res.json.vpcs }}" + loop_control: + label: "{{ item.description }}" diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/dns_domain_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/dns_domain_info/tasks/tests.yml index f772ab637..3351f14bc 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/dns_domain_info/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/dns_domain_info/tasks/tests.yml @@ -15,7 +15,7 @@ - name: verify test gather vultr dns domain info in check mode ansible.builtin.assert: that: - - result.vultr_dns_domain_info|selectattr('domain','equalto','{{ dns_domain_name }}') | list | count == 1 + - result.vultr_dns_domain_info|selectattr('domain','equalto',dns_domain_name) | list | count == 1 - name: test gather vultr dns domain info vultr.cloud.dns_domain_info: @@ -24,4 +24,4 @@ - name: verify test gather vultr dns domain info ansible.builtin.assert: that: - - result.vultr_dns_domain_info|selectattr('domain','equalto','{{ dns_domain_name }}') | list | count == 1 + - result.vultr_dns_domain_info|selectattr('domain','equalto',dns_domain_name) | list | count == 1 diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/defaults/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/defaults/main.yml index e979dc89b..7e548fca3 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/defaults/main.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/defaults/main.yml @@ -5,11 +5,18 @@ vultr_dns_domain_name: "{{ vultr_resource_prefix }}-t3-vultr.com" vultr_dns_record_items: # Single A record - - name: test-www + - name: test-www-ip data: 10.10.10.10 ttl: 400 update_data: 10.10.10.11 - update_ttl: 200 + update_ttl: 400 + + # # Single A record + # - name: test-www-ttl + # data: 10.10.10.10 + # ttl: 400 + # update_data: 10.10.10.10 + # update_ttl: 200 # Multiple A records - name: test-www-multiple diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/create_record.yml b/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/create_record.yml index 39964c138..409c1119a 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/create_record.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/create_record.yml @@ -36,11 +36,11 @@ ansible.builtin.assert: that: - result is changed - - result.vultr_dns_record.data == "{{ item.data }}" - - result.vultr_dns_record.name == "{{ item.name | default("") }}" - - result.vultr_dns_record.type == "{{ item.record_type | default('A') }}" - - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} - - result.vultr_dns_record.priority == {{ item.priority | default(-1) }} + - result.vultr_dns_record.data == item.data + - result.vultr_dns_record.name == item.name | default('') + - result.vultr_dns_record.type == item.record_type | default('A') + - result.vultr_dns_record.ttl == item.ttl | default(300) + - result.vultr_dns_record.priority == item.priority | default(-1) - name: test create a dns record idempotence vultr.cloud.dns_record: @@ -55,8 +55,8 @@ ansible.builtin.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.type == "{{ item.record_type | default('A') }}" - - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} - - result.vultr_dns_record.priority == {{ item.priority | default(-1) }} + - result.vultr_dns_record.data == item.data + - result.vultr_dns_record.name == item.name | default('') + - result.vultr_dns_record.type == item.record_type | default('A') + - result.vultr_dns_record.ttl == item.ttl | default(300) + - result.vultr_dns_record.priority == item.priority | default(-1) diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/remove_record.yml b/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/remove_record.yml index 1207ea250..f3c33ac09 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/remove_record.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/remove_record.yml @@ -15,11 +15,11 @@ ansible.builtin.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.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(-1)) }} + - result.vultr_dns_record.data == item.update_data | default(item.data) + - result.vultr_dns_record.name == item.name | default('') + - result.vultr_dns_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(-1)) - name: test remove second dns record in check mode vultr.cloud.dns_record: @@ -36,11 +36,11 @@ ansible.builtin.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.type == "{{ item.record_type | default('A') }}" - - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} - - result.vultr_dns_record.priority == {{ item.priority | default(-1) }} + - result.vultr_dns_record.data == item.data | default(item.data) + - result.vultr_dns_record.name == item.name | default('') + - result.vultr_dns_record.type == item.record_type | default('A') + - result.vultr_dns_record.ttl == item.ttl | default(300) + - result.vultr_dns_record.priority == item.priority | default(-1) when: item.multiple is defined and item.multiple == true - name: test remove a dns record @@ -56,11 +56,11 @@ ansible.builtin.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.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(-1)) }} + - result.vultr_dns_record.data == item.update_data | default(item.data) + - result.vultr_dns_record.name == item.name | default('') + - result.vultr_dns_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(-1)) - name: test remove second dns record vultr.cloud.dns_record: @@ -76,11 +76,11 @@ ansible.builtin.assert: that: - result is changed - - result.vultr_dns_record.data == "{{ item.data }}" - - result.vultr_dns_record.name == "{{ item.name | default("") }}" - - result.vultr_dns_record.type == "{{ item.record_type | default('A') }}" - - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} - - result.vultr_dns_record.priority == {{ item.priority | default(-1) }} + - result.vultr_dns_record.data == item.data + - result.vultr_dns_record.name == item.name | default('') + - result.vultr_dns_record.type == item.record_type | default('A') + - result.vultr_dns_record.ttl == item.ttl | default(300) + - result.vultr_dns_record.priority == item.priority | default(-1) when: item.multiple is defined and item.multiple == true - name: test remove a dns record idempotence diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/update_record.yml b/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/update_record.yml index f79beccf5..ad53333cb 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/update_record.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/dns_record/tasks/update_record.yml @@ -16,11 +16,11 @@ ansible.builtin.assert: that: - result is changed - - result.vultr_dns_record.data == "{{ item.data }}" - - result.vultr_dns_record.name == "{{ item.name | default("") }}" - - result.vultr_dns_record.type == "{{ item.record_type | default('A') }}" - - result.vultr_dns_record.ttl == {{ item.ttl | default(300) }} - - result.vultr_dns_record.priority == {{ item.priority | default(-1) }} + - result.vultr_dns_record.data == item.data + - result.vultr_dns_record.name == item.name | default('') + - result.vultr_dns_record.type == item.record_type | default('A') + - result.vultr_dns_record.ttl == item.ttl | default(300) + - result.vultr_dns_record.priority == item.priority | default(-1) when: item.multiple is undefined or item.multiple == false - name: verify test add another dns record in check mode ansible.builtin.assert: @@ -43,11 +43,11 @@ ansible.builtin.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.type == "{{ item.record_type | default('A') }}" - - result.vultr_dns_record.priority == {{ item.update_priority | default(-1) }} + - 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.type == item.record_type | default('A') + - result.vultr_dns_record.priority == item.update_priority | default(-1) - name: test update or add another dns record idempotence vultr.cloud.dns_record: @@ -63,8 +63,8 @@ ansible.builtin.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.type == "{{ item.record_type | default('A') }}" - - result.vultr_dns_record.priority == {{ item.update_priority | default(-1) }} + - 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.type == item.record_type | default('A') + - result.vultr_dns_record.priority == item.update_priority | default(-1) diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_group_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_group_info/tasks/tests.yml index 390150418..866d9ed74 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_group_info/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_group_info/tasks/tests.yml @@ -17,7 +17,7 @@ - name: verify test gather vultr firewall group info in check mode ansible.builtin.assert: that: - - result.vultr_firewall_group_info|selectattr('description','equalto','{{ firewall_group_name }}') | list | count == 1 + - result.vultr_firewall_group_info|selectattr('description','equalto',firewall_group_name) | list | count == 1 - name: test gather vultr firewall group info vultr.cloud.firewall_group_info: @@ -26,7 +26,7 @@ - name: verify test gather vultr firewall group info ansible.builtin.assert: that: - - result.vultr_firewall_group_info|selectattr('description','equalto','{{ firewall_group_name }}') | list | count == 1 + - result.vultr_firewall_group_info|selectattr('description','equalto',firewall_group_name) | list | count == 1 - name: Delete the firewall group vultr.cloud.firewall_group: diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/defaults/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/defaults/main.yml index 7e96b1f83..f3695f8b3 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/defaults/main.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/defaults/main.yml @@ -33,6 +33,9 @@ vultr_firewall_rules: protocol: icmp subnet: "0.0.0.0" subnet_size: 0 + # Port should be ignored, but should show a warning + port: "7" + port_assert: "" - notes: web app port: "8000:8080" diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/tasks/rule_absent.yml b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/tasks/rule_absent.yml index a8fe6f60a..4f16e2a11 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/tasks/rule_absent.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/tasks/rule_absent.yml @@ -19,11 +19,11 @@ that: - result is changed - result.vultr_firewall_rule.action == "accept" - - result.vultr_firewall_rule.protocol == "{{ rule.protocol | default('tcp') }}" - - result.vultr_firewall_rule.port == "{{ rule.port | default('') }}" - - result.vultr_firewall_rule.subnet == "{{ rule.subnet | default('') }}" - - result.vultr_firewall_rule.subnet_size == {{ rule.subnet_size | default(0) }} - - result.vultr_firewall_rule.ip_type == "{{ rule.ip_type | default('v4') }}" + - result.vultr_firewall_rule.protocol == rule.protocol | default('tcp') + - result.vultr_firewall_rule.port == rule.port_assert | default(rule.port | default('')) + - result.vultr_firewall_rule.subnet == rule.subnet | default('') + - result.vultr_firewall_rule.subnet_size == rule.subnet_size | default(0) + - result.vultr_firewall_rule.ip_type == rule.ip_type | default('v4') - name: test absent firewall rule vultr.cloud.firewall_rule: @@ -40,11 +40,11 @@ that: - result is changed - result.vultr_firewall_rule.action == "accept" - - result.vultr_firewall_rule.protocol == "{{ rule.protocol | default('tcp') }}" - - result.vultr_firewall_rule.port == "{{ rule.port | default('') }}" - - result.vultr_firewall_rule.subnet == "{{ rule.subnet | default('') }}" - - result.vultr_firewall_rule.subnet_size == {{ rule.subnet_size | default(0) }} - - result.vultr_firewall_rule.ip_type == "{{ rule.ip_type | default('v4') }}" + - result.vultr_firewall_rule.protocol == rule.protocol | default('tcp') + - result.vultr_firewall_rule.port == rule.port_assert | default(rule.port | default('')) + - result.vultr_firewall_rule.subnet == rule.subnet | default('') + - result.vultr_firewall_rule.subnet_size == rule.subnet_size | default(0) + - result.vultr_firewall_rule.ip_type == rule.ip_type | default('v4') - name: test absent firewall rule idempotence vultr.cloud.firewall_rule: diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/tasks/rule_present.yml b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/tasks/rule_present.yml index 9093b6aaf..f6ba9c4e4 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/tasks/rule_present.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule/tasks/rule_present.yml @@ -34,11 +34,11 @@ that: - result is changed - result.vultr_firewall_rule.action == "accept" - - result.vultr_firewall_rule.protocol == "{{ rule.protocol | default('tcp') }}" - - result.vultr_firewall_rule.port == "{{ rule.port | default('') }}" - - result.vultr_firewall_rule.subnet == "{{ rule.subnet | default('') }}" - - result.vultr_firewall_rule.subnet_size == {{ rule.subnet_size | default(0) }} - - result.vultr_firewall_rule.ip_type == "{{ rule.ip_type | default('v4') }}" + - result.vultr_firewall_rule.protocol == rule.protocol | default('tcp') + - result.vultr_firewall_rule.port == rule.port_assert | default(rule.port | default('')) + - result.vultr_firewall_rule.subnet == rule.subnet | default('') + - result.vultr_firewall_rule.subnet_size == rule.subnet_size | default(0) + - result.vultr_firewall_rule.ip_type == rule.ip_type | default('v4') - name: test create firewall rule idempotence vultr.cloud.firewall_rule: @@ -55,8 +55,8 @@ that: - result is not changed - result.vultr_firewall_rule.action == "accept" - - result.vultr_firewall_rule.protocol == "{{ rule.protocol | default('tcp') }}" - - result.vultr_firewall_rule.port == "{{ rule.port | default('') }}" - - result.vultr_firewall_rule.subnet == "{{ rule.subnet | default('') }}" - - result.vultr_firewall_rule.subnet_size == {{ rule.subnet_size | default(0) }} - - result.vultr_firewall_rule.ip_type == "{{ rule.ip_type | default('v4') }}" + - result.vultr_firewall_rule.protocol == rule.protocol | default('tcp') + - result.vultr_firewall_rule.port == rule.port_assert | default(rule.port | default('')) + - result.vultr_firewall_rule.subnet == rule.subnet | default('') + - result.vultr_firewall_rule.subnet_size == rule.subnet_size | default(0) + - result.vultr_firewall_rule.ip_type == rule.ip_type | default('v4') diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule_info/tasks/tests.yml index 96bca9803..a8cdf0eb0 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule_info/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/firewall_rule_info/tasks/tests.yml @@ -28,7 +28,7 @@ - name: verify test gather vultr firewall rule info in check mode ansible.builtin.assert: that: - - result.vultr_firewall_rule_info|selectattr('notes','equalto','{{ firewall_group_name }}') | list | count == 1 + - result.vultr_firewall_rule_info|selectattr('notes','equalto',firewall_group_name) | list | count == 1 - name: test gather vultr firewall rule info vultr.cloud.firewall_rule_info: @@ -37,7 +37,7 @@ - name: verify test gather vultr firewall rule info ansible.builtin.assert: that: - - result.vultr_firewall_rule_info|selectattr('notes','equalto','{{ firewall_group_name }}') | list | count == 1 + - result.vultr_firewall_rule_info|selectattr('notes','equalto',firewall_group_name) | list | count == 1 - name: Delete the firewall group vultr.cloud.firewall_group: diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/instance/defaults/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/instance/defaults/main.yml index 6683b5e85..dd280e9cf 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/instance/defaults/main.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/instance/defaults/main.yml @@ -7,6 +7,10 @@ vultr_instance_ssh_key: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEAyWYItY+3w5b8PdGRoz0 vutr_instance_vpcs: - description: "{{ vultr_resource_prefix }}_instance_vpc_1" + v4_subnet: 192.168.24.0 + v4_subnet_mask: 24 + region: ewr + - description: "{{ vultr_resource_prefix }}_instance_vpc_1" v4_subnet: 192.168.42.0 v4_subnet_mask: 24 region: ams @@ -42,13 +46,14 @@ vultr_instances: - three - four region: ams - os: Debian 11 x64 (bullseye) + os: Debian 12 x64 (bookworm) backups: true backups_update: false ddos_protection: true ddos_protection_update: false enable_ipv6: false enable_ipv6_update: true + user_scheme: limited vpcs: - "{{ vultr_resource_prefix }}_instance_vpc_1" - "{{ vultr_resource_prefix }}_instance_vpc_2" diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/instance/tasks/failures.yml b/ansible_collections/vultr/cloud/tests/integration/targets/instance/tasks/failures.yml index f22616901..3ce2c9e18 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/instance/tasks/failures.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/instance/tasks/failures.yml @@ -52,4 +52,4 @@ ansible.builtin.assert: that: - result is failed - - '"VPCs not found: does-not-exist" in result.msg' + - '"VPCs (v1) not found: does-not-exist" in result.msg' diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/instance/tasks/present.yml b/ansible_collections/vultr/cloud/tests/integration/targets/instance/tasks/present.yml index 004a9c732..b82e1226f 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/instance/tasks/present.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/instance/tasks/present.yml @@ -46,6 +46,7 @@ image: "{{ instance.image | default(omit) }}" snapshot: "{{ instance.snapshot | default(omit) }}" vpcs: "{{ instance.vpcs | default(omit) }}" + user_scheme: "{{ instance.user_scheme | default(omit) }}" register: result - name: verify test create instance ansible.builtin.assert: @@ -53,12 +54,13 @@ - result is changed - result.vultr_instance.plan == instance.plan - result.vultr_instance.region == instance.region - - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups else 'disabled' }}'" + # - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups else 'disabled' }}'" - result.vultr_instance.ddos_protection == instance.ddos_protection - result.vultr_instance.enable_ipv6 == instance.enable_ipv6 - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_1') | list | count == 1 - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_2') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_1') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_2') | list | count == 1 - result.vultr_instance.vpcs | list | count == 2 + - result.vultr_instance.user_scheme == instance.user_scheme | default('root') - name: test create instance idempotence vultr.cloud.instance: @@ -78,6 +80,7 @@ image: "{{ instance.image | default(omit) }}" snapshot: "{{ instance.snapshot | default(omit) }}" vpcs: "{{ instance.vpcs | default(omit) }}" + user_scheme: "{{ instance.user_scheme | default(omit) }}" register: result - name: verify test create instance idempotence ansible.builtin.assert: @@ -85,12 +88,13 @@ - result is not changed - result.vultr_instance.plan == instance.plan - result.vultr_instance.region == instance.region - - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups else 'disabled' }}'" + # - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups else 'disabled' }}'" - result.vultr_instance.ddos_protection == instance.ddos_protection - result.vultr_instance.enable_ipv6 == instance.enable_ipv6 - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_1') | list | count == 1 - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_2') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_1') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_2') | list | count == 1 - result.vultr_instance.vpcs | list | count == 2 + - result.vultr_instance.user_scheme == instance.user_scheme | default('root') - name: test update instance in check mode vultr.cloud.instance: @@ -110,6 +114,7 @@ image: "{{ instance.image | default(omit) }}" snapshot: "{{ instance.snapshot | default(omit) }}" vpcs: "{{ instance.vpcs_update | default(omit) }}" + user_scheme: "{{ instance.user_scheme | default(omit) }}" register: result check_mode: true - name: verify test update instance in check mode @@ -118,12 +123,13 @@ - result is changed - result.vultr_instance.plan == instance.plan - result.vultr_instance.region == instance.region - - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups else 'disabled' }}'" + # - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups else 'disabled' }}'" - result.vultr_instance.ddos_protection == instance.ddos_protection - result.vultr_instance.enable_ipv6 == instance.enable_ipv6 - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_1') | list | count == 1 - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_2') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_1') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_2') | list | count == 1 - result.vultr_instance.vpcs | list | count == 2 + - result.vultr_instance.user_scheme == instance.user_scheme | default('root') - name: test update instance vultr.cloud.instance: @@ -143,6 +149,7 @@ image: "{{ instance.image | default(omit) }}" snapshot: "{{ instance.snapshot | default(omit) }}" vpcs: "{{ instance.vpcs_update | default(omit) }}" + user_scheme: "{{ instance.user_scheme | default(omit) }}" register: result - name: verify test update instance ansible.builtin.assert: @@ -150,12 +157,13 @@ - result is changed - result.vultr_instance.plan == instance.plan_update - result.vultr_instance.region == instance.region - - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups_update else 'disabled' }}'" + # - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups else 'disabled' }}'" - result.vultr_instance.ddos_protection == instance.ddos_protection_update - result.vultr_instance.enable_ipv6 == instance.enable_ipv6_update - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_1') | list | count == 1 - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_3') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_1') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_3') | list | count == 1 - result.vultr_instance.vpcs | list | count == 2 + - result.vultr_instance.user_scheme == instance.user_scheme | default('root') - name: test update instance idempotence vultr.cloud.instance: @@ -175,6 +183,7 @@ image: "{{ instance.image | default(omit) }}" snapshot: "{{ instance.snapshot | default(omit) }}" vpcs: "{{ instance.vpcs_update | default(omit) }}" + user_scheme: "{{ instance.user_scheme | default(omit) }}" register: result - name: verify test update instance idempotence ansible.builtin.assert: @@ -182,9 +191,10 @@ - result is not changed - result.vultr_instance.plan == instance.plan_update - result.vultr_instance.region == instance.region - - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups_update else 'disabled' }}'" + # - "result.vultr_instance.backups == '{{ 'enabled' if instance.backups else 'disabled' }}'" - result.vultr_instance.ddos_protection == instance.ddos_protection_update - result.vultr_instance.enable_ipv6 == instance.enable_ipv6_update - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_1') | list | count == 1 - - result.vultr_instance.vpcs | selectattr('description','equalto','{{ vultr_resource_prefix }}_instance_vpc_3') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_1') | list | count == 1 + - result.vultr_instance.vpcs | selectattr('description','equalto',vultr_resource_prefix ~ '_instance_vpc_3') | list | count == 1 - result.vultr_instance.vpcs | list | count == 2 + - result.vultr_instance.user_scheme == instance.user_scheme | default('root') diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/instance_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/instance_info/tasks/tests.yml index 204d071af..511d36dee 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/instance_info/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/instance_info/tasks/tests.yml @@ -21,8 +21,8 @@ - name: verify test gather vultr instance info in check mode ansible.builtin.assert: that: - - result.vultr_instance_info|selectattr('label','search','^{{ vultr_resource_prefix }}') | list | count == 2 - - result.vultr_instance_info|selectattr('label','equalto','{{ vultr_resource_prefix }}_info1') | list | count == 1 + - result.vultr_instance_info|selectattr('label','search','^' ~ vultr_resource_prefix) | list | count == 2 + - result.vultr_instance_info|selectattr('label','equalto',vultr_resource_prefix ~ '_info1') | list | count == 1 - name: test gather vultr instance info vultr.cloud.instance_info: @@ -30,8 +30,8 @@ - name: verify test gather vultr instance info ansible.builtin.assert: that: - - result.vultr_instance_info|selectattr('label','search','^{{ vultr_resource_prefix }}') | list | count == 2 - - result.vultr_instance_info|selectattr('label','equalto','{{ vultr_resource_prefix }}_info1') | list | count == 1 + - result.vultr_instance_info|selectattr('label','search','^' ~ vultr_resource_prefix) | list | count == 2 + - result.vultr_instance_info|selectattr('label','equalto',vultr_resource_prefix ~ '_info1') | list | count == 1 - name: test gather vultr instance info filter region vultr.cloud.instance_info: @@ -40,7 +40,7 @@ - name: verify test gather vultr instance info filter region ansible.builtin.assert: that: - - result.vultr_instance_info|selectattr('label','search','^{{ vultr_resource_prefix }}') | list | count == 1 + - result.vultr_instance_info|selectattr('label','search','^' ~ vultr_resource_prefix) | list | count == 1 - name: test gather vultr instance info filter label vultr.cloud.instance_info: @@ -49,8 +49,8 @@ - name: verify test gather vultr instance info ansible.builtin.assert: that: - - result.vultr_instance_info|selectattr('label','search','^{{ vultr_resource_prefix }}') | list | count == 1 - - result.vultr_instance_info|selectattr('label','equalto','{{ vultr_resource_prefix }}_info2') | list | count == 1 + - result.vultr_instance_info|selectattr('label','search','^' ~ vultr_resource_prefix) | list | count == 1 + - result.vultr_instance_info|selectattr('label','equalto',vultr_resource_prefix ~ '_info2') | list | count == 1 - name: cleanup vultr.cloud.instance: diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/aliases b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/aliases new file mode 100644 index 000000000..c749ce7ca --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/aliases @@ -0,0 +1,3 @@ +cloud/vultr +needs/target/common +needs/target/cleanup diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/defaults/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/defaults/main.yml new file mode 100644 index 000000000..8c71c3d37 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/defaults/main.yml @@ -0,0 +1,4 @@ +--- +vultr_object_storage_name: "{{ vultr_resource_prefix }}-volume" +vultr_object_storage_cluster1: del1.vultrobjects.com +vultr_object_storage_cluster2: ams1.vultrobjects.com diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/tasks/failures.yml b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/tasks/failures.yml new file mode 100644 index 000000000..3b2a3066a --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/tasks/failures.yml @@ -0,0 +1,10 @@ +--- +- name: test fail if missing required + vultr.cloud.object_storage: + register: result + ignore_errors: true +- name: verify test fail if missing required + ansible.builtin.assert: + that: + - result is failed + - 'result.msg == "missing required arguments: cluster, label"' diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/tasks/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/tasks/main.yml new file mode 100644 index 000000000..0e2f60bf0 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- block: + - ansible.builtin.import_tasks: failures.yml + - ansible.builtin.import_tasks: tests.yml + always: + - ansible.builtin.import_role: + name: cleanup + tasks_from: cleanup_object_storage diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/tasks/tests.yml new file mode 100644 index 000000000..bf73498c6 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/object_storage/tasks/tests.yml @@ -0,0 +1,93 @@ +# Copyright (c) 2024, 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 create object storage in check mode + vultr.cloud.object_storage: + label: "{{ vultr_object_storage_name }}" + cluster: "{{ vultr_object_storage_cluster1 }}" + register: result + check_mode: true +- name: verify test create object storage in check mode + ansible.builtin.assert: + that: + - result is changed + +- name: test create object storage cluster 1 + vultr.cloud.object_storage: + label: "{{ vultr_object_storage_name }}" + cluster: "{{ vultr_object_storage_cluster1 }}" + register: result +- name: verify test create object storage + ansible.builtin.assert: + that: + - result is changed + - result.vultr_object_storage.label == vultr_object_storage_name + - result.vultr_object_storage.s3_hostname == vultr_object_storage_cluster1 + +- name: test create object storage cluster 2 + vultr.cloud.object_storage: + label: "{{ vultr_object_storage_name }}" + cluster: "{{ vultr_object_storage_cluster2 }}" + register: result +- name: verify test create object storage + ansible.builtin.assert: + that: + - result is changed + - result.vultr_object_storage.label == vultr_object_storage_name + - result.vultr_object_storage.s3_hostname == vultr_object_storage_cluster2 + +- name: test create object storage idempotence + vultr.cloud.object_storage: + label: "{{ vultr_object_storage_name }}" + cluster: "{{ vultr_object_storage_cluster1 }}" + register: result +- name: verify test create object storage idempotence + ansible.builtin.assert: + that: + - result is not changed + - result.vultr_object_storage.label == vultr_object_storage_name + - result.vultr_object_storage.s3_hostname == vultr_object_storage_cluster1 + +- name: test delete object storage in check mode + vultr.cloud.object_storage: + label: "{{ vultr_object_storage_name }}" + cluster: "{{ vultr_object_storage_cluster1 }}" + state: absent + check_mode: true + register: result +- name: verify test delete object storage in check mode + ansible.builtin.assert: + that: + - result is changed + - result.vultr_object_storage.label == vultr_object_storage_name + - result.vultr_object_storage.s3_hostname == vultr_object_storage_cluster1 + +- name: test delete object storage + vultr.cloud.object_storage: + label: "{{ vultr_object_storage_name }}" + cluster: "{{ vultr_object_storage_cluster1 }}" + state: absent + register: result +- name: verify test delete object storage + ansible.builtin.assert: + that: + - result is changed + - result.vultr_object_storage.label == vultr_object_storage_name + - result.vultr_object_storage.s3_hostname == vultr_object_storage_cluster1 + +- name: test delete object storage idempotence + vultr.cloud.object_storage: + label: "{{ vultr_object_storage_name }}" + cluster: "{{ vultr_object_storage_cluster1 }}" + state: absent + register: result +- name: verify test delete object storage idempotence + ansible.builtin.assert: + that: + - result is not changed + +- name: cleanup object storage cluster 2 + vultr.cloud.object_storage: + label: "{{ vultr_object_storage_name }}" + cluster: "{{ vultr_object_storage_cluster2 }}" + state: absent diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/aliases b/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/aliases index e69de29bb..c749ce7ca 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/aliases +++ b/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/aliases @@ -0,0 +1,3 @@ +cloud/vultr +needs/target/common +needs/target/cleanup diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/defaults/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/defaults/main.yml index 60634dbeb..e88833c62 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/defaults/main.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/defaults/main.yml @@ -1,9 +1,11 @@ # Copyright (c) 2021, René Moser <mail@renemoser.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- -vultr_reserved_ip_name: "{{ vultr_resource_prefix }}-ip" +vultr_reserved_ip_name: "{{ vultr_resource_prefix }}_reserved_ip" +vultr_reserved_ip_region: ams -# TODO: topic of changes -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_instance: + label: "{{ vultr_resource_prefix }}_reserved_ip" + plan: vc2-1c-1gb + region: "{{ vultr_reserved_ip_region }}" + os: Debian 12 x64 (bookworm) diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/tasks/tests.yml index a46b56366..a8f5986be 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/reserved_ip/tasks/tests.yml @@ -5,7 +5,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" state: absent register: result - name: verify setup @@ -23,20 +23,18 @@ - result is failed - 'result.msg == "missing required arguments: ip_type, label, region"' -# TODO: topic of changes -- name: setup create the server - ngine_io.vultr.vultr_server: - name: "{{ vultr_server_name }}" - os: "{{ vultr_server_os }}" - plan: "{{ vultr_server_plan }}" - region: New Jersey - register: server +- name: setup instance + vultr.cloud.instance: + label: "{{ vultr_instance.label }}" + os: "{{ vultr_instance.os }}" + plan: "{{ vultr_instance.plan }}" + region: "{{ vultr_instance.region }}" - name: test create reserved ip in check mode vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" register: result check_mode: true - name: verify test create reserved ip in check mode @@ -48,7 +46,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" register: result - name: verify test create reserved ip ansible.builtin.assert: @@ -63,7 +61,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" register: result - name: verify test create reserved ip idempotence ansible.builtin.assert: @@ -78,8 +76,8 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr - instance_name: "{{ vultr_server_name }}" + region: "{{ vultr_reserved_ip_region }}" + instance_name: "{{ vultr_instance.label }}" register: result check_mode: true - name: verify test detach instance of reserved ip in check mode @@ -95,8 +93,8 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr - instance_name: "{{ vultr_server_name }}" + region: "{{ vultr_reserved_ip_region }}" + instance_name: "{{ vultr_instance.label }}" register: result - name: verify test attach instance of reserved ip ansible.builtin.assert: @@ -111,8 +109,8 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr - instance_name: "{{ vultr_server_name }}" + region: "{{ vultr_reserved_ip_region }}" + instance_name: "{{ vultr_instance.label }}" register: result - name: verify test attach instance of reserved ip idempotence ansible.builtin.assert: @@ -127,7 +125,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" register: result - name: verify test test ignore instance attached reserved ip idempotence ansible.builtin.assert: @@ -142,7 +140,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" instance_id: "" register: result check_mode: true @@ -159,7 +157,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" instance_id: "" register: result - name: verify test detach instance of reserved ip @@ -175,7 +173,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" instance_id: "" register: result - name: verify test detach instance of reserved ip idempotence @@ -191,7 +189,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" state: absent register: result check_mode: true @@ -208,7 +206,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" state: absent register: result - name: verify test absent reserved ip @@ -225,7 +223,7 @@ vultr.cloud.reserved_ip: label: "{{ vultr_reserved_ip_name }}" ip_type: v4 - region: ewr + region: "{{ vultr_reserved_ip_region }}" state: absent register: result - name: verify test absent reserved ip idempotence @@ -233,8 +231,8 @@ that: - result is not changed -# TODO: topic of changes -- name: cleanup the server - ngine_io.vultr.vultr_server: - name: "{{ vultr_server_name }}" +- name: cleanup instance + vultr.cloud.instance: + label: "{{ vultr_instance.label }}" + region: "{{ vultr_instance.region }}" state: absent diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/snapshot_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/snapshot_info/tasks/tests.yml index fe7a195ce..2168262dc 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/snapshot_info/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/snapshot_info/tasks/tests.yml @@ -17,7 +17,7 @@ - name: verify test gather vultr snapshot info in check mode ansible.builtin.assert: that: - - result.vultr_snapshot_info|selectattr('description','equalto','{{ vultr_snapshot_description }}') | list | count == 1 + - result.vultr_snapshot_info|selectattr('description','equalto',vultr_snapshot_description) | list | count == 1 - name: test gather snapshot info vultr.cloud.snapshot_info: @@ -26,7 +26,7 @@ - name: verify test gather vultr snapshot info ansible.builtin.assert: that: - - result.vultr_snapshot_info|selectattr('description','equalto','{{ vultr_snapshot_description }}') | list | count == 1 + - result.vultr_snapshot_info|selectattr('description','equalto',vultr_snapshot_description) | list | count == 1 - name: Delete the snapshot vultr.cloud.snapshot: diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/ssh_key_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/ssh_key_info/tasks/tests.yml index 63ce48ee0..4b35406d2 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/ssh_key_info/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/ssh_key_info/tasks/tests.yml @@ -9,8 +9,8 @@ - name: verify test get vultr ssh key infos in check mode ansible.builtin.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 + - 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.cloud.ssh_key: @@ -25,8 +25,8 @@ - name: verify test get vultr ssh key infos in check mode ansible.builtin.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 + - 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.cloud.ssh_key_info: @@ -35,8 +35,8 @@ - name: verify test get vultr ssh key infos ansible.builtin.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 + - 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.cloud.ssh_key: diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/startup_script_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/startup_script_info/tasks/tests.yml index 730df6d71..ef142465f 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/startup_script_info/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/startup_script_info/tasks/tests.yml @@ -18,7 +18,7 @@ - name: verify test gather vultr startup script info in check mode ansible.builtin.assert: that: - - result.vultr_startup_script_info|selectattr('name','equalto','{{ startup_script_name }}') | list | count == 1 + - result.vultr_startup_script_info|selectattr('name','equalto',startup_script_name) | list | count == 1 - name: test gather vultr startup script info vultr.cloud.startup_script_info: @@ -27,7 +27,7 @@ - name: verify test gather vultr startup script info ansible.builtin.assert: that: - - result.vultr_startup_script_info|selectattr('name','equalto','{{ startup_script_name }}') | list | count == 1 + - result.vultr_startup_script_info|selectattr('name','equalto',startup_script_name) | list | count == 1 - name: Delete the script vultr.cloud.startup_script: diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc/defaults/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc/defaults/main.yml index 83923ffe8..524dbd470 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/vpc/defaults/main.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc/defaults/main.yml @@ -3,3 +3,4 @@ vultr_vpc_description: "{{ vultr_resource_prefix }}_vpc" vultr_vpc_v4_subnet: 192.168.42.0 vultr_vpc_v4_subnet_mask: 24 vultr_vpc_region: ewr +vultr_vpc_region_2: ams diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc/tasks/tests.yml index 8ed2dfdc7..28793a7e2 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/vpc/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc/tasks/tests.yml @@ -72,9 +72,38 @@ - result.vultr_vpc.v4_subnet == vultr_vpc_v4_subnet - result.vultr_vpc.v4_subnet_mask == vultr_vpc_v4_subnet_mask +- name: test create vpc in diff region but same description + vultr.cloud.vpc: + description: "{{ vultr_vpc_description }}" + v4_subnet: "{{ vultr_vpc_v4_subnet }}" + v4_subnet_mask: "{{ vultr_vpc_v4_subnet_mask }}" + region: "{{ vultr_vpc_region_2 }}" + register: result +- name: verify test create vpc in diff region but same description + ansible.builtin.assert: + that: + - result is changed + - result.vultr_vpc.description == vultr_vpc_description + - result.vultr_vpc.region == vultr_vpc_region_2 + - result.vultr_vpc.v4_subnet == vultr_vpc_v4_subnet + - result.vultr_vpc.v4_subnet_mask == vultr_vpc_v4_subnet_mask + +- name: test destroy vpc having 2 vpcs with same description distinqush region + vultr.cloud.vpc: + description: "{{ vultr_vpc_description }}" + state: absent + register: result + ignore_errors: true + check_mode: true +- name: verify test destroy vpc having 2 vpcs with same description distinqush region + ansible.builtin.assert: + that: + - result is failed + - name: test destroy vpc in check mode vultr.cloud.vpc: description: "{{ vultr_vpc_description }}" + region: "{{ vultr_vpc_region }}" state: absent register: result check_mode: true @@ -90,6 +119,7 @@ - name: test destroy vpc vultr.cloud.vpc: description: "{{ vultr_vpc_description }}" + region: "{{ vultr_vpc_region }}" state: absent register: result - name: verify test destroy vpc @@ -104,9 +134,21 @@ - name: test destroy an existing vpc idempotence vultr.cloud.vpc: description: "{{ vultr_vpc_description }}" + region: "{{ vultr_vpc_region }}" state: absent register: result - name: verify test destroy an existing vpc idempotence ansible.builtin.assert: that: - result is not changed + +- name: cleanup vpc in diff region + vultr.cloud.vpc: + description: "{{ vultr_vpc_description }}" + region: "{{ vultr_vpc_region_2 }}" + state: absent + register: result +- name: verify test cleanup vpc in diff region + ansible.builtin.assert: + that: + - result is changed diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/aliases b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/aliases new file mode 100644 index 000000000..c749ce7ca --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/aliases @@ -0,0 +1,3 @@ +cloud/vultr +needs/target/common +needs/target/cleanup diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/defaults/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/defaults/main.yml new file mode 100644 index 000000000..0a5d68330 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/defaults/main.yml @@ -0,0 +1,5 @@ +--- +vultr_vpc2_description: "{{ vultr_resource_prefix }}_vpc2" +vultr_vpc2_subnet: 192.168.42.0 +vultr_vpc2_cidr: 24 +vultr_vpc2_region: ewr diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/meta/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/meta/main.yml new file mode 100644 index 000000000..2083f0e12 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/tasks/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/tasks/main.yml new file mode 100644 index 000000000..df0dcb3b0 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- block: + - ansible.builtin.import_tasks: tests.yml + always: + - ansible.builtin.import_role: + name: cleanup + tasks_from: cleanup_vpc2 diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/tasks/tests.yml new file mode 100644 index 000000000..5a3bb60bf --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2/tasks/tests.yml @@ -0,0 +1,112 @@ +# Copyright (c) 2023, 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.cloud.vpc2: + description: "{{ vultr_vpc2_description }}" + state: absent + +- name: test fail if missing description + vultr.cloud.vpc2: + register: result + ignore_errors: true +- name: verify test fail if missing description + ansible.builtin.assert: + that: + - result is failed + - 'result.msg == "missing required arguments: description"' + +- name: test fail if missing params for state=present + vultr.cloud.vpc2: + description: "{{ vultr_vpc2_description }}" + register: result + ignore_errors: true +- name: verify fail if missing params for state=present + ansible.builtin.assert: + that: + - result is failed + - '"state is present but all of the following are missing:" in result.msg' + +- name: test create vpc2 in check mode + vultr.cloud.vpc2: + description: "{{ vultr_vpc2_description }}" + ip_block: "{{ vultr_vpc2_subnet }}" + prefix_length: "{{ vultr_vpc2_cidr }}" + region: "{{ vultr_vpc2_region }}" + register: result + check_mode: true +- name: verify test create server in check mode + ansible.builtin.assert: + that: + - result is changed + +- name: test create vpc + vultr.cloud.vpc2: + description: "{{ vultr_vpc2_description }}" + ip_block: "{{ vultr_vpc2_subnet }}" + prefix_length: "{{ vultr_vpc2_cidr }}" + region: "{{ vultr_vpc2_region }}" + register: result +- name: verify test create vpc + ansible.builtin.assert: + that: + - result is changed + - result.vultr_vpc2.description == vultr_vpc2_description + - result.vultr_vpc2.region == vultr_vpc2_region + - result.vultr_vpc2.ip_block == vultr_vpc2_subnet + - result.vultr_vpc2.prefix_length == vultr_vpc2_cidr + +- name: test create vpc2 idempotence + vultr.cloud.vpc2: + description: "{{ vultr_vpc2_description }}" + ip_block: "{{ vultr_vpc2_subnet }}" + prefix_length: "{{ vultr_vpc2_cidr }}" + region: "{{ vultr_vpc2_region }}" + register: result +- name: verify test vpc2 idempotence + ansible.builtin.assert: + that: + - result is not changed + - result.vultr_vpc2.description == vultr_vpc2_description + - result.vultr_vpc2.region == vultr_vpc2_region + - result.vultr_vpc2.ip_block == vultr_vpc2_subnet + - result.vultr_vpc2.prefix_length == vultr_vpc2_cidr + +- name: test destroy vpc2 in check mode + vultr.cloud.vpc2: + description: "{{ vultr_vpc2_description }}" + state: absent + register: result + check_mode: true +- name: verify test destroy vpc2 in check mode + ansible.builtin.assert: + that: + - result is changed + - result.vultr_vpc2.description == vultr_vpc2_description + - result.vultr_vpc2.region == vultr_vpc2_region + - result.vultr_vpc2.ip_block == vultr_vpc2_subnet + - result.vultr_vpc2.prefix_length == vultr_vpc2_cidr + +- name: test destroy vpc + vultr.cloud.vpc2: + description: "{{ vultr_vpc2_description }}" + state: absent + register: result +- name: verify test destroy vpc + ansible.builtin.assert: + that: + - result is changed + - result.vultr_vpc2.description == vultr_vpc2_description + - result.vultr_vpc2.region == vultr_vpc2_region + - result.vultr_vpc2.ip_block == vultr_vpc2_subnet + - result.vultr_vpc2.prefix_length == vultr_vpc2_cidr + +- name: test destroy an existing vpc2 idempotence + vultr.cloud.vpc2: + description: "{{ vultr_vpc2_description }}" + state: absent + register: result +- name: verify test destroy an existing vpc2 idempotence + ansible.builtin.assert: + that: + - result is not changed diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/aliases b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/aliases new file mode 100644 index 000000000..c749ce7ca --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/aliases @@ -0,0 +1,3 @@ +cloud/vultr +needs/target/common +needs/target/cleanup diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/defaults/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/defaults/main.yml new file mode 100644 index 000000000..2fb56613c --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/defaults/main.yml @@ -0,0 +1,5 @@ +--- +vultr_vpc2_description: "{{ vultr_resource_prefix }}_vpc2_info" +vultr_vpc2_subnet: 192.168.23.0 +vultr_vpc2_cidr: 24 +vultr_vpc2_region: ewr diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/meta/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/meta/main.yml new file mode 100644 index 000000000..2083f0e12 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/tasks/main.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/tasks/main.yml new file mode 100644 index 000000000..df0dcb3b0 --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- block: + - ansible.builtin.import_tasks: tests.yml + always: + - ansible.builtin.import_role: + name: cleanup + tasks_from: cleanup_vpc2 diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/tasks/tests.yml new file mode 100644 index 000000000..78acf473a --- /dev/null +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc2_info/tasks/tests.yml @@ -0,0 +1,36 @@ +# Copyright (c) 2023, 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 gather vpc2 info - empty resources + vultr.cloud.vpc2_info: + +- name: Create the vpc2 + vultr.cloud.vpc2: + description: "{{ vultr_vpc2_description }}" + ip_block: "{{ vultr_vpc2_subnet }}" + prefix_length: "{{ vultr_vpc2_cidr }}" + region: "{{ vultr_vpc2_region }}" + +- name: test gather vpc2 info in check mode + vultr.cloud.vpc2_info: + check_mode: true + register: result + +- name: verify test gather vultr vpc2 info in check mode + ansible.builtin.assert: + that: + - result.vultr_vpc2_info|selectattr('description','equalto',vultr_vpc2_description) | list | count == 1 + +- name: test gather vpc2 info + vultr.cloud.vpc2_info: + register: result + +- name: verify test gather vultr vpc2 info + ansible.builtin.assert: + that: + - result.vultr_vpc2_info|selectattr('description','equalto',vultr_vpc2_description) | list | count == 1 + +- name: delete the vpc2 + vultr.cloud.vpc2: + name: "{{ vultr_vpc2_description }}" + state: absent diff --git a/ansible_collections/vultr/cloud/tests/integration/targets/vpc_info/tasks/tests.yml b/ansible_collections/vultr/cloud/tests/integration/targets/vpc_info/tasks/tests.yml index a8ab3d857..564b885e6 100644 --- a/ansible_collections/vultr/cloud/tests/integration/targets/vpc_info/tasks/tests.yml +++ b/ansible_collections/vultr/cloud/tests/integration/targets/vpc_info/tasks/tests.yml @@ -19,7 +19,7 @@ - name: verify test gather vultr vpc info in check mode ansible.builtin.assert: that: - - result.vultr_vpc_info|selectattr('description','equalto','{{ vultr_vpc_description }}') | list | count == 1 + - result.vultr_vpc_info|selectattr('description','equalto',vultr_vpc_description) | list | count == 1 - name: test gather VPC info vultr.cloud.vpc_info: @@ -28,7 +28,7 @@ - name: verify test gather vultr vpc info ansible.builtin.assert: that: - - result.vultr_vpc_info|selectattr('description','equalto','{{ vultr_vpc_description }}') | list | count == 1 + - result.vultr_vpc_info|selectattr('description','equalto',vultr_vpc_description) | list | count == 1 - name: Delete the VPC vultr.cloud.vpc: |