VMware: Add check mode support to module vmware_host_acceptance (#46260)
* Improve module description * Add check mode support
This commit is contained in:
parent
0dc7f38787
commit
ab26119637
2 changed files with 27 additions and 4 deletions
|
@ -17,9 +17,10 @@ ANSIBLE_METADATA = {
|
|||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: vmware_host_acceptance
|
||||
short_description: Manage acceptance level of ESXi host
|
||||
short_description: Manage the host acceptance level of an ESXi host
|
||||
description:
|
||||
- This module can be used to manage acceptance level of an ESXi host.
|
||||
- This module can be used to manage the host acceptance level of an ESXi host.
|
||||
- The host acceptance level controls the acceptance level of each VIB on a ESXi host.
|
||||
version_added: '2.5'
|
||||
author:
|
||||
- Abhijeet Kasurde (@Akasurde)
|
||||
|
@ -139,9 +140,12 @@ class VMwareAccpetanceManager(PyVmomi):
|
|||
host_image_config_mgr = host.configManager.imageConfigManager
|
||||
if host_image_config_mgr:
|
||||
try:
|
||||
if self.module.check_mode:
|
||||
self.hosts_facts[host.name]['level'] = self.acceptance_level
|
||||
else:
|
||||
host_image_config_mgr.UpdateHostImageAcceptanceLevel(newAcceptanceLevel=self.acceptance_level)
|
||||
host_changed = True
|
||||
self.hosts_facts[host.name]['level'] = host_image_config_mgr.HostImageConfigGetAcceptance()
|
||||
host_changed = True
|
||||
except vim.fault.HostConfigFault as e:
|
||||
self.hosts_facts[host.name]['error'] = to_native(e.msg)
|
||||
|
||||
|
@ -176,6 +180,7 @@ def main():
|
|||
required_if=[
|
||||
['state', 'present', ['acceptance_level']],
|
||||
],
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
vmware_host_accept_config = VMwareAccpetanceManager(module)
|
||||
|
|
|
@ -61,3 +61,21 @@
|
|||
- assert:
|
||||
that:
|
||||
- host_acceptance_facts.facts is defined
|
||||
|
||||
- name: Change acceptance level of given hosts in check mode
|
||||
vmware_host_acceptance:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ user }}"
|
||||
password: "{{ passwd }}"
|
||||
esxi_hostname: "{{ host1 }}"
|
||||
validate_certs: no
|
||||
acceptance_level: vmware_certified
|
||||
state: present
|
||||
register: host_acceptance_facts_check_mode
|
||||
check_mode: yes
|
||||
|
||||
- debug: var=host_acceptance_facts_check_mode
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- host_acceptance_facts_check_mode.facts is defined
|
||||
|
|
Loading…
Reference in a new issue