Skip to content

Commit

Permalink
appliance-multi-hosts tests
Browse files Browse the repository at this point in the history
Test to validate we can run the same module in parallel.

See: ansible-collections#364
  • Loading branch information
goneri committed Dec 1, 2022
1 parent d44f958 commit 5e307e2
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/integration/targets/appliance-multi-hosts/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
network/vmware_rest
zuul/vmware/vcenter_1esxi_with_nested
disabled
20 changes: 20 additions & 0 deletions tests/integration/targets/appliance-multi-hosts/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
vcenter1.test vcsa_host=vcenter1.test
vcenter2.test vcsa_host=vcenter2.test
vcenter3.test vcsa_host=vcenter3.test
vcenter4.test vcsa_host=vcenter4.test
vcenter5.test vcsa_host=vcenter5.test
vcenter6.test vcsa_host=vcenter6.test
vcenter7.test vcsa_host=vcenter7.test
vcenter8.test vcsa_host=vcenter8.test
vcenter9.test vcsa_host=vcenter9.test
vcenter10.test vcsa_host=vcenter10.test
vcenter11.test vcsa_host=vcenter11.test
vcenter12.test vcsa_host=vcenter12.test
vcenter13.test vcsa_host=vcenter13.test
vcenter14.test vcsa_host=vcenter14.test
vcenter15.test vcsa_host=vcenter15.test
vcenter16.test vcsa_host=vcenter16.test
vcenter17.test vcsa_host=vcenter17.test
vcenter18.test vcsa_host=vcenter18.test
vcenter19.test vcsa_host=vcenter19.test
vcenter20.test vcsa_host=vcenter20.test
Empty file.
7 changes: 7 additions & 0 deletions tests/integration/targets/appliance-multi-hosts/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- hosts: all
gather_facts: no
collections:
- vmware.vmware_rest
tasks:
- import_role:
name: appliance-multi-hosts
11 changes: 11 additions & 0 deletions tests/integration/targets/appliance-multi-hosts/runme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
source ../init.sh

#export ANSIBLE_ROLES_PATH=..
#export VMWARE_HOST=localhost:8000/vcsa1
#export VMWARE_USER=root
#export VMWARE_PASSWORD=password
export VMWARE_VALIDATE_CERTS=no
export VMWARE_REST_LOG_FILE=/tmp/toto.log

exec ansible-playbook -i inventory playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
- name: _reset the NTP configuration
vmware.vmware_rest.appliance_ntp:
vcenter_hostname: "{{ vcsa_host }}"
servers:
- ca.pool.ntp.org
delegate_to: localhost

- name: Get the NTP configuration
vmware.vmware_rest.appliance_ntp_info:
vcenter_hostname: "{{ vcsa_host }}"
delegate_to: localhost

- name: Adjust the NTP configuration
vmware.vmware_rest.appliance_ntp:
vcenter_hostname: "{{ vcsa_host }}"
servers:
- time.google.com
delegate_to: localhost

- name: _Adjust the NTP configuration (again)
vmware.vmware_rest.appliance_ntp:
vcenter_hostname: "{{ vcsa_host }}"
servers:
- time.google.com
delegate_to: localhost
register: result

- ansible.builtin.debug: var=result
- name: Validate idempotency
ansible.builtin.assert:
that:
- not (result.changed)

- name: Get the NTP configuration
vmware.vmware_rest.appliance_ntp_info:
vcenter_hostname: "{{ vcsa_host }}"
delegate_to: localhost
register: result

- ansible.builtin.debug: var=result
- name: Assert the NTP configuration is right
ansible.builtin.assert:
that:
- result.value == ["time.google.com"]

- name: Test the NTP configuration
vmware.vmware_rest.appliance_ntp:
vcenter_hostname: "{{ vcsa_host }}"
state: test
servers:
- time.google.com
delegate_to: localhost
register: result
- ansible.builtin.debug: var=result

- name: Ensure the result is successful
ansible.builtin.assert:
that:
- result.value[0].status == "SERVER_REACHABLE"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- import_tasks: appliance_ntp.yaml

0 comments on commit 5e307e2

Please sign in to comment.