diff --git a/docs/docsite/rst/scenario_guides/guide_vultr.rst b/docs/docsite/rst/scenario_guides/guide_vultr.rst index 486b7cc67f..fbb1622258 100644 --- a/docs/docsite/rst/scenario_guides/guide_vultr.rst +++ b/docs/docsite/rst/scenario_guides/guide_vultr.rst @@ -141,3 +141,39 @@ For example, this allows you to take action on nodes grouped by location or OS n - name: Rebooting the machine shell: reboot become: True + + +Integration tests +----------------- + +Ansible includes integration tests for all Vultr modules. + +These tests are meant to run against the public Vultr API and that is why they require a valid key to access the API. + +Prepare the test setup: + +.. code-block:: shell + + $ cd ansible # location the ansible source is + $ source ./hacking/env-setup + +Set the Vultr API key: + +.. code-block:: shell + + $ cd test/integration + $ cp cloud-config-vultr.ini.template cloud-config-vultr.ini + $ vi cloud-config-vultr.ini + +Run all Vultr tests: + +.. code-block:: shell + + $ ansible-test integration cloud/vultr/ -v --diff --allow-unsupported + + +To run a specific test, e.g. vultr_account_facts: + +.. code-block:: shell + + $ ansible-test integration cloud/vultr/vultr_account_facts -v --diff --allow-unsupported diff --git a/test/integration/cloud-config-vultr.ini.template b/test/integration/cloud-config-vultr.ini.template new file mode 100644 index 0000000000..48b82108c6 --- /dev/null +++ b/test/integration/cloud-config-vultr.ini.template @@ -0,0 +1,12 @@ +# This is the configuration template for ansible-test Vultr integration tests. +# +# You do not need this template if you are: +# +# 1) Running integration tests without using ansible-test. +# +# If you want to test against the Vultr public API, +# fill in the values below and save this file without the .template extension. +# This will cause ansible-test to use the given configuration. + +[default] +key = @KEY diff --git a/test/integration/targets/vultr_account_facts/aliases b/test/integration/targets/vultr_account_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_account_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_account_facts/tasks/main.yml b/test/integration/targets/vultr_account_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_account_facts/tasks/main.yml rename to test/integration/targets/vultr_account_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_block_storage/aliases b/test/integration/targets/vultr_block_storage/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_block_storage/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/integration/targets/vultr_block_storage/defaults/main.yml b/test/integration/targets/vultr_block_storage/defaults/main.yml new file mode 100644 index 0000000000..17be33cb0f --- /dev/null +++ b/test/integration/targets/vultr_block_storage/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/test/legacy/roles/vultr_block_storage/tasks/main.yml b/test/integration/targets/vultr_block_storage/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_block_storage/tasks/main.yml rename to test/integration/targets/vultr_block_storage/tasks/main.yml diff --git a/test/integration/targets/vultr_block_storage_facts/aliases b/test/integration/targets/vultr_block_storage_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_block_storage_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/integration/targets/vultr_block_storage_facts/defaults/main.yml b/test/integration/targets/vultr_block_storage_facts/defaults/main.yml new file mode 100644 index 0000000000..17be33cb0f --- /dev/null +++ b/test/integration/targets/vultr_block_storage_facts/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/test/legacy/roles/vultr_block_storage_facts/tasks/main.yml b/test/integration/targets/vultr_block_storage_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_block_storage_facts/tasks/main.yml rename to test/integration/targets/vultr_block_storage_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_dns_domain/aliases b/test/integration/targets/vultr_dns_domain/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_dns_domain/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_user/defaults/main.yml b/test/integration/targets/vultr_dns_domain/defaults/main.yml similarity index 56% rename from test/legacy/roles/vultr_user/defaults/main.yml rename to test/integration/targets/vultr_dns_domain/defaults/main.yml index 22e3698f21..45cbf7287c 100644 --- a/test/legacy/roles/vultr_user/defaults/main.yml +++ b/test/integration/targets/vultr_dns_domain/defaults/main.yml @@ -1,4 +1,5 @@ # Copyright (c) 2018, René Moser # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- -vultr_user_name: john +vultr_resource_prefix: "vultr-test-prefix" +vultr_dns_domain_name: "{{ vultr_resource_prefix }}-example-ansible.com" diff --git a/test/legacy/roles/vultr_dns_domain/tasks/main.yml b/test/integration/targets/vultr_dns_domain/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_dns_domain/tasks/main.yml rename to test/integration/targets/vultr_dns_domain/tasks/main.yml diff --git a/test/integration/targets/vultr_dns_domain_facts/aliases b/test/integration/targets/vultr_dns_domain_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_dns_domain_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/integration/targets/vultr_dns_domain_facts/defaults/main.yml b/test/integration/targets/vultr_dns_domain_facts/defaults/main.yml new file mode 100644 index 0000000000..a452ee128d --- /dev/null +++ b/test/integration/targets/vultr_dns_domain_facts/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/test/legacy/roles/vultr_dns_domain_facts/tasks/main.yml b/test/integration/targets/vultr_dns_domain_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_dns_domain_facts/tasks/main.yml rename to test/integration/targets/vultr_dns_domain_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_dns_record/aliases b/test/integration/targets/vultr_dns_record/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_dns_record/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_dns_record/defaults/main.yml b/test/integration/targets/vultr_dns_record/defaults/main.yml similarity index 87% rename from test/legacy/roles/vultr_dns_record/defaults/main.yml rename to test/integration/targets/vultr_dns_record/defaults/main.yml index 5dd89f8199..fb52cfd955 100644 --- a/test/legacy/roles/vultr_dns_record/defaults/main.yml +++ b/test/integration/targets/vultr_dns_record/defaults/main.yml @@ -1,7 +1,8 @@ # Copyright (c) 2018, René Moser # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- -vultr_dns_domain_name: example-ansible.com +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 diff --git a/test/legacy/roles/vultr_dns_record/tasks/create_record.yml b/test/integration/targets/vultr_dns_record/tasks/create_record.yml similarity index 100% rename from test/legacy/roles/vultr_dns_record/tasks/create_record.yml rename to test/integration/targets/vultr_dns_record/tasks/create_record.yml diff --git a/test/legacy/roles/vultr_dns_record/tasks/main.yml b/test/integration/targets/vultr_dns_record/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_dns_record/tasks/main.yml rename to test/integration/targets/vultr_dns_record/tasks/main.yml diff --git a/test/legacy/roles/vultr_dns_record/tasks/record.yml b/test/integration/targets/vultr_dns_record/tasks/record.yml similarity index 100% rename from test/legacy/roles/vultr_dns_record/tasks/record.yml rename to test/integration/targets/vultr_dns_record/tasks/record.yml diff --git a/test/legacy/roles/vultr_dns_record/tasks/remove_record.yml b/test/integration/targets/vultr_dns_record/tasks/remove_record.yml similarity index 100% rename from test/legacy/roles/vultr_dns_record/tasks/remove_record.yml rename to test/integration/targets/vultr_dns_record/tasks/remove_record.yml diff --git a/test/legacy/roles/vultr_dns_record/tasks/test_fail_multiple.yml b/test/integration/targets/vultr_dns_record/tasks/test_fail_multiple.yml similarity index 100% rename from test/legacy/roles/vultr_dns_record/tasks/test_fail_multiple.yml rename to test/integration/targets/vultr_dns_record/tasks/test_fail_multiple.yml diff --git a/test/legacy/roles/vultr_dns_record/tasks/update_record.yml b/test/integration/targets/vultr_dns_record/tasks/update_record.yml similarity index 100% rename from test/legacy/roles/vultr_dns_record/tasks/update_record.yml rename to test/integration/targets/vultr_dns_record/tasks/update_record.yml diff --git a/test/integration/targets/vultr_firewall_group/aliases b/test/integration/targets/vultr_firewall_group/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_firewall_group/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_firewall_rule/defaults/main.yml b/test/integration/targets/vultr_firewall_group/defaults/main.yml similarity index 56% rename from test/legacy/roles/vultr_firewall_rule/defaults/main.yml rename to test/integration/targets/vultr_firewall_group/defaults/main.yml index 7d7ac1dbeb..7057b46678 100644 --- a/test/legacy/roles/vultr_firewall_rule/defaults/main.yml +++ b/test/integration/targets/vultr_firewall_group/defaults/main.yml @@ -1,4 +1,5 @@ # Copyright (c) 2018, René Moser # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- -vultr_firewall_group_name: ansible-firewall-group +vultr_resource_prefix: "vultr-test-prefix" +vultr_firewall_group_name: "{{ vultr_resource_prefix }}_firewall-group" diff --git a/test/legacy/roles/vultr_firewall_group/tasks/main.yml b/test/integration/targets/vultr_firewall_group/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_firewall_group/tasks/main.yml rename to test/integration/targets/vultr_firewall_group/tasks/main.yml diff --git a/test/integration/targets/vultr_firewall_group_facts/aliases b/test/integration/targets/vultr_firewall_group_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_firewall_group_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/integration/targets/vultr_firewall_group_facts/defaults/main.yml b/test/integration/targets/vultr_firewall_group_facts/defaults/main.yml new file mode 100644 index 0000000000..e545fe42e1 --- /dev/null +++ b/test/integration/targets/vultr_firewall_group_facts/defaults/main.yml @@ -0,0 +1,3 @@ +--- +vultr_resource_prefix: "vultr-test-prefix" +firewall_group_name: "{{ vultr_resource_prefix }}_firewall-group" diff --git a/test/legacy/roles/vultr_firewall_group_facts/tasks/main.yml b/test/integration/targets/vultr_firewall_group_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_firewall_group_facts/tasks/main.yml rename to test/integration/targets/vultr_firewall_group_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_firewall_rule/aliases b/test/integration/targets/vultr_firewall_rule/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_firewall_rule/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_dns_domain/defaults/main.yml b/test/integration/targets/vultr_firewall_rule/defaults/main.yml similarity index 56% rename from test/legacy/roles/vultr_dns_domain/defaults/main.yml rename to test/integration/targets/vultr_firewall_rule/defaults/main.yml index 745af80b0d..7057b46678 100644 --- a/test/legacy/roles/vultr_dns_domain/defaults/main.yml +++ b/test/integration/targets/vultr_firewall_rule/defaults/main.yml @@ -1,4 +1,5 @@ # Copyright (c) 2018, René Moser # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- -vultr_dns_domain_name: example-ansible.com +vultr_resource_prefix: "vultr-test-prefix" +vultr_firewall_group_name: "{{ vultr_resource_prefix }}_firewall-group" diff --git a/test/legacy/roles/vultr_firewall_rule/tasks/main.yml b/test/integration/targets/vultr_firewall_rule/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_firewall_rule/tasks/main.yml rename to test/integration/targets/vultr_firewall_rule/tasks/main.yml diff --git a/test/integration/targets/vultr_network/aliases b/test/integration/targets/vultr_network/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_network/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/integration/targets/vultr_network/defaults/main.yml b/test/integration/targets/vultr_network/defaults/main.yml new file mode 100644 index 0000000000..a3d9e59264 --- /dev/null +++ b/test/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/test/legacy/roles/vultr_network/tasks/main.yml b/test/integration/targets/vultr_network/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_network/tasks/main.yml rename to test/integration/targets/vultr_network/tasks/main.yml diff --git a/test/integration/targets/vultr_network_facts/aliases b/test/integration/targets/vultr_network_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_network_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/integration/targets/vultr_network_facts/defaults/main.yml b/test/integration/targets/vultr_network_facts/defaults/main.yml new file mode 100644 index 0000000000..28e3e705b3 --- /dev/null +++ b/test/integration/targets/vultr_network_facts/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/test/legacy/roles/vultr_network_facts/tasks/main.yml b/test/integration/targets/vultr_network_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_network_facts/tasks/main.yml rename to test/integration/targets/vultr_network_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_os_facts/aliases b/test/integration/targets/vultr_os_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_os_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_os_facts/tasks/main.yml b/test/integration/targets/vultr_os_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_os_facts/tasks/main.yml rename to test/integration/targets/vultr_os_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_plan_facts/aliases b/test/integration/targets/vultr_plan_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_plan_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_plan_facts/tasks/main.yml b/test/integration/targets/vultr_plan_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_plan_facts/tasks/main.yml rename to test/integration/targets/vultr_plan_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_region_facts/aliases b/test/integration/targets/vultr_region_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_region_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_region_facts/tasks/main.yml b/test/integration/targets/vultr_region_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_region_facts/tasks/main.yml rename to test/integration/targets/vultr_region_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_server/aliases b/test/integration/targets/vultr_server/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_server/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_server/defaults/main.yml b/test/integration/targets/vultr_server/defaults/main.yml similarity index 93% rename from test/legacy/roles/vultr_server/defaults/main.yml rename to test/integration/targets/vultr_server/defaults/main.yml index dfe5b73bd3..31775566c1 100644 --- a/test/legacy/roles/vultr_server/defaults/main.yml +++ b/test/integration/targets/vultr_server/defaults/main.yml @@ -1,7 +1,8 @@ # Copyright (c) 2018, René Moser # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- -vultr_server_name: ansible-test-vm1 +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" diff --git a/test/legacy/roles/vultr_server/tasks/main.yml b/test/integration/targets/vultr_server/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_server/tasks/main.yml rename to test/integration/targets/vultr_server/tasks/main.yml diff --git a/test/integration/targets/vultr_server_facts/aliases b/test/integration/targets/vultr_server_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_server_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_server_facts/defaults/main.yml b/test/integration/targets/vultr_server_facts/defaults/main.yml similarity index 53% rename from test/legacy/roles/vultr_server_facts/defaults/main.yml rename to test/integration/targets/vultr_server_facts/defaults/main.yml index fe63707fcd..37134a1f38 100644 --- a/test/legacy/roles/vultr_server_facts/defaults/main.yml +++ b/test/integration/targets/vultr_server_facts/defaults/main.yml @@ -1,4 +1,6 @@ -vultr_server_name: ansibletest +--- +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/test/legacy/roles/vultr_server_facts/tasks/main.yml b/test/integration/targets/vultr_server_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_server_facts/tasks/main.yml rename to test/integration/targets/vultr_server_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_ssh_key/aliases b/test/integration/targets/vultr_ssh_key/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_ssh_key/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_ssh_key/defaults/main.yml b/test/integration/targets/vultr_ssh_key/defaults/main.yml similarity index 92% rename from test/legacy/roles/vultr_ssh_key/defaults/main.yml rename to test/integration/targets/vultr_ssh_key/defaults/main.yml index 7ded5b6b17..53cce56767 100644 --- a/test/legacy/roles/vultr_ssh_key/defaults/main.yml +++ b/test/integration/targets/vultr_ssh_key/defaults/main.yml @@ -1,6 +1,7 @@ # Copyright (c) 2018, René Moser # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- -vultr_ssh_key_name: ansible-ssh-key +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/test/legacy/roles/vultr_ssh_key/tasks/main.yml b/test/integration/targets/vultr_ssh_key/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_ssh_key/tasks/main.yml rename to test/integration/targets/vultr_ssh_key/tasks/main.yml diff --git a/test/integration/targets/vultr_ssh_key_facts/aliases b/test/integration/targets/vultr_ssh_key_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_ssh_key_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_ssh_key_facts/defaults/main.yml b/test/integration/targets/vultr_ssh_key_facts/defaults/main.yml similarity index 80% rename from test/legacy/roles/vultr_ssh_key_facts/defaults/main.yml rename to test/integration/targets/vultr_ssh_key_facts/defaults/main.yml index bb4ecce18b..00db51ad70 100644 --- a/test/legacy/roles/vultr_ssh_key_facts/defaults/main.yml +++ b/test/integration/targets/vultr_ssh_key_facts/defaults/main.yml @@ -1,2 +1,4 @@ -ssh_key_name: ansibletest-sshkey +--- +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@sshkey diff --git a/test/legacy/roles/vultr_ssh_key_facts/tasks/main.yml b/test/integration/targets/vultr_ssh_key_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_ssh_key_facts/tasks/main.yml rename to test/integration/targets/vultr_ssh_key_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_startup_script/aliases b/test/integration/targets/vultr_startup_script/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_startup_script/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_startup_script/defaults/main.yml b/test/integration/targets/vultr_startup_script/defaults/main.yml similarity index 73% rename from test/legacy/roles/vultr_startup_script/defaults/main.yml rename to test/integration/targets/vultr_startup_script/defaults/main.yml index f13f403236..38b68a6953 100644 --- a/test/legacy/roles/vultr_startup_script/defaults/main.yml +++ b/test/integration/targets/vultr_startup_script/defaults/main.yml @@ -1,6 +1,7 @@ # Copyright (c) 2018, René Moser # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- -vultr_startup_script_name: ansible_test_script +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/test/legacy/roles/vultr_startup_script/tasks/main.yml b/test/integration/targets/vultr_startup_script/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_startup_script/tasks/main.yml rename to test/integration/targets/vultr_startup_script/tasks/main.yml diff --git a/test/integration/targets/vultr_startup_script_facts/aliases b/test/integration/targets/vultr_startup_script_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_startup_script_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/integration/targets/vultr_startup_script_facts/defaults/main.yml b/test/integration/targets/vultr_startup_script_facts/defaults/main.yml new file mode 100644 index 0000000000..017cff1a36 --- /dev/null +++ b/test/integration/targets/vultr_startup_script_facts/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/test/legacy/roles/vultr_startup_script_facts/tasks/main.yml b/test/integration/targets/vultr_startup_script_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_startup_script_facts/tasks/main.yml rename to test/integration/targets/vultr_startup_script_facts/tasks/main.yml diff --git a/test/integration/targets/vultr_user/aliases b/test/integration/targets/vultr_user/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_user/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_firewall_group/defaults/main.yml b/test/integration/targets/vultr_user/defaults/main.yml similarity index 61% rename from test/legacy/roles/vultr_firewall_group/defaults/main.yml rename to test/integration/targets/vultr_user/defaults/main.yml index 7d7ac1dbeb..9050a68f77 100644 --- a/test/legacy/roles/vultr_firewall_group/defaults/main.yml +++ b/test/integration/targets/vultr_user/defaults/main.yml @@ -1,4 +1,5 @@ # Copyright (c) 2018, René Moser # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- -vultr_firewall_group_name: ansible-firewall-group +vultr_resource_prefix: "vultr-test-prefix" +vultr_user_name: "{{ vultr_resource_prefix }}_user" diff --git a/test/legacy/roles/vultr_user/tasks/main.yml b/test/integration/targets/vultr_user/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_user/tasks/main.yml rename to test/integration/targets/vultr_user/tasks/main.yml diff --git a/test/integration/targets/vultr_user_facts/aliases b/test/integration/targets/vultr_user_facts/aliases new file mode 100644 index 0000000000..2c3fa42cbc --- /dev/null +++ b/test/integration/targets/vultr_user_facts/aliases @@ -0,0 +1,2 @@ +cloud/vultr +unsupported diff --git a/test/legacy/roles/vultr_user_facts/defaults/main.yml b/test/integration/targets/vultr_user_facts/defaults/main.yml similarity index 57% rename from test/legacy/roles/vultr_user_facts/defaults/main.yml rename to test/integration/targets/vultr_user_facts/defaults/main.yml index 4127d161a2..6901081331 100644 --- a/test/legacy/roles/vultr_user_facts/defaults/main.yml +++ b/test/integration/targets/vultr_user_facts/defaults/main.yml @@ -1,4 +1,6 @@ -user_name: mytestuser +--- +vultr_resource_prefix: "vultr-test-prefix" +user_name: "{{ vultr_resource_prefix }}_user" user_email: mytestuser@example.com user_password: aP4ssw0rd! user_acls: diff --git a/test/legacy/roles/vultr_user_facts/tasks/main.yml b/test/integration/targets/vultr_user_facts/tasks/main.yml similarity index 100% rename from test/legacy/roles/vultr_user_facts/tasks/main.yml rename to test/integration/targets/vultr_user_facts/tasks/main.yml diff --git a/test/legacy/roles/vultr_block_storage/defaults/main.yml b/test/legacy/roles/vultr_block_storage/defaults/main.yml deleted file mode 100644 index 1eab91c4d1..0000000000 --- a/test/legacy/roles/vultr_block_storage/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -vultr_block_storage_name: ansible-test-vm1 -vultr_block_storage_size: 10 -vultr_block_storage_region: New Jersey diff --git a/test/legacy/roles/vultr_block_storage_facts/defaults/main.yml b/test/legacy/roles/vultr_block_storage_facts/defaults/main.yml deleted file mode 100644 index b49589ac6f..0000000000 --- a/test/legacy/roles/vultr_block_storage_facts/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -vultr_block_storage_name: ansibletest-volume -vultr_block_storage_size: 10 -vultr_block_storage_region: New Jersey diff --git a/test/legacy/roles/vultr_dns_domain_facts/defaults/main.yml b/test/legacy/roles/vultr_dns_domain_facts/defaults/main.yml deleted file mode 100644 index ade6f34217..0000000000 --- a/test/legacy/roles/vultr_dns_domain_facts/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dns_domain_name: ansibletest.com -dns_domain_server_ip: 104.24.16.59 diff --git a/test/legacy/roles/vultr_firewall_group_facts/defaults/main.yml b/test/legacy/roles/vultr_firewall_group_facts/defaults/main.yml deleted file mode 100644 index 18d55d2853..0000000000 --- a/test/legacy/roles/vultr_firewall_group_facts/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ -firewall_group_name: mytestfirewallgroup diff --git a/test/legacy/roles/vultr_network/defaults/main.yml b/test/legacy/roles/vultr_network/defaults/main.yml deleted file mode 100644 index be72f7e2f1..0000000000 --- a/test/legacy/roles/vultr_network/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -vultr_network_name: ansible-test-network -vultr_network_cidr: 192.168.42.0/24 -vultr_network_region: New Jersey diff --git a/test/legacy/roles/vultr_network_facts/defaults/main.yml b/test/legacy/roles/vultr_network_facts/defaults/main.yml deleted file mode 100644 index 28c2ecbdb3..0000000000 --- a/test/legacy/roles/vultr_network_facts/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -vultr_network_name: mytestnetwork -vultr_network_cidr: 192.168.42.0/24 -vultr_network_region: New Jersey diff --git a/test/legacy/roles/vultr_startup_script_facts/defaults/main.yml b/test/legacy/roles/vultr_startup_script_facts/defaults/main.yml deleted file mode 100644 index d3346b2a49..0000000000 --- a/test/legacy/roles/vultr_startup_script_facts/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -startup_script_name: myteststartupscript -startup_script_type: boot -startup_script_content: "#!/bin/bash\necho Hello World > /root/hello" diff --git a/test/legacy/vultr.yml b/test/legacy/vultr.yml deleted file mode 100644 index 9223915c83..0000000000 --- a/test/legacy/vultr.yml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2018, René Moser -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- hosts: localhost - gather_facts: no - connection: local - roles: - - { role: vultr_account_facts, tags: test_vultr_account_facts } - - { role: vultr_block_storage, tags: test_vultr_block_storage } - - { role: vultr_block_storage_facts, tags: test_vultr_block_storage_facts } - - { role: vultr_dns_domain, tags: test_vultr_dns_domain } - - { role: vultr_dns_domain_facts, tags: test_vultr_dns_domain_facts } - - { role: vultr_dns_record, tags: test_vultr_dns_record } - - { role: vultr_firewall_group, tags: test_vultr_firewall_group } - - { role: vultr_firewall_group_facts, tags: test_vultr_firewall_group_facts } - - { role: vultr_firewall_rule, tags: test_vultr_firewall_rule } - - { role: vultr_network, tags: test_vultr_network } - - { role: vultr_network_facts, tags: test_vultr_network_facts } - - { role: vultr_os_facts, tags: test_vultr_os_facts } - - { role: vultr_plan_facts, tags: test_vultr_plan_facts } - - { role: vultr_region_facts, tags: test_vultr_region_facts } - - { role: vultr_server, tags: test_vultr_server } - - { role: vultr_server_facts, tags: test_vultr_server_facts } - - { role: vultr_ssh_key, tags: test_vultr_ssh_key } - - { role: vultr_ssh_key_facts, tags: test_vultr_ssh_key_facts } - - { role: vultr_startup_script, tags: test_vultr_startup_script } - - { role: vultr_startup_script_facts, tags: test_vultr_startup_script_facts } - - { role: vultr_user, tags: test_vultr_user } - - { role: vultr_user_facts, tags: test_vultr_user_facts } diff --git a/test/runner/lib/cloud/vultr.py b/test/runner/lib/cloud/vultr.py new file mode 100644 index 0000000000..eedc19555c --- /dev/null +++ b/test/runner/lib/cloud/vultr.py @@ -0,0 +1,62 @@ +"""Vultr plugin for integration tests.""" +from __future__ import absolute_import, print_function + +import os + +from lib.cloud import ( + CloudProvider, + CloudEnvironment +) + +from lib.util import ConfigParser + + +class VultrCloudProvider(CloudProvider): + """Checks if a configuration file has been passed or fixtures are going to be used for testing""" + + def __init__(self, args): + """ + :type args: TestConfig + """ + super(VultrCloudProvider, self).__init__(args, config_extension='.ini') + + def filter(self, targets, exclude): + """Filter out the cloud tests when the necessary config and resources are not available. + :type targets: tuple[TestTarget] + :type exclude: list[str] + """ + if os.path.isfile(self.config_static_path): + return + + super(VultrCloudProvider, self).filter(targets, exclude) + + def setup(self): + super(VultrCloudProvider, self).setup() + + if os.path.isfile(self.config_static_path): + self.config_path = self.config_static_path + self.managed = False + return True + return False + + +class VultrCloudEnvironment(CloudEnvironment): + """ + Updates integration test environment after delegation. Will setup the config file as parameter. + """ + + def configure_environment(self, env, cmd): + """ + :type env: dict[str, str] + :type cmd: list[str] + """ + parser = ConfigParser() + parser.read(self.config_path) + + changes = dict( + VULTR_API_KEY=parser.get('default', 'key'), + ) + env.update(changes) + + cmd.append('-e') + cmd.append('vultr_resource_prefix=%s' % self.resource_prefix)