1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

VMware: Add check mode support to module vmware_host_ntp (#46268)

This commit is contained in:
Christian Kotte 2018-10-08 11:41:52 +02:00 committed by Abhijeet Kasurde
parent c4cfeb183f
commit ccfa6ff011
2 changed files with 104 additions and 3 deletions

View file

@ -131,6 +131,9 @@ class VmwareNtpConfigManager(PyVmomi):
date_config_spec = vim.host.DateTimeConfig()
date_config_spec.ntpConfig = ntp_config_spec
try:
if self.module.check_mode:
self.results[host.name]['after_change_ntp_servers'] = available_ntp_servers
else:
host_date_time_manager.UpdateDateTimeConfig(date_config_spec)
self.results[host.name]['after_change_ntp_servers'] = host_date_time_manager.dateTimeInfo.ntpConfig.server
changed = True
@ -195,7 +198,8 @@ def main():
argument_spec=argument_spec,
required_one_of=[
['cluster_name', 'esxi_hostname'],
]
],
supports_check_mode=True
)
vmware_host_ntp_config = VmwareNtpConfigManager(module)

View file

@ -145,3 +145,100 @@
register: present
- debug: var=present
- name: Change facts about all hosts in given cluster in check mode
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
check_mode: yes
- debug: var=present
- name: Change facts about all hosts in given cluster in check mode
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
check_mode: yes
- debug: var=present
- name: Change facts about all hosts in given cluster in check mode
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
register: present
check_mode: yes
- debug: var=present
- name: Change facts about all hosts in given cluster in check mode
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
check_mode: yes
- debug: var=present
- name: Change facts about all hosts in given cluster in check mode
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
check_mode: yes
- debug: var=present
- name: Change facts about all hosts in given cluster in check mode
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
register: present
check_mode: yes
- debug: var=present