Merge pull request #55730 from goneri/vmware_refact_part5

vmware: refactoring of vmware test roles -- part5
pull/55721/head
Gonéri Le Bouder 7 years ago committed by GitHub
parent 39d1794ed9
commit 636f8cbdab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -1,306 +1,175 @@
# Test code for the vmware_host module. # Test code for the vmware_host module.
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Testcase: Add Host
- when: vcsim is not defined
block:
- name: Wait for Flask controller to come up online - name: Add first ESXi Host to vCenter
wait_for: vmware_host:
host: "{{ vcsim }}" hostname: '{{ vcenter_hostname }}'
port: 5000 username: '{{ vcenter_username }}'
state: started password: '{{ vcenter_password }}'
datacenter_name: '{{ dc1 }}'
- name: kill vcsim cluster_name: '{{ ccr1 }}'
uri: esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
url: http://{{ vcsim }}:5000/killall esxi_username: '{{ hostvars[esxi1].ansible_user }}'
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
- name: start vcsim state: present
uri: validate_certs: no
url: http://{{ vcsim }}:5000/spawn?cluster=2 register: readd_host_result
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 - name: Add first ESXi Host to vCenter (again)
set_fact: vmware_host:
dc1: "{{ datacenters.json[0] | basename }}" 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
- debug: var=dc1 - name: ensure precend task didn't changed anything
assert:
that:
- not ( readd_host_result is changed)
- name: get a list of Cluster from vcsim - name: add second host via add_or_reconnect
uri: vmware_host:
url: http://{{ vcsim }}:5000/govc_find?filter=CCR hostname: "{{ vcenter_hostname }}"
register: clusters 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
- name: get a cluster - when: vcsim is not defined
set_fact: block:
ccr1: "{{ clusters.json[0] | basename }}" - 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
- debug: var=ccr1 - 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)
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: get a host ## Testcase: Add Host to folder
set_fact: #
host1: "{{ hosts.json[0] | basename }}" # It's not possible to connect an ESXi host via vcsim.
- 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: var=host1 - debug: msg="{{ folder_results }}"
# fetch_ssl_thumbprint needs to be disabled because the host only exists in vcsim - name: ensure folder is present
assert:
that:
- folder_results.changed
# Testcase: Add Host - name: Add host to folder in check mode
- name: add host
vmware_host: vmware_host:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: test_host_system_0001 esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
esxi_username: "{{ vcsim_instance.json.username }}" esxi_username: '{{ hostvars[esxi2].ansible_user }}'
esxi_password: "{{ vcsim_instance.json.password }}" esxi_password: '{{ hostvars[esxi2].ansible_password }}'
datacenter_name: "{{ dc1 }}" datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}" folder_name: "/{{ dc1 }}/host/Staging"
fetch_ssl_thumbprint: False
state: present state: present
register: add_host_result 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 present - name: ensure host system is not present
assert: assert:
that: that:
- add_host_result is changed - add_host_to_folder_result is changed
- "{% for host in host_list.json if ((host | basename) == 'test_host_system_0001') -%} True {%- else -%} False {%- endfor %}"
# Testcase: Add Host again - name: Add host to folder
- name: add host again
vmware_host: vmware_host:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: test_host_system_0001 esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
esxi_username: "{{ vcsim_instance.json.username }}" esxi_username: '{{ hostvars[esxi2].ansible_user }}'
esxi_password: "{{ vcsim_instance.json.password }}" esxi_password: '{{ hostvars[esxi2].ansible_password }}'
datacenter_name: "{{ dc1 }}" datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}" folder_name: "/{{ dc1 }}/host/Staging"
fetch_ssl_thumbprint: False
state: present state: present
register: readd_host_result register: add_host_to_folder_result
- name: ensure precend task didn't changed anything - name: ensure host system is present
assert: assert:
that: that:
- not ( readd_host_result is changed) - add_host_to_folder_result is changed
# Testcase: Add Host via add_or_reconnect state - name: reconnect host
- name: add host via add_or_reconnect
vmware_host: vmware_host:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: test_host_system_0002 esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
esxi_username: "{{ vcsim_instance.json.username }}" esxi_username: '{{ hostvars[esxi2].ansible_user }}'
esxi_password: "{{ vcsim_instance.json.password }}" esxi_password: '{{ hostvars[esxi2].ansible_password }}'
datacenter_name: "{{ dc1 }}" datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
fetch_ssl_thumbprint: False state: reconnect
state: add_or_reconnect register: reconnect_host_result
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 - name: ensure host system has been reconnected
assert: assert:
that: that:
- add_or_reconnect_host_result is changed - reconnect_host_result is changed
- "{% for host in host_list.json if ((host | basename) == 'test_host_system_0002') -%} True {%- else -%} False {%- endfor %}" # 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
## Testcase: Add Host to folder # "govc events ..." need to be callable from
# # https://github.com/ansible/vcenter-test-container/flask_control.py
# 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)

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -2,74 +2,41 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support Acceptance Level related to operations - when: False
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim - name: Change acceptance level of given hosts
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 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
- name: Change acceptance level of given hosts
vmware_host_acceptance: vmware_host_acceptance:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ user }}" username: "{{ vcenter_username }}"
password: "{{ passwd }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
acceptance_level: vmware_certified acceptance_level: vmware_certified
state: present state: present
register: host_acceptance_facts register: host_acceptance_facts
- debug: var=host_acceptance_facts
- debug: var=host_acceptance_facts - assert:
- assert:
that: that:
- host_acceptance_facts.facts is defined - host_acceptance_facts.facts is defined
- name: Change acceptance level of given hosts in check mode - name: Change acceptance level of given hosts in check mode
vmware_host_acceptance: vmware_host_acceptance:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ user }}" username: "{{ vcenter_username }}"
password: "{{ passwd }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
acceptance_level: vmware_certified acceptance_level: vmware_certified
state: present state: present
register: host_acceptance_facts_check_mode register: host_acceptance_facts_check_mode
check_mode: yes check_mode: yes
- debug: var=host_acceptance_facts_check_mode
- debug: var=host_acceptance_facts_check_mode - assert:
- assert:
that: that:
- host_acceptance_facts_check_mode.facts is defined - host_acceptance_facts_check_mode.facts is defined

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -2,125 +2,86 @@
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de> # 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) # 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
# Active Directory domain isn't available # Active Directory domain isn't available
- name: Join an AD domain in check mode - when:
- vcsim is not defined
- active_directory_domain is defined
block:
- name: Join an AD domain in check mode
vmware_host_active_directory: vmware_host_active_directory:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ad_domain: example.local ad_domain: '{{ active_directory_domain }}'
ad_user: adjoin ad_user: '{{ active_directory_user }}'
ad_password: Password123$ ad_password: '{{ active_directory_password }}'
ad_state: present ad_state: present
validate_certs: no validate_certs: no
register: host_active_directory_facts_check_mode register: host_active_directory_facts_check_mode
check_mode: yes check_mode: yes
- debug: var=host_active_directory_facts_check_mode - debug: var=host_active_directory_facts_check_mode
- assert: - assert:
that: that:
- host_active_directory_facts_check_mode is defined - host_active_directory_facts_check_mode is defined
- host_active_directory_facts_check_mode.changed - host_active_directory_facts_check_mode.changed
- name: Join an AD domain - name: Join an AD domain
vmware_host_active_directory: vmware_host_active_directory:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ad_domain: example.local ad_domain: example.local
ad_user: adjoin ad_user: adjoin
ad_password: Password123$ ad_password: Password123$
ad_state: present ad_state: present
validate_certs: no validate_certs: no
register: host_active_directory_facts register: host_active_directory_facts
ignore_errors: true
- debug: var=host_active_directory_facts - debug: var=host_active_directory_facts
- assert: - assert:
that: that:
- host_active_directory_facts is defined - host_active_directory_facts is defined
- host_active_directory_facts.changed - host_active_directory_facts.changed
- name: Leave AD domain in check mode - name: Leave AD domain in check mode
vmware_host_active_directory: vmware_host_active_directory:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ad_state: absent ad_state: absent
validate_certs: no validate_certs: no
register: host_active_directory_facts_2_check_mode register: host_active_directory_facts_2_check_mode
check_mode: yes check_mode: yes
- debug: var=host_active_directory_facts_2_check_mode - debug: var=host_active_directory_facts_2_check_mode
- assert: - assert:
that: that:
- host_active_directory_facts_2_check_mode is defined - host_active_directory_facts_2_check_mode is defined
- host_active_directory_facts_2_check_mode.changed - host_active_directory_facts_2_check_mode.changed
- name: Leave AD domain - name: Leave AD domain
vmware_host_active_directory: vmware_host_active_directory:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ad_state: absent ad_state: absent
validate_certs: no validate_certs: no
register: host_active_directory_facts_2 register: host_active_directory_facts_2
ignore_errors: true
- debug: var=host_active_directory_facts_2 - debug: var=host_active_directory_facts_2
- assert: - assert:
that: that:
- host_active_directory_facts_2 is defined - host_active_directory_facts_2 is defined
- host_active_directory_facts_2.changed - host_active_directory_facts_2.changed

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -4,75 +4,35 @@
# TODO: vcsim does not support host system capabilities # TODO: vcsim does not support host system capabilities
- name: Wait for Flask controller to come up online - when: vcsim is not defined
wait_for: block:
host: "{{ vcsim }}" - import_role:
port: 5000 name: prepare_vmware_tests
state: started vars:
setup_attach_host: true
- name: kill vcsim
uri: - name: Gather capability facts for all ESXi host from given cluster
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 host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1
- debug: var=host1
- name: Gather capability facts for all ESXi host from given cluster
vmware_host_capability_facts: vmware_host_capability_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: False validate_certs: False
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
register: capability_0001_results register: capability_0001_results
- assert:
- assert:
that: that:
- "not capability_0001_results.changed" - not (capability_0001_results is changed)
- "capability_0001_results.hosts_capability_facts is defined" - capability_0001_results.hosts_capability_facts is defined
- name: Gather capability facts for ESXi host - name: Gather capability facts for ESXi host
vmware_host_capability_facts: vmware_host_capability_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: False validate_certs: False
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: capability_0002_results register: capability_0002_results
- assert:
- assert:
that: that:
- "not capability_0002_results.changed" - not (capability_0002_results is changed)
- "capability_0002_results.hosts_capability_facts is defined" - capability_0002_results.hosts_capability_facts is defined

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -1,85 +1,33 @@
# Test code for the vmware_host_config_facts module. # Test code for the vmware_host_config_facts module.
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- import_role:
- name: Wait for Flask controller to come up online name: prepare_vmware_tests
wait_for: vars:
host: "{{ vcsim }}" setup_attach_host: true
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: gather facts about all hosts in given cluster - name: gather facts about all hosts in given cluster
vmware_host_config_facts: vmware_host_config_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
register: all_hosts_result register: all_hosts_result
- name: ensure facts are gathered for all hosts - debug:
assert: var: all_hosts_result
that:
- all_hosts_result.hosts_facts
- name: gather facts about a given host
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
- name: ensure facts are gathered for all hosts - name: ensure facts are gathered for all hosts
assert: assert:
that: that:
- single_hosts_result.hosts_facts - all_hosts_result.hosts_facts
- name: gather facts about all hosts in given cluster in check mode - name: gather facts about all hosts in given cluster in check mode
vmware_host_config_facts: vmware_host_config_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
register: all_hosts_result_check_mode register: all_hosts_result_check_mode
@ -90,17 +38,31 @@
that: that:
- all_hosts_result_check_mode.hosts_facts - all_hosts_result_check_mode.hosts_facts
- name: gather facts about a given host in check mode - when: vcsim is not defined
block:
- name: gather facts about a given host in check mode
vmware_host_config_facts: vmware_host_config_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: "{{ host1 }}" esxi_hostname: "{{ hostvars[esxi1].ansible_host }}"
register: single_hosts_result_check_mode register: single_hosts_result_check_mode
check_mode: yes check_mode: yes
- name: ensure facts are gathered for all hosts
- name: ensure facts are gathered for all hosts
assert: assert:
that: that:
- single_hosts_result_check_mode.hosts_facts - single_hosts_result_check_mode.hosts_facts
- name: gather facts about a given host
vmware_host_config_facts:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
esxi_hostname: "{{ hostvars[esxi1].ansible_host }}"
register: single_hosts_result
- name: ensure facts are gathered for all hosts
assert:
that:
- single_hosts_result.hosts_facts

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -2,90 +2,64 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support update host configuartion - import_role:
name: prepare_vmware_tests
- name: Wait for Flask controller to come up online vars:
wait_for: setup_attach_host: true
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 - name: Change an invalid key
uri: vmware_host_config_manager:
url: http://{{ vcsim }}:5000/govc_find?filter=CCR validate_certs: no
register: clusters hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: get a cluster password: "{{ vcenter_password }}"
set_fact: cluster_name: "{{ ccr1 }}"
ccr1: "{{ clusters.json[0] | basename }}" options:
'This.Is.No.Where': 'verbose'
- name: get a list of hosts from vcsim failed_when: False
uri: register: invalid_key
url: http://{{ vcsim }}:5000/govc_find?filter=H - debug: var=invalid_key
register: hosts - name: ensure we raise the correct error
assert:
- name: get a host that:
set_fact: - '"Unsupported option This.Is.No.Where" in invalid_key.msg'
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1
- debug: var=host1
- name: Change facts about all hosts in given cluster # TODO: vcsim does not support update host configuartion
- when: vcsim is not defined
block:
- name: Change facts about all hosts in given cluster
vmware_host_config_manager: vmware_host_config_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
options: options:
'Config.HostAgent.log.level': 'verbose' 'Config.HostAgent.log.level': 'verbose'
validate_certs: no validate_certs: no
register: all_hosts_result
- name: ensure changes are done to all hosts - name: Change facts about a given host
assert:
that:
- all_hosts_result.changed
- name: Change facts about a given host
vmware_host_config_manager: vmware_host_config_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
options: options:
'Config.HostAgent.log.level': 'info' 'Config.HostAgent.log.level': 'info'
validate_certs: no validate_certs: no
register: host_result register: host_result
- name: ensure changes are done to given hosts - debug: var=host_result
- name: ensure change was applied
assert: assert:
that: that:
- all_hosts_result.changed - host_result is changed
- name: Change facts about all hosts in given cluster in check mode - name: Change facts about all hosts in given cluster in check mode
vmware_host_config_manager: vmware_host_config_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
options: options:
'Config.HostAgent.log.level': 'verbose' 'Config.HostAgent.log.level': 'verbose'
@ -93,24 +67,24 @@
register: all_hosts_result_check_mode register: all_hosts_result_check_mode
check_mode: yes check_mode: yes
- name: ensure changes are done to all hosts - name: ensure changes are done to all hosts
assert: assert:
that: that:
- all_hosts_result_check_mode.changed - all_hosts_result_check_mode.changed
- name: Change facts about a given host in check mode - name: Change facts about a given host in check mode
vmware_host_config_manager: vmware_host_config_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
options: options:
'Config.HostAgent.log.level': 'info' 'Config.HostAgent.log.level': 'info'
validate_certs: no validate_certs: no
register: host_result_check_mode register: host_result_check_mode
check_mode: yes check_mode: yes
- name: ensure changes are done to given hosts - name: ensure changes are done to given hosts
assert: assert:
that: that:
- all_hosts_result_check_mode.changed - all_hosts_result_check_mode.changed

@ -1,3 +1,4 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -1,58 +1,17 @@
# Test code for the vmware_host_dns_facts module. # Test code for the vmware_host_dns_facts module.
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- 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 }}"
- 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 cluster
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: gather DNS facts about all hosts in given cluster - name: gather DNS facts about all hosts in given cluster
vmware_host_dns_facts: vmware_host_dns_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
validate_certs: no validate_certs: no
register: all_hosts_dns_result register: all_hosts_dns_result
@ -65,10 +24,10 @@
- name: gather DNS facts about host system - name: gather DNS facts about host system
vmware_host_dns_facts: vmware_host_dns_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
register: all_hosts_dns_result register: all_hosts_dns_result
@ -80,9 +39,9 @@
- name: gather DNS facts about all hosts in given cluster in check mode - name: gather DNS facts about all hosts in given cluster in check mode
vmware_host_dns_facts: vmware_host_dns_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
validate_certs: no validate_certs: no
register: all_hosts_dns_result_check_mode register: all_hosts_dns_result_check_mode
@ -96,10 +55,10 @@
- name: gather DNS facts about host system in check mode - name: gather DNS facts about host system in check mode
vmware_host_dns_facts: vmware_host_dns_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
register: all_hosts_dns_result_check_mode register: all_hosts_dns_result_check_mode
check_mode: yes check_mode: yes

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -1,28 +1,34 @@
- name: kill vcsim - when: vcsim is not defined
uri: block:
url: "{{ 'http://' + vcsim + ':5000/killall' }}" - import_role:
- name: start vcsim name: prepare_vmware_tests
uri: vars:
url: "{{ 'http://' + vcsim + ':5000/spawn?cluster=2' }}" setup_attach_host: true
register: vcsim_instance - name: get host facts through a vcenter
- name: get host facts
vmware_host_facts: vmware_host_facts:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: facts 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']"
- debug: var=facts - name: get host facts through from a host
vmware_host_facts:
- name: get host info validate_certs: False
uri: hostname: '{{ hostvars[esxi1].ansible_host }}'
url: "{{ 'http://' + vcsim + ':5000/govc_host_info' }}" username: '{{ hostvars[esxi1].ansible_user }}'
register: host_info_result password: '{{ hostvars[esxi1].ansible_password }}'
register: facts
- name: verify some data,like ansible_processor - debug: var=facts
- name: verify some data,like ansible_processor
assert: assert:
that: that:
- facts['ansible_facts']['ansible_hostname'] in host_info_result['json'] - "'ansible_hostname' in facts['ansible_facts']"
- facts['ansible_facts']['ansible_processor'] == host_info_result['json'][facts['ansible_facts']['ansible_hostname']]['Processor type'] - "'ansible_processor' in facts['ansible_facts']"

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -3,61 +3,23 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support host feature capabilities # TODO: vcsim does not support host feature capabilities
- import_role:
- name: Wait for Flask controller to come up online name: prepare_vmware_tests
wait_for: vars:
host: "{{ vcsim }}" setup_attach_host: true
port: 5000 setup_datastore: true
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 host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1
- debug: var=host1
- name: Gather feature capability facts for all ESXi host from given cluster - name: Gather feature capability facts for all ESXi host from given cluster
vmware_host_feature_facts: vmware_host_feature_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
register: capability_0001_results register: capability_0001_results
- debug: var=capability_0001_results
- assert: - assert:
that: that:
- "not capability_0001_results.changed" - "not capability_0001_results.changed"
@ -65,14 +27,16 @@
- name: Gather feature capability facts for all ESXi host from given cluster in check mode - name: Gather feature capability facts for all ESXi host from given cluster in check mode
vmware_host_feature_facts: vmware_host_feature_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
register: capability_0001_results register: capability_0001_results
check_mode: yes check_mode: yes
- debug: var=capability_0001_results
- assert: - assert:
that: that:
- "not capability_0001_results.changed" - "not capability_0001_results.changed"
@ -80,13 +44,15 @@
- name: Gather feature capability facts for ESXi host - name: Gather feature capability facts for ESXi host
vmware_host_feature_facts: vmware_host_feature_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: capability_0002_results register: capability_0002_results
- debug: var=capability_0002_results
- assert: - assert:
that: that:
- "not capability_0002_results.changed" - "not capability_0002_results.changed"
@ -95,14 +61,16 @@
- name: Gather feature capability facts for ESXi host in check mode - name: Gather feature capability facts for ESXi host in check mode
vmware_host_feature_facts: vmware_host_feature_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: capability_0002_results register: capability_0002_results
check_mode: yes check_mode: yes
- debug: var=capability_0002_results
- assert: - assert:
that: that:
- "not capability_0002_results.changed" - "not capability_0002_results.changed"

@ -1,3 +1,4 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -1,106 +1,73 @@
# Test code for the vmware_host_firewall_facts module. # Test code for the vmware_host_firewall_facts module.
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- import_role:
name: prepare_vmware_tests
vars:
setup_esxi_instance: true
- name: Wait for Flask controller to come up online - name: Gather firewall facts for a given ESXi
wait_for: vmware_host_firewall_facts:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 5000 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
validate_certs: no
- name: kill vcsim esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
uri: register: firewall_0004_results
url: http://{{ vcsim }}:5000/killall check_mode: yes
- 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 - assert:
uri: that:
url: http://{{ vcsim }}:5000/govc_find?filter=H - "not firewall_0004_results.changed"
register: hosts - "firewall_0004_results.hosts_firewall_facts is defined"
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1 - when: vcsim is not defined
- debug: var=host1 block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Gather firewall facts for all ESXi host from given cluster - name: Gather firewall facts for all ESXi host from given cluster
vmware_host_firewall_facts: vmware_host_firewall_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
register: firewall_0001_results register: firewall_0001_results
- assert: - assert:
that: that:
- "not firewall_0001_results.changed" - "not firewall_0001_results.changed"
- "firewall_0001_results.hosts_firewall_facts is defined" - "firewall_0001_results.hosts_firewall_facts is defined"
- name: Gather firewall facts for ESXi host - name: Gather firewall facts for ESXi host
vmware_host_firewall_facts: vmware_host_firewall_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: firewall_0002_results register: firewall_0002_results
- assert: - assert:
that: that:
- "not firewall_0002_results.changed" - "not firewall_0002_results.changed"
- "firewall_0002_results.hosts_firewall_facts is defined" - "firewall_0002_results.hosts_firewall_facts is defined"
- name: Gather firewall facts for all ESXi host from given cluster in check mode - name: Gather firewall facts for all ESXi host from given cluster in check mode
vmware_host_firewall_facts: vmware_host_firewall_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
register: firewall_0003_results register: firewall_0003_results
check_mode: yes check_mode: yes
- assert: - assert:
that: that:
- "not firewall_0003_results.changed" - "not firewall_0003_results.changed"
- "firewall_0003_results.hosts_firewall_facts is defined" - "firewall_0003_results.hosts_firewall_facts is defined"
- name: Gather firewall facts for ESXi host in check mode
vmware_host_firewall_facts:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
esxi_hostname: "{{ host1 }}"
register: firewall_0004_results
check_mode: yes
- assert:
that:
- "not firewall_0004_results.changed"
- "firewall_0004_results.hosts_firewall_facts is defined"

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -1,117 +1,84 @@
# Test code for the vmware_host_firewall_manager module. # Test code for the vmware_host_firewall_manager module.
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # 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) # 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: Wait for Flask controller to come up online - name: Enable vvold rule set on all hosts of {{ ccr1 }}
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: vmware_host_firewall_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
rules: rules:
- name: vvold - name: vvold
enabled: True enabled: True
register: all_hosts_result register: all_hosts_result
- debug: msg="{{ all_hosts_result }}"
- debug: msg="{{ all_hosts_result }}" - name: ensure everything is changed for all hosts of {{ ccr1 }}
- name: ensure everything is changed for all hosts of {{ ccr1 }}
assert: assert:
that: that:
- all_hosts_result.changed - all_hosts_result.changed
- all_hosts_result.rule_set_state is defined - all_hosts_result.rule_set_state is defined
- name: ensure facts are gathered for all hosts of {{ ccr1 }} - name: ensure facts are gathered for all hosts of {{ ccr1 }}
assert: assert:
that: that:
- all_hosts_result.rule_set_state[item]['vvold']['current_state'] == True - 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']['desired_state'] == True
- all_hosts_result.rule_set_state[item]['vvold']['previous_state'] == False - all_hosts_result.rule_set_state[item]['vvold']['previous_state'] == False
with_items: with_items:
- DC0_C0_H0 - '{{ hostvars[esxi1].ansible_host }}'
- DC0_C0_H1 - '{{ hostvars[esxi2].ansible_host }}'
- DC0_C0_H2
- name: Disable vvold for {{ host1 }} - name: Disable vvold for {{ host1 }}
vmware_host_firewall_manager: vmware_host_firewall_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
rules: rules:
- name: vvold - name: vvold
enabled: False enabled: False
register: host_result register: host_result
- debug: msg="{{ host_result }}"
- debug: msg="{{ host_result }}" - name: ensure vvold is disabled for {{ host1 }}
- name: ensure vvold is disabled for {{ host1 }}
assert: assert:
that: that:
- host_result.changed - host_result.changed
- host_result.rule_set_state is defined - host_result.rule_set_state is defined
- name: ensure facts are gathered for {{ host1 }} - name: ensure facts are gathered for {{ host1 }}
assert: assert:
that: that:
- host_result.rule_set_state[item]['vvold']['current_state'] == False - 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']['desired_state'] == False
- host_result.rule_set_state[item]['vvold']['previous_state'] == True - host_result.rule_set_state[item]['vvold']['previous_state'] == True
with_items: with_items:
- "{{ host1 }}" - '{{ hostvars[esxi1].ansible_host }}'
- name: Enable vvold rule set on all hosts of {{ ccr1 }} in check mode - name: Enable vvold rule set on all hosts of {{ ccr1 }} in check mode
vmware_host_firewall_manager: vmware_host_firewall_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
rules: rules:
@ -119,52 +86,44 @@
enabled: True enabled: True
register: all_hosts_result_check_mode register: all_hosts_result_check_mode
check_mode: yes check_mode: yes
- debug: var=all_hosts_result_check_mode
- debug: msg="{{ all_hosts_result_check_mode }}" - name: ensure everything is changed for all hosts of {{ ccr1 }}
- name: ensure everything is changed for all hosts of {{ ccr1 }}
assert: assert:
that: that:
- all_hosts_result_check_mode.changed - all_hosts_result_check_mode.changed
- all_hosts_result_check_mode.rule_set_state is defined - all_hosts_result_check_mode.rule_set_state is defined
- name: ensure facts are gathered for all hosts of {{ ccr1 }} - name: ensure facts are gathered for all hosts of {{ ccr1 }}
assert: assert:
that: that:
- all_hosts_result_check_mode.rule_set_state[item]['vvold']['current_state'] == True - all_hosts_result_check_mode.rule_set_state[hostvars[esxi1].ansible_host]['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[hostvars[esxi2].ansible_host]['vvold']['current_state'] == True
- all_hosts_result_check_mode.rule_set_state[item]['vvold']['previous_state'] == False - all_hosts_result_check_mode.rule_set_state[hostvars[esxi2].ansible_host]['vvold']['desired_state'] == True
with_items:
- DC0_C0_H0
- DC0_C0_H1
- DC0_C0_H2
- name: Disable vvold for {{ host1 }} in check mode - name: Disable vvold for {{ host1 }} in check mode
vmware_host_firewall_manager: vmware_host_firewall_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
rules: rules:
- name: vvold - name: vvold
enabled: False enabled: False
register: host_result_check_mode register: host_result_check_mode
check_mode: yes check_mode: yes
- debug: msg="{{ host_result_check_mode }}"
- debug: msg="{{ host_result_check_mode }}" - name: ensure vvold is disabled for {{ host1 }}
- name: ensure vvold is disabled for {{ host1 }}
assert: assert:
that: that:
- host_result_check_mode.changed == False - host_result_check_mode.changed == False
- host_result_check_mode.rule_set_state is defined - host_result_check_mode.rule_set_state is defined
- name: ensure facts are gathered for {{ host1 }} - name: ensure facts are gathered for {{ host1 }}
assert: assert:
that: that:
- host_result_check_mode.rule_set_state[item]['vvold']['current_state'] == False - 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']['desired_state'] == False
- host_result_check_mode.rule_set_state[item]['vvold']['previous_state'] == False - host_result_check_mode.rule_set_state[item]['vvold']['previous_state'] == False
with_items: with_items:
- "{{ host1 }}" - '{{ hostvars[esxi1].ansible_host }}'

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -2,119 +2,91 @@
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de> # 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) # 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
# Hyperthreading optimization is not available for hosts in vcsim # Hyperthreading optimization is not available for hosts in vcsim
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Enable Hyperthreading everywhere
vmware_host_hyperthreading:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
state: disabled
register: enable_hyperthreading_everywhere
ignore_errors: true
- when: enable_hyperthreading_everywhere is succeeded
block:
- name: Disable Hyperthreading for a given host - name: Disable Hyperthreading for a given host
vmware_host_hyperthreading: vmware_host_hyperthreading:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
state: disabled state: disabled
register: host_hyperthreading_facts register: host_hyperthreading_facts
- debug: var=host_hyperthreading_facts - debug: var=host_hyperthreading_facts
- assert: - assert:
that: that:
- host_hyperthreading_facts is defined - host_hyperthreading_facts is defined
- host_hyperthreading_facts.changed - host_hyperthreading_facts.changed
- name: Disable Hyperthreading for a given host in check mode - name: Disable Hyperthreading for a given host in check mode
vmware_host_hyperthreading: vmware_host_hyperthreading:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
state: disabled state: disabled
register: host_hyperthreading_facts_check_mode register: host_hyperthreading_facts_check_mode
check_mode: yes check_mode: yes
- debug: var=host_hyperthreading_facts_check_mode - debug: var=host_hyperthreading_facts_check_mode
- assert: - assert:
that: that:
- host_hyperthreading_facts_check_mode is defined - host_hyperthreading_facts_check_mode is defined
- host_hyperthreading_facts_check_mode.changed
- name: Disable Hyperthreading for all hosts in given cluster - name: Disable Hyperthreading for all hosts in given cluster
vmware_host_hyperthreading: vmware_host_hyperthreading:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
validate_certs: no validate_certs: no
state: disabled state: disabled
register: host_hyperthreading_facts register: host_hyperthreading_facts
- debug: var=host_hyperthreading_facts - debug: var=host_hyperthreading_facts
- assert: - assert:
that: that:
- host_hyperthreading_facts is defined - host_hyperthreading_facts is defined
- host_hyperthreading_facts.changed - host_hyperthreading_facts is changed
- name: Disable Hyperthreading for all hosts in given cluster in check mode - name: Enable Hyperthreading for all hosts in given cluster in check mode
vmware_host_hyperthreading: vmware_host_hyperthreading:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
validate_certs: no validate_certs: no
state: disabled state: enabled
register: host_hyperthreading_facts_check_mode register: host_hyperthreading_facts_check_mode
check_mode: yes check_mode: yes
- debug: var=host_hyperthreading_facts_check_mode - debug: var=host_hyperthreading_facts_check_mode
- assert: - assert:
that: that:
- host_hyperthreading_facts_check_mode is defined - host_hyperthreading_facts_check_mode is defined
- host_hyperthreading_facts_check_mode.changed - host_hyperthreading_facts_check_mode.changed

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -1,118 +1,81 @@
# Test code for the vmware_host_ipv6 module. # Test code for the vmware_host_ipv6 module.
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de> # 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) # 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: 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: Wait for Flask controller to come up online - name: Enable IPv6 support for a given host
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: vmware_host_ipv6:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
state: enabled state: enabled
register: host_ipv6_facts register: host_ipv6_facts
- debug: var=host_ipv6_facts
- debug: var=host_ipv6_facts - assert:
- assert:
that: that:
- host_ipv6_facts is defined - host_ipv6_facts is defined
- host_ipv6_facts.changed - host_ipv6_facts.changed
- name: Enable IPv6 support for a given host in check mode - name: Enable IPv6 support for a given host in check mode
vmware_host_ipv6: vmware_host_ipv6:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
state: enabled state: enabled
register: host_ipv6_facts_check_mode register: host_ipv6_facts_check_mode
check_mode: yes check_mode: yes
- debug: var=host_ipv6_facts_check_mode
- debug: var=host_ipv6_facts_check_mode - assert:
- assert:
that: that:
- host_ipv6_facts_check_mode is defined - host_ipv6_facts_check_mode is defined
- host_ipv6_facts_check_mode.changed - not (host_ipv6_facts_check_mode is changed)
- name: Enable IPv6 support for all hosts in given cluster - name: Enable IPv6 support for all hosts in given cluster
vmware_host_ipv6: vmware_host_ipv6:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
validate_certs: no validate_certs: no
state: enabled state: enabled
register: hosts_ipv6_facts register: hosts_ipv6_facts
- debug: var=hosts_ipv6_facts
- debug: var=hosts_ipv6_facts - assert:
- assert:
that: that:
- hosts_ipv6_facts is defined - hosts_ipv6_facts is defined
- hosts_ipv6_facts.changed - hosts_ipv6_facts.changed
- name: Enable IPv6 support for all hosts in given cluster in check mode - name: Enable IPv6 support for all hosts in given cluster in check mode
vmware_host_ipv6: vmware_host_ipv6:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
validate_certs: no validate_certs: no
state: enabled state: enabled
register: hosts_ipv6_facts_check_mode register: hosts_ipv6_facts_check_mode
check_mode: yes check_mode: yes
- debug: var=hosts_ipv6_facts_check_mode
- debug: var=hosts_ipv6_facts_check_mode - assert:
- assert:
that: that:
- hosts_ipv6_facts_check_mode is defined - hosts_ipv6_facts_check_mode is defined
- hosts_ipv6_facts_check_mode.changed - not (hosts_ipv6_facts_check_mode is changed)

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -1,66 +1,42 @@
# test code for the vmware_host_kernel_manager module # test code for the vmware_host_kernel_manager module
# Copyright: (c) 2019, Aaron Longchamps <a.j.longchamps@gmail.com> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- when: vcsim is not defined
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
setup_datastore: true
- name: kill vcsim
uri: - name: host connected, module exists, options exist, arguments different
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: vmware_host_kernel_manager:
hostname: '{{ vcsim }}' hostname: '{{ vcenter_hostname }}'
username: '{{ vcsim_instance.json.username }}' username: '{{ vcenter_username }}'
password: '{{ vcsim_instance.json.password }}' password: '{{ vcenter_password }}'
validate_certs: False validate_certs: False
esxi_hostname: '{{ host1 }}' esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
kernel_module_name: "tcpip4" kernel_module_name: "tcpip4"
kernel_module_option: "ipv6=0" kernel_module_option: "ipv6=0"
register: my_results_01 register: my_results_01
- debug: var=my_results_01
- name: Check that the provided kernel_module_name has kernel_module_option set - name: Check that the provided kernel_module_name has kernel_module_option set
assert: assert:
that: that:
- "my_results_01.results['DC0_H0']['configured_options'] == 'ipv6=0'" - "'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 - name: host connected, module exists, same options for idempotence test
vmware_host_kernel_manager: vmware_host_kernel_manager:
hostname: '{{ vcsim }}' hostname: '{{ vcenter_hostname }}'
username: '{{ vcsim_instance.json.username }}' username: '{{ vcenter_username }}'
password: '{{ vcsim_instance.json.password }}' password: '{{ vcenter_password }}'
validate_certs: False validate_certs: False
esxi_hostname: '{{ host1 }}' esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
kernel_module_name: "tcpip4" kernel_module_name: "tcpip4"
kernel_module_option: "ipv6=0" kernel_module_option: "ipv6=0"
register: my_results_02 register: my_results_02
- name: Check that changed is false
- name: Check that changed is false
assert: assert:
that: that:
- "my_results_02.results['DC0_H0']['changed'] == false" - not (my_results_02 is changed)

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -3,132 +3,88 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support update host NTP configuration # TODO: vcsim does not support update host NTP configuration
- when: vcsim is not defined
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
- name: kill vcsim - name: Add NTP server to a host
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 host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1
- debug: var=host1
- name: Add NTP server to a host
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present state: present
ntp_server: ntp_servers:
- 0.pool.ntp.org - 0.pool.ntp.org
validate_certs: no validate_certs: no
register: present register: present
- debug: var=present
- debug: var=present - name: Add another NTP server to a host
- name: Add another NTP server to a host
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present state: present
ntp_server: ntp_servers:
- 1.pool.ntp.org - 1.pool.ntp.org
validate_certs: no validate_certs: no
register: present register: present
- debug: var=present
- debug: var=present - name: Remove NTP server from a host
- name: Remove NTP server from a host
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: absent state: absent
ntp_server: ntp_servers:
- 1.pool.ntp.org - 1.pool.ntp.org
validate_certs: no validate_certs: no
register: absent_one register: absent_one
- debug: var=absent_one
- debug: var=absent_one - name: Remove NTP server from a host
- name: Remove NTP server from a host
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present state: present
ntp_server: ntp_servers:
- 1.pool.ntp.org - 1.pool.ntp.org
validate_certs: no validate_certs: no
register: present register: present
- debug: var=present
- debug: var=present - name: Add more NTP servers to a host
- name: Add more NTP servers to a host
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present state: present
ntp_server: ntp_servers:
- 2.pool.ntp.org - 2.pool.ntp.org
- 3.pool.ntp.org - 3.pool.ntp.org
- 4.pool.ntp.org - 4.pool.ntp.org
validate_certs: no validate_certs: no
register: present register: present
- debug: var=present
- debug: var=present - name: Remove all NTP servers from a host
- name: Remove all NTP servers from a host
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: absent state: absent
ntp_server: ntp_servers:
- 0.pool.ntp.org - 0.pool.ntp.org
- 1.pool.ntp.org - 1.pool.ntp.org
- 2.pool.ntp.org - 2.pool.ntp.org
@ -137,82 +93,76 @@
- 6.pool.ntp.org - 6.pool.ntp.org
validate_certs: no validate_certs: no
register: absent_all register: absent_all
- debug: var=absent_all
- debug: var=absent_all - name: Configure NTP servers for a host
- name: Configure NTP servers for a host
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ntp_server: ntp_servers:
- 0.pool.ntp.org - 0.pool.ntp.org
- 1.pool.ntp.org - 1.pool.ntp.org
- 2.pool.ntp.org - 2.pool.ntp.org
validate_certs: no validate_certs: no
register: ntp_servers register: ntp_servers
- debug: var=ntp_servers
- debug: var=ntp_servers - name: Configure NTP servers for a host
- name: Configure NTP servers for a host
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ntp_server: ntp_servers:
- 3.pool.ntp.org - 3.pool.ntp.org
- 4.pool.ntp.org - 4.pool.ntp.org
- 5.pool.ntp.org - 5.pool.ntp.org
verbose: true verbose: true
validate_certs: no validate_certs: no
register: ntp_servers register: ntp_servers
- debug: var=ntp_servers
- debug: var=ntp_servers - name: Add NTP server to a host in check mode
- name: Add NTP server to a host in check mode
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present state: present
ntp_server: ntp_servers:
- 0.pool.ntp.org - 0.pool.ntp.org
validate_certs: no validate_certs: no
register: present register: present
check_mode: yes check_mode: yes
- debug: var=present
- debug: var=present - name: Remove NTP server to a host in check mode
- name: Remove NTP server to a host in check mode
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: absent state: absent
ntp_server: ntp_servers:
- 0.pool.ntp.org - 0.pool.ntp.org
validate_certs: no validate_certs: no
register: present register: present
check_mode: yes check_mode: yes
- debug: var=present
- debug: var=present - name: Configure NTP servers for a host in check mode
- name: Configure NTP servers for a host in check mode
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ntp_server: ntp_servers:
- 0.pool.ntp.org - 0.pool.ntp.org
- 1.pool.ntp.org - 1.pool.ntp.org
- 2.pool.ntp.org - 2.pool.ntp.org
validate_certs: no validate_certs: no
register: ntp_servers register: ntp_servers
check_mode: yes check_mode: yes
- debug: var=ntp_servers
- debug: var=ntp_servers

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -3,53 +3,22 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support NTP Manager related to operations # TODO: vcsim does not support NTP Manager related to operations
- when: vcsim is not defined
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
- name: kill vcsim - name: Gather NTP facts about all hosts in given host
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 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
- name: Gather NTP facts about all hosts in given host
vmware_host_ntp_facts: vmware_host_ntp_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
register: host_ntp register: host_ntp
- debug: var=host_ntp
- debug: var=host_ntp - assert:
- assert:
that: that:
- host_ntp.hosts_ntp_facts is defined - host_ntp.hosts_ntp_facts is defined

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -3,53 +3,22 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support Package Manager related to operations # TODO: vcsim does not support Package Manager related to operations
- when: vcsim is not defined
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
- name: kill vcsim - name: Gather facts about all hosts in given cluster
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 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
- name: Gather facts about all hosts in given cluster
vmware_host_package_facts: vmware_host_package_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ user }}" username: "{{ vcenter_username }}"
password: "{{ passwd }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
register: host_packages register: host_packages
- debug: var=host_packages
- debug: var=host_packages - assert:
- assert:
that: that:
- host_packages.hosts_package_facts is defined - host_packages.hosts_package_facts is defined

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -2,122 +2,76 @@
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de> # 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) # 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 - when: vcsim is not defined
wait_for: block:
host: "{{ vcsim }}" - import_role:
port: 5000 name: prepare_vmware_tests
state: started vars:
setup_attach_host: true
- name: Kill vcsim
uri: # The following test cases aren't supported by vcsim
url: http://{{ vcsim }}:5000/killall - name: Set the Power Management Policy for esxi1
- 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 host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1
- debug: var=host1
# The following test cases aren't supported by vcsim
- name: Set the Power Management Policy for {{ host1 }}
vmware_host_powermgmt_policy: vmware_host_powermgmt_policy:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
policy: high-performance policy: high-performance
validate_certs: no validate_certs: no
register: host_result register: host_result
- debug: var=host_result
- debug: msg="{{ host_result }}" - name: Ensure Power Management Policy for esxi1
- name: Ensure Power Management Policy for {{ host1 }}
assert: assert:
that: that:
- host_result is changed - host_result.result['{{ hostvars[esxi1].ansible_host }}'].current_state == "high-performance"
- host_result.result is defined
- name: Set the Power Management Policy on all hosts of {{ ccr1 }} - name: Set the Power Management Policy on all hosts of {{ ccr1 }}
vmware_host_powermgmt_policy: vmware_host_powermgmt_policy:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" cluster_name: "{{ ccr1 }}"
policy: balanced policy: balanced
validate_certs: no validate_certs: no
register: all_hosts_result register: all_hosts_result
- debug: var=all_hosts_result
- debug: msg="{{ all_hosts_result }}" - name: Ensure Power Management Policy is changed for all hosts of {{ ccr1 }}
- name: Ensure Power Management Policy is changed for all hosts of {{ ccr1 }}
assert: assert:
that: that:
- all_hosts_result is changed - all_hosts_result is changed
- all_hosts_result.result is defined - all_hosts_result.result is defined
- name: Set the Power Management Policy for {{ host1 }} in check mode - name: Set the Power Management Policy for esxi1 in check mode
vmware_host_powermgmt_policy: vmware_host_powermgmt_policy:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
policy: high-performance policy: high-performance
validate_certs: no validate_certs: no
register: host_result register: host_result
check_mode: yes check_mode: yes
- debug: var=host_result
- debug: msg="{{ host_result }}" - name: Ensure Power Management Policy for esxi1 in check mode
- name: Ensure Power Management Policy for {{ host1 }} in check mode
assert: assert:
that: that:
- host_result is changed - host_result is changed
- host_result.result is defined - host_result.result is defined
- name: Set the Power Management Policy on all hosts of {{ ccr1 }} in check mode - name: Set the Power Management Policy on all hosts of {{ ccr1 }}
vmware_host_powermgmt_policy: vmware_host_powermgmt_policy:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" cluster_name: "{{ ccr1 }}"
policy: balanced policy: balanced
validate_certs: no validate_certs: no
register: all_hosts_result register: all_hosts_result
check_mode: yes check_mode: yes
- debug: var=all_hosts_result
- debug: msg="{{ all_hosts_result }}" - name: Ensure we are still using the 'balanced' mode
- name: Ensure Power Management Policy is changed for all hosts of {{ ccr1 }} in check mode
assert: assert:
that: that:
- all_hosts_result is changed - not (all_hosts_result is changed)
- all_hosts_result.result is defined - "all_hosts_result.result['{{ hostvars[esxi1].ansible_host }}']current_state == 'balanced'"
- "all_hosts_result.result['{{ hostvars[esxi2].ansible_host }}']current_state == 'balanced'"

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -3,55 +3,32 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support Powerstate related to operations # TODO: vcsim does not support Powerstate related to operations
- when: False
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
- name: kill vcsim
uri: # https://kb.vmware.com/s/article/2001651?lang=en_US
url: http://{{ vcsim }}:5000/killall # It seems like we need a Power managment interface to be able to run the
# module.
- name: start vcsim # I currently get:
uri: # "Failed to power down '192.168.123.7' to standby as host system due to : ('The operation is not supported on the object.', None)"
url: http://{{ vcsim }}:5000/spawn?cluster=2 - name: Restart Host
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=H
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: Restart Host
vmware_host_powerstate: vmware_host_powerstate:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: False validate_certs: False
state: power-down-to-standby state: power-down-to-standby
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
force: True force: True
register: host_powerstate register: host_powerstate
- debug: var=host_powerstate - debug: var=host_powerstate
- assert: - assert:
that: that:
- host_powerstate.results is changed - host_powerstate.results is changed

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
unsupported cloud/vcenter
needs/target/prepare_vmware_tests

@ -1,79 +1,24 @@
# Test code for the vmware_host_scanhba module. # Test code for the vmware_host_scanhba module.
# Copyright: (c) 2019, Michael Eaton <me@michaeleaton.me> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- when: vcsim is not defined
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
- name: kill vcsim - name: Recan HBA's for an entire cluster (there should be at least one host as above)
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: vmware_host_scanhba:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: '{{ ccr1 }}' cluster_name: '{{ ccr1 }}'
refresh_storage: false refresh_storage: false
register: host_scan_results register: host_scan_results
- debug: msg="{{ host_scan_results }}"
- debug: msg="{{ host_scan_results }}" - name: ensure a change occured (as in the scan happened) and the task didnt fail
- name: ensure a change occured (as in the scan happened) and the task didnt fail
assert: assert:
that: that:
- host_scan_results.changed - host_scan_results.changed

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -3,53 +3,37 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support service related to operations # TODO: vcsim does not support service related to operations
- when: vcsim is not defined
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
- name: kill vcsim - &host_srv_facts
uri: name: Check facts about all hosts in given cluster
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 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
- name: Change facts about all hosts in given cluster
vmware_host_service_facts: vmware_host_service_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ user }}" username: "{{ vcenter_username }}"
password: "{{ passwd }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
register: host_services register: host_services
- debug: var=host_services - debug:
var: host_services
- assert:
that:
- host_services.host_service_facts is defined
- <<: *host_srv_facts
name: Check facts about all hosts in given cluster in check mode
check_mode: yes
- debug:
var: host_services
- assert: - assert:
that: that:
- host_services.host_service_facts is defined - host_services.host_service_facts is defined

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -4,114 +4,83 @@
# TODO: vcsim does not support service management # TODO: vcsim does not support service management
# commenting this testcase till the time. # commenting this testcase till the time.
- when: vcsim is not defined
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
- name: kill vcsim - name: Start ntpd service on all hosts in given cluster
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: Start ntpd service on all hosts in given cluster
vmware_host_service_manager: vmware_host_service_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
service_name: ntpd service_name: ntpd
state: present state: present
register: all_hosts_result register: all_hosts_result
- debug: var=all_hosts_result
- name: ensure facts are gathered for all hosts - name: Stop ntpd service on a given host
assert:
that:
- all_hosts_result.changed
- name: Stop ntpd service on a given host
vmware_host_service_manager: vmware_host_service_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
service_name: ntpd service_name: ntpd
state: absent state: absent
register: single_hosts_result register: single_hosts_result
- name: ensure facts are gathered
- name: ensure facts are gathered
assert: assert:
that: that:
- single_hosts_result.changed == False - single_hosts_result is changed
- name: Start ntpd service on all hosts in given cluster in check mode - name: Start ntpd service on all hosts in given cluster in check mode
vmware_host_service_manager: vmware_host_service_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
service_name: ntpd service_name: ntpd
state: present state: present
register: all_hosts_result_check_mode register: all_hosts_result_check_mode
check_mode: yes check_mode: yes
- name: ensure facts are gathered for all hosts
- name: ensure facts are gathered for all hosts
assert: assert:
that: that:
- all_hosts_result_check_mode.changed - all_hosts_result_check_mode is changed
- name: Stop ntpd service on a given host in check mode - name: Stop ntpd service on a given host in check mode
vmware_host_service_manager: vmware_host_service_manager:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
service_name: ntpd service_name: ntpd
state: absent state: absent
register: single_hosts_result_check_mode register: single_hosts_result_check_mode
check_mode: yes check_mode: yes
- name: ensure facts are gathered
assert:
that:
- not (single_hosts_result_check_mode is changed)
- name: ensure facts are gathered - name: Start ntpd service on all hosts in given cluster
vmware_host_service_manager:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
cluster_name: "{{ ccr1 }}"
service_name: ntpd
state: present
register: all_hosts_result_check_mode
- name: finally, ensure ntp is running on the cluster
assert: assert:
that: that:
- single_hosts_result_check_mode.changed == False - all_hosts_result_check_mode is changed

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -2,63 +2,55 @@
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de> # 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) # 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 - when: vcsim is not defined
wait_for: block:
host: "{{ vcsim }}" - import_role:
port: 5000 name: prepare_vmware_tests
state: started vars:
setup_attach_host: true
- name: kill vcsim
uri: # SNMP works only with standalone ESXi server
url: http://{{ vcsim }}:5000/killall - name: Enable and configure SNMP community in check mode
# SNMP works only with standalone ESXi server
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?esx=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: Enable and configure SNMP community in check mode
vmware_host_snmp: vmware_host_snmp:
hostname: "{{ vcsim }}" hostname: '{{ hostvars[esxi1].ansible_host }}'
username: "{{ vcsim_instance.json.username }}" username: '{{ hostvars[esxi1].ansible_user }}'
password: "{{ vcsim_instance.json.password }}" password: '{{ hostvars[esxi1].ansible_password }}'
community: [ test ] community: [ test ]
state: enabled state: enabled
validate_certs: no validate_certs: no
register: snmp_enabled_check_mode register: snmp_enabled_check_mode
check_mode: yes check_mode: yes
- debug: var=snmp_enabled_check_mode
- debug: var=snmp_enabled_check_mode - assert:
- assert:
that: that:
- snmp_enabled_check_mode is defined - snmp_enabled_check_mode is defined
- snmp_enabled_check_mode.changed - snmp_enabled_check_mode.changed
- name: Enable and configure SNMP community - name: Enable and configure SNMP community
vmware_host_snmp: vmware_host_snmp:
hostname: "{{ vcsim }}" hostname: '{{ hostvars[esxi1].ansible_host }}'
username: "{{ vcsim_instance.json.username }}" username: '{{ hostvars[esxi1].ansible_user }}'
password: "{{ vcsim_instance.json.password }}" password: '{{ hostvars[esxi1].ansible_password }}'
community: [ test ] community: [ test ]
state: enabled state: enabled
validate_certs: no validate_certs: no
register: snmp_enabled register: snmp_enabled
check_mode: yes - debug: var=snmp_enabled
- assert:
- debug: var=snmp_enabled that:
- snmp_enabled is defined
- snmp_enabled.changed
- assert: - name: Disable SNMP
vmware_host_snmp:
hostname: '{{ hostvars[esxi1].ansible_host }}'
username: '{{ hostvars[esxi1].ansible_user }}'
password: '{{ hostvars[esxi1].ansible_password }}'
state: disabled
validate_certs: no
register: snmp_disabled
- debug: var=snmp_enabled
- assert:
that: that:
- snmp_enabled is defined - snmp_enabled is defined
- snmp_enabled.changed - snmp_enabled.changed

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -1,58 +1,18 @@
# Test code for the vmware_host_ssl_facts module. # Test code for the vmware_host_ssl_facts module.
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- 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 hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: get a list of clusters from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
register: clusters
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- name: get a cluster
set_fact:
cluster1: "{{ clusters.json[0] | basename }}"
- debug: var=host1
- debug: var=cluster1
- name: Gather SSL facts about ESXi machine - name: Gather SSL facts about ESXi machine
vmware_host_ssl_facts: vmware_host_ssl_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
register: ssl_facts register: ssl_facts
@ -64,10 +24,10 @@
- name: Gather facts about all hostsystem in given cluster - name: Gather facts about all hostsystem in given cluster
vmware_host_ssl_facts: vmware_host_ssl_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
cluster_name: "{{ cluster1 }}" cluster_name: "{{ ccr1 }}"
validate_certs: no validate_certs: no
register: ssl_facts register: ssl_facts
@ -79,10 +39,10 @@
- name: Gather SSL facts about ESXi machine in check mode - name: Gather SSL facts about ESXi machine in check mode
vmware_host_ssl_facts: vmware_host_ssl_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
check_mode: yes check_mode: yes
register: ssl_facts register: ssl_facts
@ -95,10 +55,10 @@
- name: Gather facts about all hostsystem in given cluster in check mode ee - name: Gather facts about all hostsystem in given cluster in check mode ee
vmware_host_ssl_facts: vmware_host_ssl_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
cluster_name: "{{ cluster1 }}" cluster_name: "{{ ccr1 }}"
validate_certs: no validate_certs: no
check_mode: yes check_mode: yes
register: ssl_facts register: ssl_facts

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -3,53 +3,37 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support networkConfig related to operations # TODO: vcsim does not support networkConfig related to operations
- when: vcsim is not defined
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
- name: kill vcsim - &vmhba_data
uri: name: Gather vmhba facts
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 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
- name: Gather vmhba facts
vmware_host_vmhba_facts: vmware_host_vmhba_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ user }}" username: "{{ vcenter_username }}"
password: "{{ passwd }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
register: host_vmhbas register: host_vmhbas
- debug: var=host_vmhbas - debug:
var: host_vmhbas
- assert:
that:
- host_vmhbas.hosts_vmhbas_facts is defined
- <<: *vmhba_data
name: Gather vmhba facts in check mode
check_mode: yes
- debug:
var: host_vmhbas
- assert: - assert:
that: that:
- host_vmhbas.hosts_vmhbas_facts is defined - host_vmhbas.hosts_vmhbas_facts is defined

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -3,71 +3,38 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support networkConfig related to operations # TODO: vcsim does not support networkConfig related to operations
- when: vcsim is not defined
- name: Wait for Flask controller to come up online block:
wait_for: - import_role:
host: "{{ vcsim }}" name: prepare_vmware_tests
port: 5000 vars:
state: started setup_attach_host: true
- name: kill vcsim - name: Gather vmnic facts about a host
uri: vmware_host_vmnic_facts:
url: http://{{ vcsim }}:5000/killall hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: start vcsim password: "{{ vcenter_password }}"
uri: esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
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 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
- name: Gather vmnic facts about a host
vmware_host_vmnics_facts:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no validate_certs: no
register: host_vmnics register: host_vmnics
- debug: var=host_vmnics
- debug: var=host_vmnics - assert:
- assert:
that: that:
- host_vmnics.hosts_vmnics_facts is defined - host_vmnics.hosts_vmnics_facts is defined
- name: Gather extended vmnic facts about a host - name: Gather extended vmnic facts about a host
vmware_host_vmnics_facts: vmware_host_vmnic_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ user }}" username: "{{ vcenter_username }}"
password: "{{ passwd }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
capabilities: true capabilities: true
directpath_io: true directpath_io: true
sriov: true sriov: true
register: host_vmnics_extended register: host_vmnics_extended
- debug: var=host_vmnics_extended
- debug: var=host_vmnics_extended - assert:
- assert:
that: that:
- host_vmnics_extended.hosts_vmnics_facts is defined - host_vmnics_extended.hosts_vmnics_facts is defined

Loading…
Cancel
Save