# Test code for the vmware_host_service_manager module. # Copyright: (c) 2018, Abhijeet Kasurde # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # TODO: vcsim does not support service management # commenting this testcase till the time. - when: vcsim is not defined block: - import_role: name: prepare_vmware_tests vars: setup_attach_host: true - name: Start ntpd service on all hosts in given cluster vmware_host_service_manager: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no cluster_name: "{{ ccr1 }}" service_name: ntpd state: present register: all_hosts_result - debug: var=all_hosts_result - name: Stop ntpd service on a given host vmware_host_service_manager: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no esxi_hostname: '{{ hostvars[esxi1].ansible_host }}' service_name: ntpd state: absent register: single_hosts_result - name: ensure facts are gathered assert: that: - single_hosts_result is changed - name: Start ntpd service on all hosts in given cluster in check mode vmware_host_service_manager: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no cluster_name: "{{ ccr1 }}" service_name: ntpd state: present register: all_hosts_result_check_mode check_mode: yes - name: ensure facts are gathered for all hosts assert: that: - all_hosts_result_check_mode is changed - name: Stop ntpd service on a given host in check mode vmware_host_service_manager: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no esxi_hostname: '{{ hostvars[esxi1].ansible_host }}' service_name: ntpd state: absent register: single_hosts_result_check_mode check_mode: yes - name: ensure facts are gathered assert: that: - not (single_hosts_result_check_mode is changed) - name: Start ntpd service on all hosts in given cluster vmware_host_service_manager: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no cluster_name: "{{ ccr1 }}" service_name: ntpd state: present register: all_hosts_result_check_mode - name: finally, ensure ntp is running on the cluster assert: that: - all_hosts_result_check_mode is changed