From 9ed0ffa981e95270d6751a44fc9d14cc9776ae3a Mon Sep 17 00:00:00 2001 From: smiron Date: Sun, 8 Dec 2024 10:38:46 +0200 Subject: [PATCH] modify appliance-multi-hosts to work on eco vsphere --- .../playbook.yml | 14 ++++ .../tasks/appliance_ntp.yml | 65 +++++++++++++++++++ .../tasks/main.yml | 1 + 3 files changed, 80 insertions(+) create mode 100644 tests/integration/targets/vmware_rest_appliance-multi-hosts/playbook.yml create mode 100644 tests/integration/targets/vmware_rest_appliance-multi-hosts/tasks/appliance_ntp.yml create mode 100644 tests/integration/targets/vmware_rest_appliance-multi-hosts/tasks/main.yml diff --git a/tests/integration/targets/vmware_rest_appliance-multi-hosts/playbook.yml b/tests/integration/targets/vmware_rest_appliance-multi-hosts/playbook.yml new file mode 100644 index 00000000..82113a5c --- /dev/null +++ b/tests/integration/targets/vmware_rest_appliance-multi-hosts/playbook.yml @@ -0,0 +1,14 @@ +- hosts: localhost + gather_facts: no + + tasks: + - name: Import eco-vcenter credentials + ansible.builtin.include_vars: + file: ../../integration_config.yml + tags: eco-vcenter-ci + + - name: Import appliance multi-hosts role + ansible.builtin.import_role: + name: vmware_rest_appliance-multi-hosts + tags: + - eco-vcenter-ci diff --git a/tests/integration/targets/vmware_rest_appliance-multi-hosts/tasks/appliance_ntp.yml b/tests/integration/targets/vmware_rest_appliance-multi-hosts/tasks/appliance_ntp.yml new file mode 100644 index 00000000..638e3de1 --- /dev/null +++ b/tests/integration/targets/vmware_rest_appliance-multi-hosts/tasks/appliance_ntp.yml @@ -0,0 +1,65 @@ +--- +- name: Manage NTP Configuration on vCenter + block: + - name: Reset the NTP configuration + vmware.vmware_rest.appliance_ntp: + servers: + - ca.pool.ntp.org + delegate_to: localhost + + - name: Retrieve the initial NTP configuration + vmware.vmware_rest.appliance_ntp_info: + delegate_to: localhost + + - name: Set the NTP configuration to use google NTP servers + vmware.vmware_rest.appliance_ntp: + servers: + - time.google.com + delegate_to: localhost + + - name: Verify idempotency of NTP configuration + vmware.vmware_rest.appliance_ntp: + servers: + - time.google.com + delegate_to: localhost + register: ntp_result + + - name: Debug idempotency result + ansible.builtin.debug: + var: ntp_result + + - name: Assert idempotency + ansible.builtin.assert: + that: + - not (ntp_result.changed) + + - name: Retrieve the updated NTP configuration + vmware.vmware_rest.appliance_ntp_info: + delegate_to: localhost + register: ntp_info + + - name: Debug updated NTP configuration + ansible.builtin.debug: + var: ntp_info + + - name: Assert the NTP configuration matches expected servers + ansible.builtin.assert: + that: + - ntp_info.value == ["time.google.com"] + + - name: Test the NTP configuration connectivity + vmware.vmware_rest.appliance_ntp: + state: test + servers: + - time.google.com + delegate_to: localhost + register: ntp_test_result + + - name: Debug NTP test result + ansible.builtin.debug: + var: ntp_test_result + + - name: Ensure the NTP server is reachable + ansible.builtin.assert: + that: + - ntp_test_result.value[0].status == "SERVER_REACHABLE" diff --git a/tests/integration/targets/vmware_rest_appliance-multi-hosts/tasks/main.yml b/tests/integration/targets/vmware_rest_appliance-multi-hosts/tasks/main.yml new file mode 100644 index 00000000..89f25a8c --- /dev/null +++ b/tests/integration/targets/vmware_rest_appliance-multi-hosts/tasks/main.yml @@ -0,0 +1 @@ +- import_tasks: appliance_ntp.yml