2018-01-17 14:23:13 +01:00
|
|
|
# Test code for the vmware_host_ntp module.
|
|
|
|
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
# TODO: vcsim does not support update host NTP configuration
|
|
|
|
|
2018-05-08 19:31:17 +02:00
|
|
|
- name: Wait for Flask controller to come up online
|
|
|
|
wait_for:
|
|
|
|
host: "{{ vcsim }}"
|
|
|
|
port: 5000
|
|
|
|
state: started
|
|
|
|
|
|
|
|
- name: kill vcsim
|
|
|
|
uri:
|
|
|
|
url: http://{{ vcsim }}:5000/killall
|
|
|
|
|
|
|
|
- name: start vcsim
|
|
|
|
uri:
|
|
|
|
url: http://{{ vcsim }}:5000/spawn?cluster=2
|
|
|
|
register: vcsim_instance
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: vcsim_instance
|
|
|
|
|
|
|
|
- name: Wait for vcsim server to come up online
|
|
|
|
wait_for:
|
|
|
|
host: "{{ vcsim }}"
|
|
|
|
port: 443
|
|
|
|
state: started
|
|
|
|
|
|
|
|
- name: get a list of Cluster from vcsim
|
|
|
|
uri:
|
|
|
|
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
|
|
|
|
register: clusters
|
|
|
|
|
|
|
|
- name: get a cluster
|
|
|
|
set_fact:
|
|
|
|
ccr1: "{{ clusters.json[0] | basename }}"
|
|
|
|
|
|
|
|
- name: get a list of hosts from vcsim
|
|
|
|
uri:
|
|
|
|
url: http://{{ vcsim }}:5000/govc_find?filter=H
|
|
|
|
register: hosts
|
|
|
|
|
|
|
|
- name: get a host
|
|
|
|
set_fact:
|
|
|
|
host1: "{{ hosts.json[0] | basename }}"
|
|
|
|
|
|
|
|
- debug: var=ccr1
|
|
|
|
- debug: var=host1
|
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Add NTP server to a host
|
2018-05-08 19:31:17 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
state: present
|
|
|
|
ntp_server:
|
|
|
|
- 0.pool.ntp.org
|
|
|
|
validate_certs: no
|
|
|
|
register: present
|
|
|
|
|
|
|
|
- debug: var=present
|
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Add another NTP server to a host
|
2018-05-08 19:31:17 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
state: present
|
|
|
|
ntp_server:
|
|
|
|
- 1.pool.ntp.org
|
|
|
|
validate_certs: no
|
|
|
|
register: present
|
|
|
|
|
|
|
|
- debug: var=present
|
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Remove NTP server from a host
|
2018-05-08 19:31:17 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
state: absent
|
|
|
|
ntp_server:
|
|
|
|
- 1.pool.ntp.org
|
|
|
|
validate_certs: no
|
2018-12-20 06:07:23 +01:00
|
|
|
register: absent_one
|
2018-05-08 19:31:17 +02:00
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- debug: var=absent_one
|
2018-05-08 19:31:17 +02:00
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Remove NTP server from a host
|
2018-05-08 19:31:17 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
state: present
|
|
|
|
ntp_server:
|
|
|
|
- 1.pool.ntp.org
|
|
|
|
validate_certs: no
|
|
|
|
register: present
|
|
|
|
|
|
|
|
- debug: var=present
|
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Add more NTP servers to a host
|
2018-05-08 19:31:17 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
state: present
|
|
|
|
ntp_server:
|
|
|
|
- 2.pool.ntp.org
|
|
|
|
- 3.pool.ntp.org
|
|
|
|
- 4.pool.ntp.org
|
|
|
|
validate_certs: no
|
|
|
|
register: present
|
|
|
|
|
|
|
|
- debug: var=present
|
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Remove all NTP servers from a host
|
2018-05-08 19:31:17 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
state: absent
|
|
|
|
ntp_server:
|
|
|
|
- 0.pool.ntp.org
|
|
|
|
- 1.pool.ntp.org
|
|
|
|
- 2.pool.ntp.org
|
|
|
|
- 3.pool.ntp.org
|
|
|
|
- 4.pool.ntp.org
|
|
|
|
- 6.pool.ntp.org
|
|
|
|
validate_certs: no
|
2018-12-20 06:07:23 +01:00
|
|
|
register: absent_all
|
2018-05-08 19:31:17 +02:00
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- debug: var=absent_all
|
2018-10-08 11:41:52 +02:00
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Configure NTP servers for a host
|
2018-10-08 11:41:52 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
ntp_server:
|
|
|
|
- 0.pool.ntp.org
|
|
|
|
- 1.pool.ntp.org
|
2018-12-20 06:07:23 +01:00
|
|
|
- 2.pool.ntp.org
|
2018-10-08 11:41:52 +02:00
|
|
|
validate_certs: no
|
2018-12-20 06:07:23 +01:00
|
|
|
register: ntp_servers
|
2018-10-08 11:41:52 +02:00
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- debug: var=ntp_servers
|
2018-10-08 11:41:52 +02:00
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Configure NTP servers for a host
|
2018-10-08 11:41:52 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
ntp_server:
|
2018-12-20 06:07:23 +01:00
|
|
|
- 3.pool.ntp.org
|
|
|
|
- 4.pool.ntp.org
|
|
|
|
- 5.pool.ntp.org
|
|
|
|
verbose: true
|
2018-10-08 11:41:52 +02:00
|
|
|
validate_certs: no
|
2018-12-20 06:07:23 +01:00
|
|
|
register: ntp_servers
|
2018-10-08 11:41:52 +02:00
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- debug: var=ntp_servers
|
2018-10-08 11:41:52 +02:00
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Add NTP server to a host in check mode
|
2018-10-08 11:41:52 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
state: present
|
|
|
|
ntp_server:
|
2018-12-20 06:07:23 +01:00
|
|
|
- 0.pool.ntp.org
|
2018-10-08 11:41:52 +02:00
|
|
|
validate_certs: no
|
|
|
|
register: present
|
|
|
|
check_mode: yes
|
|
|
|
|
|
|
|
- debug: var=present
|
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Remove NTP server to a host in check mode
|
2018-10-08 11:41:52 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
2018-12-20 06:07:23 +01:00
|
|
|
state: absent
|
2018-10-08 11:41:52 +02:00
|
|
|
ntp_server:
|
2018-12-20 06:07:23 +01:00
|
|
|
- 0.pool.ntp.org
|
2018-10-08 11:41:52 +02:00
|
|
|
validate_certs: no
|
|
|
|
register: present
|
|
|
|
check_mode: yes
|
|
|
|
|
|
|
|
- debug: var=present
|
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- name: Configure NTP servers for a host in check mode
|
2018-10-08 11:41:52 +02:00
|
|
|
vmware_host_ntp:
|
|
|
|
hostname: "{{ vcsim }}"
|
|
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
|
|
esxi_hostname: "{{ host1 }}"
|
|
|
|
ntp_server:
|
|
|
|
- 0.pool.ntp.org
|
|
|
|
- 1.pool.ntp.org
|
|
|
|
- 2.pool.ntp.org
|
|
|
|
validate_certs: no
|
2018-12-20 06:07:23 +01:00
|
|
|
register: ntp_servers
|
2018-10-08 11:41:52 +02:00
|
|
|
check_mode: yes
|
|
|
|
|
2018-12-20 06:07:23 +01:00
|
|
|
- debug: var=ntp_servers
|