Skip to content

Commit

Permalink
add appliance services.yml test
Browse files Browse the repository at this point in the history
  • Loading branch information
prabinovRedhat committed Jan 9, 2025
1 parent 0da1722 commit c4384d2
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
- name: Manage and test ntpd service
block:
- name: Get information about the ntpd service
vmware.vmware_rest.appliance_services_info:
service: ntpd
register: initial_ntpd_info

- name: Debug initial ntpd service info
ansible.builtin.debug:
var: initial_ntpd_info

- name: Stop the ntpd service
vmware.vmware_rest.appliance_services:
service: ntpd
state: stop
register: stop_result

- name: Debug stop result
ansible.builtin.debug:
var: stop_result

- name: Get information about the ntpd service after it is stopped
vmware.vmware_rest.appliance_services_info:
service: ntpd
register: after_stop_ntpd_info

- name: Debug ntpd service info after it is stopped
ansible.builtin.debug:
var: after_stop_ntpd_info

- name: Validate ntpd service is stopped
ansible.builtin.assert:
that:
- after_stop_ntpd_info.failed == false
- after_stop_ntpd_info.value.state == "STOPPED"
fail_msg: "Failed to stop the ntpd service."

- name: Start the ntpd service
vmware.vmware_rest.appliance_services:
service: ntpd
state: start
register: start_result

- name: Debug start result
ansible.builtin.debug:
var: start_result

- name: Get information about the ntpd service after it has started
vmware.vmware_rest.appliance_services_info:
service: ntpd
register: after_start_ntpd_info

- name: Debug ntpd service info after it has started
ansible.builtin.debug:
var: after_start_ntpd_info

- name: Validate ntpd service is started
ansible.builtin.assert:
that:
- after_start_ntpd_info.failed == false
- after_start_ntpd_info.value.state == "STARTED"
fail_msg: "Failed to start the ntpd service."

- name: Restart the ntpd service
vmware.vmware_rest.appliance_services:
service: ntpd
state: restart
register: restart_result

- name: Debug restart result
ansible.builtin.debug:
var: restart_result

- name: Get information about the ntpd service after it is restarted
vmware.vmware_rest.appliance_services_info:
service: ntpd
register: after_restart_ntpd_info

- name: Debug ntpd service info after it is restarted
ansible.builtin.debug:
var: after_restart_ntpd_info

- name: Validate ntpd service is restarted
ansible.builtin.assert:
that:
- after_restart_ntpd_info.failed == false
- after_restart_ntpd_info.value.state == "STARTED"
fail_msg: "Failed to restart the ntpd service."

always:
- name: Ensure ntpd service is started
vmware.vmware_rest.appliance_services:
service: ntpd
state: start
register: ensure_started_result

- name: Debug ensure started result
ansible.builtin.debug:
var: ensure_started_result
12 changes: 5 additions & 7 deletions tests/integration/targets/vmware_rest_appliance/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
- import_tasks: appliance_localaccounts.yml
- import_tasks: appliance_monitoring.yml
- import_tasks: appliance_networking_dns_hostname.yml
- import_tasks: appliance_networking_proxy.yml
- import_tasks: appliance_services.yml
- import_tasks: appliance_system.yml
- import_tasks: appliance_time.yml
# - import_tasks: appliance_networking.yml - There is a bug
# - import_tasks: appliance_networking_firewall_inbound.yml - There is a bug
# - import_tasks: appliance_networking_interfaces_ipv4.yml - There is a bug
# - import_tasks: appliance_networking_interfaces_ipv6.yml - There is a bug
- import_tasks: appliance_networking_proxy.yml
# - import_tasks: appliance_services.yml
# - import_tasks: appliance_shutdown.yml
- import_tasks: appliance_system.yml
# - import_tasks: appliance_system_storage.yml - There is a bug
- import_tasks: appliance_time.yml
# - import_tasks: appliance_vmon_service.yml
# - import_tasks: appliance_system_storage.yml - There is a bug

0 comments on commit c4384d2

Please sign in to comment.