From 1589424c3e292a7ac12eb2e5fccd17548375d5b8 Mon Sep 17 00:00:00 2001 From: Christian Kotte Date: Wed, 3 Oct 2018 14:55:40 +0200 Subject: [PATCH] VMware: Add check mode support in vmware_host_config_facts (#46272) --- .../cloud/vmware/vmware_host_config_facts.py | 3 +- .../vmware_host_config_facts/tasks/main.yml | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_host_config_facts.py b/lib/ansible/modules/cloud/vmware/vmware_host_config_facts.py index 605689d753a..c2c9a21986f 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host_config_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host_config_facts.py @@ -106,7 +106,8 @@ def main(): argument_spec=argument_spec, required_one_of=[ ['cluster_name', 'esxi_hostname'], - ] + ], + supports_check_mode=True ) vmware_host_config = VmwareConfigFactsManager(module) diff --git a/test/integration/targets/vmware_host_config_facts/tasks/main.yml b/test/integration/targets/vmware_host_config_facts/tasks/main.yml index 9b89767db06..c89a11944ad 100644 --- a/test/integration/targets/vmware_host_config_facts/tasks/main.yml +++ b/test/integration/targets/vmware_host_config_facts/tasks/main.yml @@ -80,3 +80,33 @@ assert: that: - single_hosts_result.hosts_facts + +- name: gather facts about all hosts in given cluster in check mode + vmware_host_config_facts: + hostname: "{{ vcsim }}" + username: "{{ vcsim_instance.json.username }}" + password: "{{ vcsim_instance.json.password }}" + validate_certs: no + cluster_name: "{{ ccr1 }}" + register: all_hosts_result_check_mode + check_mode: yes + +- name: ensure facts are gathered for all hosts + assert: + that: + - all_hosts_result_check_mode.hosts_facts + +- name: gather facts about a given host in check mode + vmware_host_config_facts: + hostname: "{{ vcsim }}" + username: "{{ vcsim_instance.json.username }}" + password: "{{ vcsim_instance.json.password }}" + validate_certs: no + esxi_hostname: "{{ host1 }}" + register: single_hosts_result_check_mode + check_mode: yes + +- name: ensure facts are gathered for all hosts + assert: + that: + - single_hosts_result_check_mode.hosts_facts