mirror of https://github.com/ansible/ansible.git
Merge pull request #55730 from goneri/vmware_refact_part5
vmware: refactoring of vmware test roles -- part5pull/55721/head
parent
39d1794ed9
commit
636f8cbdab
@ -1,2 +1,3 @@
|
||||
shippable/vcenter/group1
|
||||
cloud/vcenter
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,306 +1,175 @@
|
||||
# Test code for the vmware_host module.
|
||||
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 5000
|
||||
state: started
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
|
||||
- name: start vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?cluster=2
|
||||
register: vcsim_instance
|
||||
|
||||
- debug:
|
||||
var: vcsim_instance
|
||||
|
||||
- name: Wait for vcsim server to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 443
|
||||
state: started
|
||||
|
||||
- name: get a list of Datacenter from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=DC
|
||||
register: datacenters
|
||||
|
||||
- name: get a datacenter
|
||||
set_fact:
|
||||
dc1: "{{ datacenters.json[0] | basename }}"
|
||||
|
||||
- debug: var=dc1
|
||||
|
||||
- name: get a list of Cluster from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
|
||||
register: clusters
|
||||
|
||||
- name: get a cluster
|
||||
set_fact:
|
||||
ccr1: "{{ clusters.json[0] | basename }}"
|
||||
|
||||
- debug: var=ccr1
|
||||
|
||||
- name: get a list of hosts from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
register: hosts
|
||||
|
||||
- name: get a host
|
||||
set_fact:
|
||||
host1: "{{ hosts.json[0] | basename }}"
|
||||
|
||||
- debug: var=host1
|
||||
|
||||
# fetch_ssl_thumbprint needs to be disabled because the host only exists in vcsim
|
||||
|
||||
# Testcase: Add Host
|
||||
- name: add host
|
||||
vmware_host:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: test_host_system_0001
|
||||
esxi_username: "{{ vcsim_instance.json.username }}"
|
||||
esxi_password: "{{ vcsim_instance.json.password }}"
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
fetch_ssl_thumbprint: False
|
||||
state: present
|
||||
register: add_host_result
|
||||
|
||||
- name: get a list of host system from vcsim after adding host system
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
register: host_list
|
||||
|
||||
- name: ensure host system is present
|
||||
assert:
|
||||
that:
|
||||
- add_host_result is changed
|
||||
- "{% for host in host_list.json if ((host | basename) == 'test_host_system_0001') -%} True {%- else -%} False {%- endfor %}"
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
|
||||
- name: Add first ESXi Host to vCenter
|
||||
vmware_host:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter_name: '{{ dc1 }}'
|
||||
cluster_name: '{{ ccr1 }}'
|
||||
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
esxi_username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
state: present
|
||||
validate_certs: no
|
||||
register: readd_host_result
|
||||
|
||||
- name: Add first ESXi Host to vCenter (again)
|
||||
vmware_host:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter_name: '{{ dc1 }}'
|
||||
cluster_name: '{{ ccr1 }}'
|
||||
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
esxi_username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
state: present
|
||||
validate_certs: no
|
||||
register: readd_host_result
|
||||
|
||||
- name: ensure precend task didn't changed anything
|
||||
assert:
|
||||
that:
|
||||
- not ( readd_host_result is changed)
|
||||
|
||||
- name: add second host via add_or_reconnect
|
||||
vmware_host:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
|
||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
fetch_ssl_thumbprint: False
|
||||
state: add_or_reconnect
|
||||
register: add_or_reconnect_host_result
|
||||
- name: ensure host system is present
|
||||
assert:
|
||||
that:
|
||||
- add_or_reconnect_host_result is changed
|
||||
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- name: disconnect host 2
|
||||
vmware_host:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
fetch_ssl_thumbprint: False
|
||||
state: absent
|
||||
|
||||
- name: remove host again
|
||||
vmware_host:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
state: absent
|
||||
register: reremove_host_result
|
||||
- name: ensure precend task didn't changed anything
|
||||
assert:
|
||||
that:
|
||||
- not ( reremove_host_result is changed)
|
||||
|
||||
# Testcase: Add Host again
|
||||
- name: add host again
|
||||
vmware_host:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: test_host_system_0001
|
||||
esxi_username: "{{ vcsim_instance.json.username }}"
|
||||
esxi_password: "{{ vcsim_instance.json.password }}"
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
fetch_ssl_thumbprint: False
|
||||
state: present
|
||||
register: readd_host_result
|
||||
|
||||
- name: ensure precend task didn't changed anything
|
||||
assert:
|
||||
that:
|
||||
- not ( readd_host_result is changed)
|
||||
|
||||
# Testcase: Add Host via add_or_reconnect state
|
||||
- name: add host via add_or_reconnect
|
||||
vmware_host:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: test_host_system_0002
|
||||
esxi_username: "{{ vcsim_instance.json.username }}"
|
||||
esxi_password: "{{ vcsim_instance.json.password }}"
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
fetch_ssl_thumbprint: False
|
||||
state: add_or_reconnect
|
||||
register: add_or_reconnect_host_result
|
||||
|
||||
- name: get a list of host system from vcsim after adding host system
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
register: host_list
|
||||
|
||||
- name: ensure host system is present
|
||||
assert:
|
||||
that:
|
||||
- add_or_reconnect_host_result is changed
|
||||
- "{% for host in host_list.json if ((host | basename) == 'test_host_system_0002') -%} True {%- else -%} False {%- endfor %}"
|
||||
|
||||
## Testcase: Add Host to folder
|
||||
#
|
||||
# It's not possible to connect an ESXi host via vcsim.
|
||||
#
|
||||
# - name: Create host folder
|
||||
# vcenter_folder:
|
||||
# hostname: "{{ vcsim }}"
|
||||
# username: "{{ vcsim_instance.json.username }}"
|
||||
# password: "{{ vcsim_instance.json.password }}"
|
||||
# validate_certs: no
|
||||
# datacenter: "{{ dc1 }}"
|
||||
# folder_name: "Staging"
|
||||
# folder_type: host
|
||||
# state: present
|
||||
# register: folder_results
|
||||
#
|
||||
# - debug: msg="{{ folder_results }}"
|
||||
#
|
||||
# - name: ensure folder is present
|
||||
# assert:
|
||||
# that:
|
||||
# - folder_results.changed
|
||||
#
|
||||
# - name: Create host folder again
|
||||
# vcenter_folder:
|
||||
# hostname: "{{ vcsim }}"
|
||||
# username: "{{ vcsim_instance.json.username }}"
|
||||
# password: "{{ vcsim_instance.json.password }}"
|
||||
# validate_certs: no
|
||||
# datacenter: "{{ dc1 }}"
|
||||
# folder_name: "Staging"
|
||||
# folder_type: host
|
||||
# state: present
|
||||
# register: folder_results
|
||||
#
|
||||
# - debug: msg="{{ folder_results }}"
|
||||
#
|
||||
# - name: ensure folder is present
|
||||
# assert:
|
||||
# that:
|
||||
# - folder_results.changed == False
|
||||
#
|
||||
# - name: Add host to folder in check mode
|
||||
# vmware_host:
|
||||
# hostname: "{{ vcsim }}"
|
||||
# username: "{{ vcsim_instance.json.username }}"
|
||||
# password: "{{ vcsim_instance.json.password }}"
|
||||
# validate_certs: no
|
||||
# esxi_hostname: test_host_system_0003
|
||||
# esxi_username: "{{ vcsim_instance.json.username }}"
|
||||
# esxi_password: "{{ vcsim_instance.json.password }}"
|
||||
# datacenter_name: "{{ dc1 }}"
|
||||
# folder_name: "Staging"
|
||||
# state: present
|
||||
# register: add_host_to_folder_result
|
||||
# check_mode: yes
|
||||
#
|
||||
# - name: get a list of host system from vcsim after adding host system
|
||||
# uri:
|
||||
# url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
# register: host_list
|
||||
#
|
||||
# - name: ensure host system is not present
|
||||
# assert:
|
||||
# that:
|
||||
# - add_host_to_folder_result is changed
|
||||
# - not ("{% for host in host_list.json if ((host | basename) == 'test_host_system_0003') -%} True {%- else -%} False {%- endfor %}")
|
||||
#
|
||||
# - name: Add host to folder
|
||||
# vmware_host:
|
||||
# hostname: "{{ vcsim }}"
|
||||
# username: "{{ vcsim_instance.json.username }}"
|
||||
# password: "{{ vcsim_instance.json.password }}"
|
||||
# validate_certs: no
|
||||
# esxi_hostname: test_host_system_0003
|
||||
# esxi_username: "{{ vcsim_instance.json.username }}"
|
||||
# esxi_password: "{{ vcsim_instance.json.password }}"
|
||||
# datacenter_name: "{{ dc1 }}"
|
||||
# folder_name: "Staging"
|
||||
# state: present
|
||||
# register: add_host_to_folder_result
|
||||
#
|
||||
# - name: get a list of host system from vcsim after adding host system
|
||||
# uri:
|
||||
# url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
# register: host_list
|
||||
#
|
||||
# - name: ensure host system is present
|
||||
# assert:
|
||||
# that:
|
||||
# - add_host_to_folder_result is changed
|
||||
# - "{% for host in host_list.json if ((host | basename) == 'test_host_system_0003') -%} True {%- else -%} False {%- endfor %}"
|
||||
|
||||
## Testcase: Reconnect Host
|
||||
#
|
||||
# ReconnectHost_Task need to be implemented in vcsim for this test to work
|
||||
# https://github.com/vmware/govmomi/tree/master/vcsim#supported-methods
|
||||
#
|
||||
#- name: reconnect host
|
||||
# vmware_host:
|
||||
# hostname: "{{ vcsim }}"
|
||||
# username: "{{ vcsim_instance.json.username }}"
|
||||
# password: "{{ vcsim_instance.json.password }}"
|
||||
# validate_certs: no
|
||||
# esxi_hostname: test_host_system_0001
|
||||
# datacenter_name: "{{ dc1 }}"
|
||||
# cluster_name: "{{ ccr1 }}"
|
||||
# state: reconnect
|
||||
# register: reconnect_host_result
|
||||
#
|
||||
#- name: ensure host system has been reconnected
|
||||
# assert:
|
||||
# that:
|
||||
# - reconnect_host_result is changed
|
||||
# # it would be a good idea to check the events on the host to see the reconnect
|
||||
# # https://github.com/vmware/govmomi/blob/master/govc/USAGE.md#events
|
||||
# # "govc events ..." need to be callable from
|
||||
# # https://github.com/ansible/vcenter-test-container/flask_control.py
|
||||
|
||||
## Testcase: Remove Host
|
||||
#
|
||||
# EnterMaintenanceMode_Task need to be implemented in vcsim for this test to work
|
||||
# https://github.com/vmware/govmomi/tree/master/vcsim#supported-methods
|
||||
#
|
||||
#- name: remove host
|
||||
# vmware_host:
|
||||
# hostname: "{{ vcsim }}"
|
||||
# username: "{{ vcsim_instance.json.username }}"
|
||||
# password: "{{ vcsim_instance.json.password }}"
|
||||
# validate_certs: no
|
||||
# esxi_hostname: test_host_system_0001
|
||||
# datacenter_name: "{{ dc1 }}"
|
||||
# cluster_name: "{{ ccr1 }}"
|
||||
# state: absent
|
||||
# register: remove_host_result
|
||||
#
|
||||
#- name: get a list of host system from vcsim after removing host system
|
||||
# uri:
|
||||
# url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
# register: host_list
|
||||
#
|
||||
#- name: ensure host system is absent
|
||||
# assert:
|
||||
# that:
|
||||
# - remove_host_result is changed
|
||||
# - "{% for host in host_list.json if ((host | basename) == 'test_host_system_0001') -%} False {%- else -%} True {%- endfor %}"
|
||||
|
||||
## Testcase: Remove Host again
|
||||
#
|
||||
# EnterMaintenanceMode_Task need to be implemented in vcsim for this test to work
|
||||
# https://github.com/vmware/govmomi/tree/master/vcsim#supported-methods
|
||||
#
|
||||
#- name: remove host again
|
||||
# vmware_host:
|
||||
# hostname: "{{ vcsim }}"
|
||||
# username: "{{ vcsim_instance.json.username }}"
|
||||
# password: "{{ vcsim_instance.json.password }}"
|
||||
# validate_certs: no
|
||||
# esxi_hostname: test_host_system_0001
|
||||
# datacenter_name: "{{ dc1 }}"
|
||||
# cluster_name: "{{ ccr1 }}"
|
||||
# state: absent
|
||||
# register: reremove_host_result
|
||||
#
|
||||
#- name: ensure precend task didn't changed anything
|
||||
# assert:
|
||||
# that:
|
||||
# - not ( reremove_host_result is changed)
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- name: Create host folder
|
||||
vcenter_folder:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder_name: "Staging"
|
||||
folder_type: host
|
||||
state: present
|
||||
register: folder_results
|
||||
|
||||
- debug: msg="{{ folder_results }}"
|
||||
|
||||
- name: ensure folder is present
|
||||
assert:
|
||||
that:
|
||||
- folder_results.changed
|
||||
|
||||
- name: Add host to folder in check mode
|
||||
vmware_host:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
|
||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
folder_name: "/{{ dc1 }}/host/Staging"
|
||||
state: present
|
||||
register: add_host_to_folder_result
|
||||
check_mode: yes
|
||||
|
||||
- name: ensure host system is not present
|
||||
assert:
|
||||
that:
|
||||
- add_host_to_folder_result is changed
|
||||
|
||||
- name: Add host to folder
|
||||
vmware_host:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
|
||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
folder_name: "/{{ dc1 }}/host/Staging"
|
||||
state: present
|
||||
register: add_host_to_folder_result
|
||||
|
||||
- name: ensure host system is present
|
||||
assert:
|
||||
that:
|
||||
- add_host_to_folder_result is changed
|
||||
|
||||
- name: reconnect host
|
||||
vmware_host:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
|
||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
state: reconnect
|
||||
register: reconnect_host_result
|
||||
|
||||
- name: ensure host system has been reconnected
|
||||
assert:
|
||||
that:
|
||||
- reconnect_host_result is changed
|
||||
# it would be a good idea to check the events on the host to see the reconnect
|
||||
# https://github.com/vmware/govmomi/blob/master/govc/USAGE.md#events
|
||||
# "govc events ..." need to be callable from
|
||||
# https://github.com/ansible/vcenter-test-container/flask_control.py
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
shippable/vcenter/group1
|
||||
cloud/vcenter
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,3 +1,4 @@
|
||||
shippable/vcenter/group1
|
||||
cloud/vcenter
|
||||
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,28 +1,34 @@
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: "{{ 'http://' + vcsim + ':5000/killall' }}"
|
||||
- name: start vcsim
|
||||
uri:
|
||||
url: "{{ 'http://' + vcsim + ':5000/spawn?cluster=2' }}"
|
||||
register: vcsim_instance
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_attach_host: true
|
||||
- name: get host facts through a vcenter
|
||||
vmware_host_facts:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
register: facts
|
||||
- debug: var=facts
|
||||
- name: verify some data,like ansible_processor
|
||||
assert:
|
||||
that:
|
||||
- "'ansible_hostname' in facts['ansible_facts']"
|
||||
- "'ansible_processor' in facts['ansible_facts']"
|
||||
|
||||
- name: get host facts
|
||||
vmware_host_facts:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
register: facts
|
||||
|
||||
- debug: var=facts
|
||||
|
||||
- name: get host info
|
||||
uri:
|
||||
url: "{{ 'http://' + vcsim + ':5000/govc_host_info' }}"
|
||||
register: host_info_result
|
||||
|
||||
- name: verify some data,like ansible_processor
|
||||
assert:
|
||||
that:
|
||||
- facts['ansible_facts']['ansible_hostname'] in host_info_result['json']
|
||||
- facts['ansible_facts']['ansible_processor'] == host_info_result['json'][facts['ansible_facts']['ansible_hostname']]['Processor type']
|
||||
- name: get host facts through from a host
|
||||
vmware_host_facts:
|
||||
validate_certs: False
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
register: facts
|
||||
- debug: var=facts
|
||||
- name: verify some data,like ansible_processor
|
||||
assert:
|
||||
that:
|
||||
- "'ansible_hostname' in facts['ansible_facts']"
|
||||
- "'ansible_processor' in facts['ansible_facts']"
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,3 +1,4 @@
|
||||
shippable/vcenter/group1
|
||||
cloud/vcenter
|
||||
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
shippable/vcenter/group1
|
||||
cloud/vcenter
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,170 +1,129 @@
|
||||
# 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)
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 5000
|
||||
state: started
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
|
||||
- name: start vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?cluster=2
|
||||
register: vcsim_instance
|
||||
|
||||
- debug:
|
||||
var: vcsim_instance
|
||||
|
||||
- name: Wait for vcsim server to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 443
|
||||
state: started
|
||||
|
||||
- name: get a list of Cluster from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
|
||||
register: clusters
|
||||
|
||||
- name: get a cluster
|
||||
set_fact:
|
||||
ccr1: "{{ clusters.json[0] | basename }}"
|
||||
|
||||
- name: get a list of hosts from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
register: hosts
|
||||
|
||||
- name: get a cluster
|
||||
set_fact:
|
||||
host1: "{{ hosts.json[0] | basename }}"
|
||||
|
||||
- debug: var=ccr1
|
||||
- debug: var=host1
|
||||
|
||||
- name: Enable vvold rule set on all hosts of {{ ccr1 }}
|
||||
vmware_host_firewall_manager:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.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:
|
||||
- DC0_C0_H0
|
||||
- DC0_C0_H1
|
||||
- DC0_C0_H2
|
||||
|
||||
- name: Disable vvold for {{ host1 }}
|
||||
vmware_host_firewall_manager:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: "{{ host1 }}"
|
||||
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:
|
||||
- "{{ host1 }}"
|
||||
|
||||
- name: Enable vvold rule set on all hosts of {{ ccr1 }} in check mode
|
||||
vmware_host_firewall_manager:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
validate_certs: no
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
rules:
|
||||
- name: vvold
|
||||
enabled: True
|
||||
register: all_hosts_result_check_mode
|
||||
check_mode: yes
|
||||
|
||||
- debug: msg="{{ 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[item]['vvold']['current_state'] == True
|
||||
- all_hosts_result_check_mode.rule_set_state[item]['vvold']['desired_state'] == True
|
||||
- all_hosts_result_check_mode.rule_set_state[item]['vvold']['previous_state'] == False
|
||||
with_items:
|
||||
- DC0_C0_H0
|
||||
- DC0_C0_H1
|
||||
- DC0_C0_H2
|
||||
|
||||
- name: Disable vvold for {{ host1 }} in check mode
|
||||
vmware_host_firewall_manager:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: "{{ host1 }}"
|
||||
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:
|
||||
- "{{ host1 }}"
|
||||
- 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 }}'
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
shippable/vcenter/group1
|
||||
cloud/vcenter
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,118 +1,81 @@
|
||||
# Test code for the vmware_host_ipv6 module.
|
||||
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 5000
|
||||
state: started
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
|
||||
- name: start vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?cluster=2
|
||||
register: vcsim_instance
|
||||
|
||||
- debug:
|
||||
var: vcsim_instance
|
||||
|
||||
- name: Wait for vcsim server to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 443
|
||||
state: started
|
||||
|
||||
- name: get a list of clusters from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
|
||||
register: clusters
|
||||
|
||||
- name: get a cluster
|
||||
set_fact:
|
||||
ccr1: "{{ clusters.json[0] | basename }}"
|
||||
|
||||
- name: get a list of hosts from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
register: hosts
|
||||
|
||||
- name: get a host
|
||||
set_fact:
|
||||
host1: "{{ hosts.json[0] | basename }}"
|
||||
|
||||
- debug: var=ccr1
|
||||
- debug: var=host1
|
||||
|
||||
- name: Enable IPv6 support for a given host
|
||||
vmware_host_ipv6:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
esxi_hostname: "{{ host1 }}"
|
||||
validate_certs: no
|
||||
state: enabled
|
||||
register: host_ipv6_facts
|
||||
|
||||
- debug: var=host_ipv6_facts
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- host_ipv6_facts is defined
|
||||
- host_ipv6_facts.changed
|
||||
|
||||
- name: Enable IPv6 support for a given host in check mode
|
||||
vmware_host_ipv6:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
esxi_hostname: "{{ host1 }}"
|
||||
validate_certs: no
|
||||
state: enabled
|
||||
register: host_ipv6_facts_check_mode
|
||||
check_mode: yes
|
||||
|
||||
- debug: var=host_ipv6_facts_check_mode
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- host_ipv6_facts_check_mode is defined
|
||||
- host_ipv6_facts_check_mode.changed
|
||||
|
||||
- name: Enable IPv6 support for all hosts in given cluster
|
||||
vmware_host_ipv6:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
validate_certs: no
|
||||
state: enabled
|
||||
register: hosts_ipv6_facts
|
||||
|
||||
- debug: var=hosts_ipv6_facts
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- hosts_ipv6_facts is defined
|
||||
- hosts_ipv6_facts.changed
|
||||
|
||||
- name: Enable IPv6 support for all hosts in given cluster in check mode
|
||||
vmware_host_ipv6:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
validate_certs: no
|
||||
state: enabled
|
||||
register: hosts_ipv6_facts_check_mode
|
||||
check_mode: yes
|
||||
|
||||
- debug: var=hosts_ipv6_facts_check_mode
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- hosts_ipv6_facts_check_mode is defined
|
||||
- hosts_ipv6_facts_check_mode.changed
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_attach_host: true
|
||||
|
||||
- name: Ensure IPv6 is off
|
||||
vmware_host_ipv6:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
validate_certs: no
|
||||
state: disabled
|
||||
register: host_ipv6_facts
|
||||
|
||||
- name: Enable IPv6 support for a given host
|
||||
vmware_host_ipv6:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
validate_certs: no
|
||||
state: enabled
|
||||
register: host_ipv6_facts
|
||||
- debug: var=host_ipv6_facts
|
||||
- assert:
|
||||
that:
|
||||
- host_ipv6_facts is defined
|
||||
- host_ipv6_facts.changed
|
||||
|
||||
- name: Enable IPv6 support for a given host in check mode
|
||||
vmware_host_ipv6:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
validate_certs: no
|
||||
state: enabled
|
||||
register: host_ipv6_facts_check_mode
|
||||
check_mode: yes
|
||||
- debug: var=host_ipv6_facts_check_mode
|
||||
- assert:
|
||||
that:
|
||||
- host_ipv6_facts_check_mode is defined
|
||||
- not (host_ipv6_facts_check_mode is changed)
|
||||
|
||||
- name: Enable IPv6 support for all hosts in given cluster
|
||||
vmware_host_ipv6:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
validate_certs: no
|
||||
state: enabled
|
||||
register: hosts_ipv6_facts
|
||||
- debug: var=hosts_ipv6_facts
|
||||
- assert:
|
||||
that:
|
||||
- hosts_ipv6_facts is defined
|
||||
- hosts_ipv6_facts.changed
|
||||
|
||||
- name: Enable IPv6 support for all hosts in given cluster in check mode
|
||||
vmware_host_ipv6:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
validate_certs: no
|
||||
state: enabled
|
||||
register: hosts_ipv6_facts_check_mode
|
||||
check_mode: yes
|
||||
- debug: var=hosts_ipv6_facts_check_mode
|
||||
- assert:
|
||||
that:
|
||||
- hosts_ipv6_facts_check_mode is defined
|
||||
- not (hosts_ipv6_facts_check_mode is changed)
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,66 +1,42 @@
|
||||
# test code for the vmware_host_kernel_manager module
|
||||
# Copyright: (c) 2019, Aaron Longchamps <a.j.longchamps@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 5000
|
||||
state: started
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
|
||||
- name: start vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&host=1
|
||||
register: vcsim_instance
|
||||
|
||||
- debug: var=vcsim_instance
|
||||
|
||||
- name: Wait for vcsim server to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 443
|
||||
state: started
|
||||
|
||||
- name: get a list of hosts from vcsim
|
||||
uri:
|
||||
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=host' }}"
|
||||
register: hostlist
|
||||
|
||||
- set_fact:
|
||||
host1: "{{ hostlist['json'][0] }}"
|
||||
|
||||
- name: host connected, module exists, options exist, arguments different
|
||||
vmware_host_kernel_manager:
|
||||
hostname: '{{ vcsim }}'
|
||||
username: '{{ vcsim_instance.json.username }}'
|
||||
password: '{{ vcsim_instance.json.password }}'
|
||||
validate_certs: False
|
||||
esxi_hostname: '{{ host1 }}'
|
||||
kernel_module_name: "tcpip4"
|
||||
kernel_module_option: "ipv6=0"
|
||||
register: my_results_01
|
||||
|
||||
- name: Check that the provided kernel_module_name has kernel_module_option set
|
||||
assert:
|
||||
that:
|
||||
- "my_results_01.results['DC0_H0']['configured_options'] == 'ipv6=0'"
|
||||
|
||||
- name: host connected, module exists, same options for idempotence test
|
||||
vmware_host_kernel_manager:
|
||||
hostname: '{{ vcsim }}'
|
||||
username: '{{ vcsim_instance.json.username }}'
|
||||
password: '{{ vcsim_instance.json.password }}'
|
||||
validate_certs: False
|
||||
esxi_hostname: '{{ host1 }}'
|
||||
kernel_module_name: "tcpip4"
|
||||
kernel_module_option: "ipv6=0"
|
||||
register: my_results_02
|
||||
|
||||
- name: Check that changed is false
|
||||
assert:
|
||||
that:
|
||||
- "my_results_02.results['DC0_H0']['changed'] == false"
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_attach_host: true
|
||||
setup_datastore: true
|
||||
|
||||
- name: host connected, module exists, options exist, arguments different
|
||||
vmware_host_kernel_manager:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
validate_certs: False
|
||||
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
kernel_module_name: "tcpip4"
|
||||
kernel_module_option: "ipv6=0"
|
||||
register: my_results_01
|
||||
- debug: var=my_results_01
|
||||
- name: Check that the provided kernel_module_name has kernel_module_option set
|
||||
assert:
|
||||
that:
|
||||
- "'original_options' in my_results_01['ansible_module_results']['{{ hostvars[esxi1].ansible_host }}']"
|
||||
- "my_results_01['ansible_module_results']['{{ hostvars[esxi1].ansible_host }}'].original_options == 'ipv6=0'"
|
||||
|
||||
- name: host connected, module exists, same options for idempotence test
|
||||
vmware_host_kernel_manager:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
validate_certs: False
|
||||
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
kernel_module_name: "tcpip4"
|
||||
kernel_module_option: "ipv6=0"
|
||||
register: my_results_02
|
||||
- name: Check that changed is false
|
||||
assert:
|
||||
that:
|
||||
- not (my_results_02 is changed)
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
shippable/vcenter/group1
|
||||
unsupported
|
||||
cloud/vcenter
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,80 +1,25 @@
|
||||
# Test code for the vmware_host_scanhba module.
|
||||
# Copyright: (c) 2019, Michael Eaton <me@michaeleaton.me>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 5000
|
||||
state: started
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
|
||||
- name: start vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?cluster=2
|
||||
register: vcsim_instance
|
||||
|
||||
- debug:
|
||||
var: vcsim_instance
|
||||
|
||||
- name: Wait for vcsim server to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 443
|
||||
state: started
|
||||
|
||||
- name: get a list of Datacenter from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=DC
|
||||
register: datacenters
|
||||
|
||||
- name: get a datacenter
|
||||
set_fact:
|
||||
dc1: "{{ datacenters.json[0] | basename }}"
|
||||
|
||||
- debug: var=dc1
|
||||
|
||||
- name: get a list of Cluster from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
|
||||
register: clusters
|
||||
|
||||
- name: get a cluster
|
||||
set_fact:
|
||||
ccr1: "{{ clusters.json[0] | basename }}"
|
||||
|
||||
- debug: var=ccr1
|
||||
|
||||
- name: add host
|
||||
vmware_host:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: test_host_system_0001
|
||||
esxi_username: "{{ vcsim_instance.json.username }}"
|
||||
esxi_password: "{{ vcsim_instance.json.password }}"
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
state: present
|
||||
|
||||
- name: Recan HBA's for an entire cluster (there should be at least one host as above)
|
||||
vmware_host_scanhba:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance.json.username }}"
|
||||
password: "{{ vcsim_instance.json.password }}"
|
||||
validate_certs: no
|
||||
cluster_name: '{{ ccr1 }}'
|
||||
refresh_storage: false
|
||||
register: host_scan_results
|
||||
|
||||
- debug: msg="{{ host_scan_results }}"
|
||||
|
||||
- name: ensure a change occured (as in the scan happened) and the task didnt fail
|
||||
assert:
|
||||
that:
|
||||
- host_scan_results.changed
|
||||
- not host_scan_results.failed
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_attach_host: true
|
||||
|
||||
- name: Recan HBA's for an entire cluster (there should be at least one host as above)
|
||||
vmware_host_scanhba:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
cluster_name: '{{ ccr1 }}'
|
||||
refresh_storage: false
|
||||
register: host_scan_results
|
||||
- debug: msg="{{ host_scan_results }}"
|
||||
- name: ensure a change occured (as in the scan happened) and the task didnt fail
|
||||
assert:
|
||||
that:
|
||||
- host_scan_results.changed
|
||||
- not host_scan_results.failed
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
shippable/vcenter/group1
|
||||
cloud/vcenter
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
Loading…
Reference in New Issue