2018-04-19 11:41:04 +02:00
|
|
|
# Test code for the vmware_cluster_facts 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)
|
|
|
|
|
2019-04-30 11:38:44 +02:00
|
|
|
- import_role:
|
|
|
|
name: prepare_vmware_tests
|
2018-04-19 11:41:04 +02:00
|
|
|
|
2019-04-30 11:38:44 +02:00
|
|
|
- &vc_all_data
|
|
|
|
name: gather facts about all clusters in the given datacenter
|
2018-04-19 11:41:04 +02:00
|
|
|
vmware_cluster_facts:
|
2019-04-30 11:38:44 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2018-04-19 11:41:04 +02:00
|
|
|
validate_certs: False
|
2019-04-30 11:38:44 +02:00
|
|
|
datacenter: "{{ dc1 }}"
|
2018-04-19 11:41:04 +02:00
|
|
|
register: all_cluster_result
|
|
|
|
|
2019-04-30 11:38:44 +02:00
|
|
|
- &ensure_vc_all_data
|
|
|
|
name: ensure facts are gathered for all clusters
|
2018-04-19 11:41:04 +02:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- all_cluster_result.clusters
|
|
|
|
- not all_cluster_result.changed
|
|
|
|
|
2019-04-30 11:38:44 +02:00
|
|
|
- <<: *vc_all_data
|
|
|
|
name: Gather facts about all clusters in the given datacenter in check mode
|
|
|
|
check_mode: yes
|
|
|
|
|
|
|
|
- debug: msg=all_cluster_result
|
|
|
|
|
2019-07-24 12:15:15 +02:00
|
|
|
- <<: *ensure_vc_all_data
|
|
|
|
name: Ensure facts are gathered for all clusters in check mode
|
2019-04-30 11:38:44 +02:00
|
|
|
|
|
|
|
- &vc_cluster_data
|
|
|
|
name: Gather facts about the given cluster
|
2018-04-19 11:41:04 +02:00
|
|
|
vmware_cluster_facts:
|
2019-04-30 11:38:44 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2018-04-19 11:41:04 +02:00
|
|
|
validate_certs: False
|
2019-04-30 11:38:44 +02:00
|
|
|
cluster_name: "{{ ccr1 }}"
|
2018-04-19 11:41:04 +02:00
|
|
|
register: cluster_result
|
|
|
|
|
2019-04-30 11:38:44 +02:00
|
|
|
- &ensure_vc_cluster_data
|
|
|
|
name: Ensure facts are gathered for the given cluster
|
2018-04-19 11:41:04 +02:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- cluster_result.clusters
|
2019-04-30 11:38:44 +02:00
|
|
|
- not cluster_result.changed
|
|
|
|
|
|
|
|
- <<: *vc_cluster_data
|
|
|
|
name: Gather facts about the given cluster in check mode
|
|
|
|
check_mode: yes
|
|
|
|
|
2019-07-24 12:15:15 +02:00
|
|
|
- <<: *ensure_vc_cluster_data
|
|
|
|
name: Ensure facts are gathered for the given cluster in check mode
|
|
|
|
|
|
|
|
|
|
|
|
- when: vcsim is not defined
|
|
|
|
block:
|
|
|
|
- import_role:
|
|
|
|
name: prepare_vmware_tests
|
|
|
|
vars:
|
|
|
|
setup_category: true
|
|
|
|
setup_tag: true
|
|
|
|
|
|
|
|
- name: Apply tag to cluster
|
|
|
|
vmware_tag_manager:
|
2019-07-26 11:27:10 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2019-07-24 12:15:15 +02:00
|
|
|
validate_certs: no
|
|
|
|
tag_names:
|
|
|
|
- '{{ cluster_category }}:{{ cluster_tag }}'
|
|
|
|
state: present
|
2019-07-26 11:27:10 +02:00
|
|
|
object_name: '{{ ccr1 }}'
|
2019-07-24 12:15:15 +02:00
|
|
|
object_type: ClusterComputeResource
|
|
|
|
|
|
|
|
- name: Get facts about cluster
|
|
|
|
vmware_cluster_facts:
|
2019-07-26 11:27:10 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2019-07-24 12:15:15 +02:00
|
|
|
validate_certs: no
|
|
|
|
show_tag: True
|
2019-07-26 11:27:10 +02:00
|
|
|
cluster_name: "{{ ccr1 }}"
|
2019-07-24 12:15:15 +02:00
|
|
|
register: cluster_info
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- cluster_info is defined
|
2019-07-26 11:27:10 +02:00
|
|
|
- cluster_info.clusters[ccr1].tags is defined
|