mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
636f8cbdab
vmware: refactoring of vmware test roles -- part5
129 lines
4.9 KiB
YAML
129 lines
4.9 KiB
YAML
# Test code for the vmware_host_firewall_manager 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)
|
|
- when: vcsim is not defined
|
|
block:
|
|
- import_role:
|
|
name: prepare_vmware_tests
|
|
vars:
|
|
setup_attach_host: true
|
|
|
|
- name: Disable the Firewall vvold rule on the ESXi
|
|
vmware_host_firewall_manager:
|
|
hostname: '{{ vcenter_hostname }}'
|
|
username: '{{ vcenter_username }}'
|
|
password: '{{ vcenter_password }}'
|
|
cluster_name: '{{ ccr1 }}'
|
|
validate_certs: no
|
|
rules:
|
|
- name: vvold
|
|
enabled: False
|
|
|
|
- name: Enable vvold rule set on all hosts of {{ ccr1 }}
|
|
vmware_host_firewall_manager:
|
|
hostname: "{{ vcenter_hostname }}"
|
|
username: "{{ vcenter_username }}"
|
|
password: "{{ vcenter_password }}"
|
|
validate_certs: no
|
|
cluster_name: "{{ ccr1 }}"
|
|
rules:
|
|
- name: vvold
|
|
enabled: True
|
|
register: all_hosts_result
|
|
- debug: msg="{{ all_hosts_result }}"
|
|
- name: ensure everything is changed for all hosts of {{ ccr1 }}
|
|
assert:
|
|
that:
|
|
- all_hosts_result.changed
|
|
- all_hosts_result.rule_set_state is defined
|
|
|
|
- name: ensure facts are gathered for all hosts of {{ ccr1 }}
|
|
assert:
|
|
that:
|
|
- all_hosts_result.rule_set_state[item]['vvold']['current_state'] == True
|
|
- all_hosts_result.rule_set_state[item]['vvold']['desired_state'] == True
|
|
- all_hosts_result.rule_set_state[item]['vvold']['previous_state'] == False
|
|
with_items:
|
|
- '{{ hostvars[esxi1].ansible_host }}'
|
|
- '{{ hostvars[esxi2].ansible_host }}'
|
|
|
|
- name: Disable vvold for {{ host1 }}
|
|
vmware_host_firewall_manager:
|
|
hostname: "{{ vcenter_hostname }}"
|
|
username: "{{ vcenter_username }}"
|
|
password: "{{ vcenter_password }}"
|
|
validate_certs: no
|
|
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
|
|
rules:
|
|
- name: vvold
|
|
enabled: False
|
|
register: host_result
|
|
- debug: msg="{{ host_result }}"
|
|
- name: ensure vvold is disabled for {{ host1 }}
|
|
assert:
|
|
that:
|
|
- host_result.changed
|
|
- host_result.rule_set_state is defined
|
|
|
|
- name: ensure facts are gathered for {{ host1 }}
|
|
assert:
|
|
that:
|
|
- host_result.rule_set_state[item]['vvold']['current_state'] == False
|
|
- host_result.rule_set_state[item]['vvold']['desired_state'] == False
|
|
- host_result.rule_set_state[item]['vvold']['previous_state'] == True
|
|
with_items:
|
|
- '{{ hostvars[esxi1].ansible_host }}'
|
|
|
|
- name: Enable vvold rule set on all hosts of {{ ccr1 }} in check mode
|
|
vmware_host_firewall_manager:
|
|
hostname: "{{ vcenter_hostname }}"
|
|
username: "{{ vcenter_username }}"
|
|
password: "{{ vcenter_password }}"
|
|
validate_certs: no
|
|
cluster_name: "{{ ccr1 }}"
|
|
rules:
|
|
- name: vvold
|
|
enabled: True
|
|
register: all_hosts_result_check_mode
|
|
check_mode: yes
|
|
- debug: var=all_hosts_result_check_mode
|
|
- name: ensure everything is changed for all hosts of {{ ccr1 }}
|
|
assert:
|
|
that:
|
|
- all_hosts_result_check_mode.changed
|
|
- all_hosts_result_check_mode.rule_set_state is defined
|
|
|
|
- name: ensure facts are gathered for all hosts of {{ ccr1 }}
|
|
assert:
|
|
that:
|
|
- all_hosts_result_check_mode.rule_set_state[hostvars[esxi1].ansible_host]['vvold']['current_state'] == True
|
|
- all_hosts_result_check_mode.rule_set_state[hostvars[esxi2].ansible_host]['vvold']['current_state'] == True
|
|
- all_hosts_result_check_mode.rule_set_state[hostvars[esxi2].ansible_host]['vvold']['desired_state'] == True
|
|
|
|
- name: Disable vvold for {{ host1 }} in check mode
|
|
vmware_host_firewall_manager:
|
|
hostname: "{{ vcenter_hostname }}"
|
|
username: "{{ vcenter_username }}"
|
|
password: "{{ vcenter_password }}"
|
|
validate_certs: no
|
|
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
|
|
rules:
|
|
- name: vvold
|
|
enabled: False
|
|
register: host_result_check_mode
|
|
check_mode: yes
|
|
- debug: msg="{{ host_result_check_mode }}"
|
|
- name: ensure vvold is disabled for {{ host1 }}
|
|
assert:
|
|
that:
|
|
- host_result_check_mode.changed == False
|
|
- host_result_check_mode.rule_set_state is defined
|
|
|
|
- name: ensure facts are gathered for {{ host1 }}
|
|
assert:
|
|
that:
|
|
- host_result_check_mode.rule_set_state[item]['vvold']['current_state'] == False
|
|
- host_result_check_mode.rule_set_state[item]['vvold']['desired_state'] == False
|
|
- host_result_check_mode.rule_set_state[item]['vvold']['previous_state'] == False
|
|
with_items:
|
|
- '{{ hostvars[esxi1].ansible_host }}'
|