-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0da1722
commit 4e4a25d
Showing
2 changed files
with
124 additions
and
7 deletions.
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
tests/integration/targets/vmware_rest_appliance/tasks/appliance_services.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
--- | ||
- 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 is defined | ||
- after_stop_ntpd_info.failed == false | ||
- after_stop_ntpd_info.value.state is defined | ||
- 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 is defined | ||
- after_start_ntpd_info.failed == false | ||
- after_start_ntpd_info.value.state is defined | ||
- 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 is defined | ||
- after_restart_ntpd_info.failed == false | ||
- after_restart_ntpd_info.value.state is defined | ||
- after_restart_ntpd_info.value.state == "STARTED" | ||
fail_msg: "Failed to restart the ntpd service." | ||
|
||
rescue: | ||
- name: Handle errors during ntpd service management | ||
ansible.builtin.debug: | ||
msg: "An error occurred while managing the ntpd service. Please check the logs for more details." | ||
|
||
always: | ||
- name: Ensure ntpd service is started | ||
vmware.vmware_rest.appliance_services: | ||
service: ntpd | ||
state: start | ||
when: after_restart_ntpd_info.value.state is defined and after_restart_ntpd_info.value.state != "STARTED" | ||
register: ensure_started_result | ||
|
||
- name: Debug ensure started result | ||
ansible.builtin.debug: | ||
var: ensure_started_result | ||
|
||
- name: Validate ntpd service has started | ||
ansible.builtin.assert: | ||
that: | ||
- ensure_started_result is defined | ||
- ensure_started_result.failed == false | ||
fail_msg: "Failed to ensure the ntpd service has started." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters