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)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- debug:
var: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of Datacenter from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- name: get a datacenter
set_fact:
dc1: "{{ datacenters.json[0] | basename }}"
- debug: var=dc1
- name: get a list of Cluster from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
register: clusters
- name: get a cluster
set_fact:
ccr1: "{{ clusters.json[0] | basename }}"
- debug: var=ccr1
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
# fetch_ssl_thumbprint needs to be disabled because the host only exists in vcsim
# Testcase: Add Host # Testcase: Add Host
- name: add host - when: vcsim is not defined
vmware_host: block:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}" - name: Add first ESXi Host to vCenter
password: "{{ vcsim_instance.json.password }}" vmware_host:
validate_certs: no hostname: '{{ vcenter_hostname }}'
esxi_hostname: test_host_system_0001 username: '{{ vcenter_username }}'
esxi_username: "{{ vcsim_instance.json.username }}" password: '{{ vcenter_password }}'
esxi_password: "{{ vcsim_instance.json.password }}" datacenter_name: '{{ dc1 }}'
datacenter_name: "{{ dc1 }}" cluster_name: '{{ ccr1 }}'
cluster_name: "{{ ccr1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
fetch_ssl_thumbprint: False esxi_username: '{{ hostvars[esxi1].ansible_user }}'
state: present esxi_password: '{{ hostvars[esxi1].ansible_password }}'
register: add_host_result state: present
validate_certs: no
- name: get a list of host system from vcsim after adding host system register: readd_host_result
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H - name: Add first ESXi Host to vCenter (again)
register: host_list vmware_host:
hostname: '{{ vcenter_hostname }}'
- name: ensure host system is present username: '{{ vcenter_username }}'
assert: password: '{{ vcenter_password }}'
that: datacenter_name: '{{ dc1 }}'
- add_host_result is changed cluster_name: '{{ ccr1 }}'
- "{% for host in host_list.json if ((host | basename) == 'test_host_system_0001') -%} True {%- else -%} False {%- endfor %}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
esxi_username: '{{ hostvars[esxi1].ansible_user }}'
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
state: present
validate_certs: no
register: readd_host_result
- name: ensure precend task didn't changed anything
assert:
that:
- not ( readd_host_result is changed)
- name: add second host via add_or_reconnect
vmware_host:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
fetch_ssl_thumbprint: False
state: add_or_reconnect
register: add_or_reconnect_host_result
- name: ensure host system is present
assert:
that:
- add_or_reconnect_host_result is changed
- when: vcsim is not defined
block:
- name: disconnect host 2
vmware_host:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
fetch_ssl_thumbprint: False
state: absent
- name: remove host again
vmware_host:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
state: absent
register: reremove_host_result
- name: ensure precend task didn't changed anything
assert:
that:
- not ( reremove_host_result is changed)
# Testcase: Add Host again
- name: add host again
vmware_host:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
esxi_hostname: test_host_system_0001
esxi_username: "{{ vcsim_instance.json.username }}"
esxi_password: "{{ vcsim_instance.json.password }}"
datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
fetch_ssl_thumbprint: False
state: present
register: readd_host_result
- name: ensure precend task didn't changed anything
assert:
that:
- not ( readd_host_result is changed)
# Testcase: Add Host via add_or_reconnect state
- name: add host via add_or_reconnect
vmware_host:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
esxi_hostname: test_host_system_0002
esxi_username: "{{ vcsim_instance.json.username }}"
esxi_password: "{{ vcsim_instance.json.password }}"
datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
fetch_ssl_thumbprint: False
state: add_or_reconnect
register: add_or_reconnect_host_result
- name: get a list of host system from vcsim after adding host system
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: host_list
- name: ensure host system is present
assert:
that:
- add_or_reconnect_host_result is changed
- "{% for host in host_list.json if ((host | basename) == 'test_host_system_0002') -%} True {%- else -%} False {%- endfor %}"
## Testcase: Add Host to folder ## Testcase: Add Host to folder
# #
# It's not possible to connect an ESXi host via vcsim. # It's not possible to connect an ESXi host via vcsim.
# - when: vcsim is not defined
# - name: Create host folder block:
# vcenter_folder: - name: Create host folder
# hostname: "{{ vcsim }}" vcenter_folder:
# username: "{{ vcsim_instance.json.username }}" hostname: "{{ vcenter_hostname }}"
# password: "{{ vcsim_instance.json.password }}" username: "{{ vcenter_username }}"
# validate_certs: no password: "{{ vcenter_password }}"
# datacenter: "{{ dc1 }}" validate_certs: no
# folder_name: "Staging" datacenter: "{{ dc1 }}"
# folder_type: host folder_name: "Staging"
# state: present folder_type: host
# register: folder_results state: present
# register: folder_results
# - debug: msg="{{ folder_results }}"
# - debug: msg="{{ folder_results }}"
# - name: ensure folder is present
# assert: - name: ensure folder is present
# that: assert:
# - folder_results.changed that:
# - folder_results.changed
# - name: Create host folder again
# vcenter_folder: - name: Add host to folder in check mode
# hostname: "{{ vcsim }}" vmware_host:
# username: "{{ vcsim_instance.json.username }}" hostname: "{{ vcenter_hostname }}"
# password: "{{ vcsim_instance.json.password }}" username: "{{ vcenter_username }}"
# validate_certs: no password: "{{ vcenter_password }}"
# datacenter: "{{ dc1 }}" validate_certs: no
# folder_name: "Staging" esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
# folder_type: host esxi_username: '{{ hostvars[esxi2].ansible_user }}'
# state: present esxi_password: '{{ hostvars[esxi2].ansible_password }}'
# register: folder_results datacenter_name: "{{ dc1 }}"
# folder_name: "/{{ dc1 }}/host/Staging"
# - debug: msg="{{ folder_results }}" state: present
# register: add_host_to_folder_result
# - name: ensure folder is present check_mode: yes
# assert:
# that: - name: ensure host system is not present
# - folder_results.changed == False assert:
# that:
# - name: Add host to folder in check mode - add_host_to_folder_result is changed
# vmware_host:
# hostname: "{{ vcsim }}" - name: Add host to folder
# username: "{{ vcsim_instance.json.username }}" vmware_host:
# password: "{{ vcsim_instance.json.password }}" hostname: "{{ vcenter_hostname }}"
# validate_certs: no username: "{{ vcenter_username }}"
# esxi_hostname: test_host_system_0003 password: "{{ vcenter_password }}"
# esxi_username: "{{ vcsim_instance.json.username }}" validate_certs: no
# esxi_password: "{{ vcsim_instance.json.password }}" esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
# datacenter_name: "{{ dc1 }}" esxi_username: '{{ hostvars[esxi2].ansible_user }}'
# folder_name: "Staging" esxi_password: '{{ hostvars[esxi2].ansible_password }}'
# state: present datacenter_name: "{{ dc1 }}"
# register: add_host_to_folder_result folder_name: "/{{ dc1 }}/host/Staging"
# check_mode: yes state: present
# register: add_host_to_folder_result
# - name: get a list of host system from vcsim after adding host system
# uri: - name: ensure host system is present
# url: http://{{ vcsim }}:5000/govc_find?filter=H assert:
# register: host_list that:
# - add_host_to_folder_result is changed
# - name: ensure host system is not present
# assert: - name: reconnect host
# that: vmware_host:
# - add_host_to_folder_result is changed hostname: "{{ vcenter_hostname }}"
# - not ("{% for host in host_list.json if ((host | basename) == 'test_host_system_0003') -%} True {%- else -%} False {%- endfor %}") username: "{{ vcenter_username }}"
# password: "{{ vcenter_password }}"
# - name: Add host to folder validate_certs: no
# vmware_host: esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
# hostname: "{{ vcsim }}" esxi_username: '{{ hostvars[esxi2].ansible_user }}'
# username: "{{ vcsim_instance.json.username }}" esxi_password: '{{ hostvars[esxi2].ansible_password }}'
# password: "{{ vcsim_instance.json.password }}" datacenter_name: "{{ dc1 }}"
# validate_certs: no cluster_name: "{{ ccr1 }}"
# esxi_hostname: test_host_system_0003 state: reconnect
# esxi_username: "{{ vcsim_instance.json.username }}" register: reconnect_host_result
# esxi_password: "{{ vcsim_instance.json.password }}"
# datacenter_name: "{{ dc1 }}" - name: ensure host system has been reconnected
# folder_name: "Staging" assert:
# state: present that:
# register: add_host_to_folder_result - reconnect_host_result is changed
# # it would be a good idea to check the events on the host to see the reconnect
# - name: get a list of host system from vcsim after adding host system # https://github.com/vmware/govmomi/blob/master/govc/USAGE.md#events
# uri: # "govc events ..." need to be callable from
# url: http://{{ vcsim }}:5000/govc_find?filter=H # https://github.com/ansible/vcenter-test-container/flask_control.py
# 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:
- name: Wait for Flask controller to come up online - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}" vars:
port: 5000 setup_attach_host: true
state: started
- name: kill vcsim - name: Change acceptance level of given hosts
uri: vmware_host_acceptance:
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 validate_certs: no
register: vcsim_instance acceptance_level: vmware_certified
state: present
- debug: register: host_acceptance_facts
var: vcsim_instance - debug: var=host_acceptance_facts
- assert:
- name: Wait for vcsim server to come up online that:
wait_for: - host_acceptance_facts.facts is defined
host: "{{ vcsim }}"
port: 443 - name: Change acceptance level of given hosts in check mode
state: started vmware_host_acceptance:
hostname: "{{ vcenter_hostname }}"
- name: get a list of hosts from vcsim username: "{{ vcenter_username }}"
uri: password: "{{ vcenter_password }}"
url: http://{{ vcsim }}:5000/govc_find?filter=H esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: hosts validate_certs: no
acceptance_level: vmware_certified
- name: get a host state: present
set_fact: register: host_acceptance_facts_check_mode
host1: "{{ hosts.json[0] | basename }}" check_mode: yes
- debug: var=host_acceptance_facts_check_mode
- debug: var=host1 - assert:
that:
- name: Change acceptance level of given hosts - host_acceptance_facts_check_mode.facts is defined
vmware_host_acceptance:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
acceptance_level: vmware_certified
state: present
register: host_acceptance_facts
- debug: var=host_acceptance_facts
- assert:
that:
- host_acceptance_facts.facts is defined
- name: Change acceptance level of given hosts in check mode
vmware_host_acceptance:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
acceptance_level: vmware_certified
state: present
register: host_acceptance_facts_check_mode
check_mode: yes
- debug: var=host_acceptance_facts_check_mode
- assert:
that:
- 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:
vmware_host_active_directory: - vcsim is not defined
hostname: "{{ vcsim }}" - active_directory_domain is defined
username: "{{ vcsim_instance.json.username }}" block:
password: "{{ vcsim_instance.json.password }}" - name: Join an AD domain in check mode
esxi_hostname: "{{ host1 }}" vmware_host_active_directory:
ad_domain: example.local hostname: "{{ vcenter_hostname }}"
ad_user: adjoin username: "{{ vcenter_username }}"
ad_password: Password123$ password: "{{ vcenter_password }}"
ad_state: present esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no ad_domain: '{{ active_directory_domain }}'
register: host_active_directory_facts_check_mode ad_user: '{{ active_directory_user }}'
check_mode: yes ad_password: '{{ active_directory_password }}'
ad_state: present
- debug: var=host_active_directory_facts_check_mode validate_certs: no
register: host_active_directory_facts_check_mode
- assert: check_mode: yes
that:
- host_active_directory_facts_check_mode is defined - debug: var=host_active_directory_facts_check_mode
- host_active_directory_facts_check_mode.changed
- assert:
- name: Join an AD domain that:
vmware_host_active_directory: - host_active_directory_facts_check_mode is defined
hostname: "{{ vcsim }}" - host_active_directory_facts_check_mode.changed
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}" - name: Join an AD domain
esxi_hostname: "{{ host1 }}" vmware_host_active_directory:
ad_domain: example.local hostname: "{{ vcenter_hostname }}"
ad_user: adjoin username: "{{ vcenter_username }}"
ad_password: Password123$ password: "{{ vcenter_password }}"
ad_state: present esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no ad_domain: example.local
register: host_active_directory_facts ad_user: adjoin
ad_password: Password123$
- debug: var=host_active_directory_facts ad_state: present
validate_certs: no
- assert: register: host_active_directory_facts
that: ignore_errors: true
- host_active_directory_facts is defined
- host_active_directory_facts.changed - debug: var=host_active_directory_facts
- name: Leave AD domain in check mode - assert:
vmware_host_active_directory: that:
hostname: "{{ vcsim }}" - host_active_directory_facts is defined
username: "{{ vcsim_instance.json.username }}" - host_active_directory_facts.changed
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}" - name: Leave AD domain in check mode
ad_state: absent vmware_host_active_directory:
validate_certs: no hostname: "{{ vcenter_hostname }}"
register: host_active_directory_facts_2_check_mode username: "{{ vcenter_username }}"
check_mode: yes password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
- debug: var=host_active_directory_facts_2_check_mode ad_state: absent
validate_certs: no
- assert: register: host_active_directory_facts_2_check_mode
that: check_mode: yes
- host_active_directory_facts_2_check_mode is defined
- host_active_directory_facts_2_check_mode.changed - debug: var=host_active_directory_facts_2_check_mode
- name: Leave AD domain - assert:
vmware_host_active_directory: that:
hostname: "{{ vcsim }}" - host_active_directory_facts_2_check_mode is defined
username: "{{ vcsim_instance.json.username }}" - host_active_directory_facts_2_check_mode.changed
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}" - name: Leave AD domain
ad_state: absent vmware_host_active_directory:
validate_certs: no hostname: "{{ vcenter_hostname }}"
register: host_active_directory_facts_2 username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
- debug: var=host_active_directory_facts_2 esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ad_state: absent
- assert: validate_certs: no
that: register: host_active_directory_facts_2
- host_active_directory_facts_2 is defined ignore_errors: true
- host_active_directory_facts_2.changed
- debug: var=host_active_directory_facts_2
- assert:
that:
- host_active_directory_facts_2 is defined
- 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 vmware_host_capability_facts:
hostname: "{{ vcenter_hostname }}"
- name: start vcsim username: "{{ vcenter_username }}"
uri: password: "{{ vcenter_password }}"
url: http://{{ vcsim }}:5000/spawn?cluster=2 validate_certs: False
register: vcsim_instance cluster_name: "{{ ccr1 }}"
register: capability_0001_results
- debug: - assert:
var: vcsim_instance that:
- not (capability_0001_results is changed)
- name: Wait for vcsim server to come up online - capability_0001_results.hosts_capability_facts is defined
wait_for:
host: "{{ vcsim }}" - name: Gather capability facts for ESXi host
port: 443 vmware_host_capability_facts:
state: started hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: get a list of Cluster from vcsim password: "{{ vcenter_password }}"
uri: validate_certs: False
url: http://{{ vcsim }}:5000/govc_find?filter=CCR esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: clusters register: capability_0002_results
- assert:
- name: get a cluster that:
set_fact: - not (capability_0002_results is changed)
ccr1: "{{ clusters.json[0] | basename }}" - capability_0002_results.hosts_capability_facts is defined
- 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:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: False
cluster_name: "{{ ccr1 }}"
register: capability_0001_results
- assert:
that:
- "not capability_0001_results.changed"
- "capability_0001_results.hosts_capability_facts is defined"
- name: Gather capability facts for ESXi host
vmware_host_capability_facts:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: False
esxi_hostname: "{{ host1 }}"
register: capability_0002_results
- assert:
that:
- "not capability_0002_results.changed"
- "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
vmware_host_config_facts: block:
hostname: "{{ vcsim }}" - name: gather facts about a given host in check mode
username: "{{ vcsim_instance.json.username }}" vmware_host_config_facts:
password: "{{ vcsim_instance.json.password }}" hostname: "{{ vcenter_hostname }}"
validate_certs: no username: "{{ vcenter_username }}"
esxi_hostname: "{{ host1 }}" password: "{{ vcenter_password }}"
register: single_hosts_result_check_mode validate_certs: no
check_mode: yes esxi_hostname: "{{ hostvars[esxi1].ansible_host }}"
register: single_hosts_result_check_mode
- name: ensure facts are gathered for all hosts check_mode: yes
assert: - name: ensure facts are gathered for all hosts
that: assert:
- single_hosts_result_check_mode.hosts_facts that:
- 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,115 +2,89 @@
# 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
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: Change facts about all hosts in given cluster
vmware_host_config_manager:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
cluster_name: "{{ ccr1 }}"
options:
'Config.HostAgent.log.level': 'verbose'
validate_certs: no
register: all_hosts_result
- name: ensure changes are done to all hosts
assert:
that:
- all_hosts_result.changed
- name: Change facts about a given host - name: Change an invalid key
vmware_host_config_manager: vmware_host_config_manager:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}"
options:
'Config.HostAgent.log.level': 'info'
validate_certs: no validate_certs: no
register: host_result hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: ensure changes are done to given hosts password: "{{ vcenter_password }}"
assert:
that:
- all_hosts_result.changed
- name: Change facts about all hosts in given cluster in check mode
vmware_host_config_manager:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
options: options:
'Config.HostAgent.log.level': 'verbose' 'This.Is.No.Where': 'verbose'
validate_certs: no failed_when: False
register: all_hosts_result_check_mode register: invalid_key
check_mode: yes - debug: var=invalid_key
- name: ensure we raise the correct error
- name: ensure changes are done to all hosts
assert: assert:
that: that:
- all_hosts_result_check_mode.changed - '"Unsupported option This.Is.No.Where" in invalid_key.msg'
- name: Change facts about a given host in check mode
vmware_host_config_manager:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}"
options:
'Config.HostAgent.log.level': 'info'
validate_certs: no
register: host_result_check_mode
check_mode: yes
- name: ensure changes are done to given hosts # TODO: vcsim does not support update host configuartion
assert: - when: vcsim is not defined
that: block:
- all_hosts_result_check_mode.changed - name: Change facts about all hosts in given cluster
vmware_host_config_manager:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
options:
'Config.HostAgent.log.level': 'verbose'
validate_certs: no
- name: Change facts about a given host
vmware_host_config_manager:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
options:
'Config.HostAgent.log.level': 'info'
validate_certs: no
register: host_result
- debug: var=host_result
- name: ensure change was applied
assert:
that:
- host_result is changed
- name: Change facts about all hosts in given cluster in check mode
vmware_host_config_manager:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
options:
'Config.HostAgent.log.level': 'verbose'
validate_certs: no
register: all_hosts_result_check_mode
check_mode: yes
- name: ensure changes are done to all hosts
assert:
that:
- all_hosts_result_check_mode.changed
- name: Change facts about a given host in check mode
vmware_host_config_manager:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
options:
'Config.HostAgent.log.level': 'info'
validate_certs: no
register: host_result_check_mode
check_mode: yes
- name: ensure changes are done to given hosts
assert:
that:
- 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
vmware_host_facts:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: facts
- debug: var=facts
- name: verify some data,like ansible_processor
assert:
that:
- "'ansible_hostname' in facts['ansible_facts']"
- "'ansible_processor' in facts['ansible_facts']"
- name: get host facts - name: get host facts through from a host
vmware_host_facts: vmware_host_facts:
validate_certs: False validate_certs: False
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 }}'
register: facts register: facts
- debug: var=facts
- debug: var=facts - name: verify some data,like ansible_processor
assert:
- name: get host info that:
uri: - "'ansible_hostname' in facts['ansible_facts']"
url: "{{ 'http://' + vcsim + ':5000/govc_host_info' }}" - "'ansible_processor' in facts['ansible_facts']"
register: host_info_result
- name: verify some data,like ansible_processor
assert:
that:
- facts['ansible_facts']['ansible_hostname'] in host_info_result['json']
- facts['ansible_facts']['ansible_processor'] == host_info_result['json'][facts['ansible_facts']['ansible_hostname']]['Processor type']

@ -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,102 +1,18 @@
# 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:
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 host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1
- debug: var=host1
- name: Gather firewall facts for all ESXi host from given cluster
vmware_host_firewall_facts:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
cluster_name: "{{ ccr1 }}"
register: firewall_0001_results
- assert:
that:
- "not firewall_0001_results.changed"
- "firewall_0001_results.hosts_firewall_facts is defined"
- 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
- assert:
that:
- "not firewall_0002_results.changed"
- "firewall_0002_results.hosts_firewall_facts is defined"
- name: Gather firewall facts for all ESXi host from given cluster in check mode
vmware_host_firewall_facts:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
cluster_name: "{{ ccr1 }}"
register: firewall_0003_results
check_mode: yes
- assert:
that:
- "not firewall_0003_results.changed"
- "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 register: firewall_0004_results
check_mode: yes check_mode: yes
@ -104,3 +20,54 @@
that: that:
- "not firewall_0004_results.changed" - "not firewall_0004_results.changed"
- "firewall_0004_results.hosts_firewall_facts is defined" - "firewall_0004_results.hosts_firewall_facts is defined"
- when: vcsim is not defined
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Gather firewall facts for all ESXi host from given cluster
vmware_host_firewall_facts:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
cluster_name: "{{ ccr1 }}"
register: firewall_0001_results
- assert:
that:
- "not firewall_0001_results.changed"
- "firewall_0001_results.hosts_firewall_facts is defined"
- name: Gather firewall facts for ESXi host
vmware_host_firewall_facts:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: firewall_0002_results
- assert:
that:
- "not firewall_0002_results.changed"
- "firewall_0002_results.hosts_firewall_facts is defined"
- name: Gather firewall facts for all ESXi host from given cluster in check mode
vmware_host_firewall_facts:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
cluster_name: "{{ ccr1 }}"
register: firewall_0003_results
check_mode: yes
- assert:
that:
- "not firewall_0003_results.changed"
- "firewall_0003_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,170 +1,129 @@
# 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
- 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: Disable the Firewall vvold rule on the ESXi
uri: vmware_host_firewall_manager:
url: http://{{ vcsim }}:5000/killall hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
- name: start vcsim password: '{{ vcenter_password }}'
uri: cluster_name: '{{ ccr1 }}'
url: http://{{ vcsim }}:5000/spawn?cluster=2 validate_certs: no
register: vcsim_instance rules:
- name: vvold
- debug: enabled: False
var: vcsim_instance
- name: Enable vvold rule set on all hosts of {{ ccr1 }}
- name: Wait for vcsim server to come up online vmware_host_firewall_manager:
wait_for: hostname: "{{ vcenter_hostname }}"
host: "{{ vcsim }}" username: "{{ vcenter_username }}"
port: 443 password: "{{ vcenter_password }}"
state: started validate_certs: no
cluster_name: "{{ ccr1 }}"
- name: get a list of Cluster from vcsim rules:
uri: - name: vvold
url: http://{{ vcsim }}:5000/govc_find?filter=CCR enabled: True
register: clusters register: all_hosts_result
- debug: msg="{{ all_hosts_result }}"
- name: get a cluster - name: ensure everything is changed for all hosts of {{ ccr1 }}
set_fact: assert:
ccr1: "{{ clusters.json[0] | basename }}" that:
- all_hosts_result.changed
- name: get a list of hosts from vcsim - all_hosts_result.rule_set_state is defined
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H - name: ensure facts are gathered for all hosts of {{ ccr1 }}
register: hosts assert:
that:
- name: get a cluster - all_hosts_result.rule_set_state[item]['vvold']['current_state'] == True
set_fact: - all_hosts_result.rule_set_state[item]['vvold']['desired_state'] == True
host1: "{{ hosts.json[0] | basename }}" - all_hosts_result.rule_set_state[item]['vvold']['previous_state'] == False
with_items:
- debug: var=ccr1 - '{{ hostvars[esxi1].ansible_host }}'
- debug: var=host1 - '{{ hostvars[esxi2].ansible_host }}'
- name: Enable vvold rule set on all hosts of {{ ccr1 }} - 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
cluster_name: "{{ ccr1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
rules: rules:
- name: vvold - name: vvold
enabled: True enabled: False
register: all_hosts_result register: host_result
- debug: msg="{{ host_result }}"
- debug: msg="{{ all_hosts_result }}" - name: ensure vvold is disabled for {{ host1 }}
assert:
- name: ensure everything is changed for all hosts of {{ ccr1 }} that:
assert: - host_result.changed
that: - host_result.rule_set_state is defined
- all_hosts_result.changed
- all_hosts_result.rule_set_state is defined - name: ensure facts are gathered for {{ host1 }}
assert:
- name: ensure facts are gathered for all hosts of {{ ccr1 }} that:
assert: - host_result.rule_set_state[item]['vvold']['current_state'] == False
that: - host_result.rule_set_state[item]['vvold']['desired_state'] == False
- all_hosts_result.rule_set_state[item]['vvold']['current_state'] == True - host_result.rule_set_state[item]['vvold']['previous_state'] == True
- all_hosts_result.rule_set_state[item]['vvold']['desired_state'] == True with_items:
- all_hosts_result.rule_set_state[item]['vvold']['previous_state'] == False - '{{ hostvars[esxi1].ansible_host }}'
with_items:
- DC0_C0_H0 - name: Enable vvold rule set on all hosts of {{ ccr1 }} in check mode
- DC0_C0_H1 vmware_host_firewall_manager:
- DC0_C0_H2 hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: Disable vvold for {{ host1 }} password: "{{ vcenter_password }}"
vmware_host_firewall_manager: validate_certs: no
hostname: "{{ vcsim }}" cluster_name: "{{ ccr1 }}"
username: "{{ vcsim_instance.json.username }}" rules:
password: "{{ vcsim_instance.json.password }}" - name: vvold
validate_certs: no enabled: True
esxi_hostname: "{{ host1 }}" register: all_hosts_result_check_mode
rules: check_mode: yes
- name: vvold - debug: var=all_hosts_result_check_mode
enabled: False - name: ensure everything is changed for all hosts of {{ ccr1 }}
register: host_result assert:
that:
- debug: msg="{{ host_result }}" - all_hosts_result_check_mode.changed
- all_hosts_result_check_mode.rule_set_state is defined
- name: ensure vvold is disabled for {{ host1 }}
assert: - name: ensure facts are gathered for all hosts of {{ ccr1 }}
that: assert:
- host_result.changed that:
- host_result.rule_set_state is defined - all_hosts_result_check_mode.rule_set_state[hostvars[esxi1].ansible_host]['vvold']['current_state'] == True
- all_hosts_result_check_mode.rule_set_state[hostvars[esxi2].ansible_host]['vvold']['current_state'] == True
- name: ensure facts are gathered for {{ host1 }} - all_hosts_result_check_mode.rule_set_state[hostvars[esxi2].ansible_host]['vvold']['desired_state'] == True
assert:
that: - name: Disable vvold for {{ host1 }} in check mode
- host_result.rule_set_state[item]['vvold']['current_state'] == False vmware_host_firewall_manager:
- host_result.rule_set_state[item]['vvold']['desired_state'] == False hostname: "{{ vcenter_hostname }}"
- host_result.rule_set_state[item]['vvold']['previous_state'] == True username: "{{ vcenter_username }}"
with_items: password: "{{ vcenter_password }}"
- "{{ host1 }}" validate_certs: no
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
- name: Enable vvold rule set on all hosts of {{ ccr1 }} in check mode rules:
vmware_host_firewall_manager: - name: vvold
hostname: "{{ vcsim }}" enabled: False
username: "{{ vcsim_instance.json.username }}" register: host_result_check_mode
password: "{{ vcsim_instance.json.password }}" check_mode: yes
validate_certs: no - debug: msg="{{ host_result_check_mode }}"
cluster_name: "{{ ccr1 }}" - name: ensure vvold is disabled for {{ host1 }}
rules: assert:
- name: vvold that:
enabled: True - host_result_check_mode.changed == False
register: all_hosts_result_check_mode - host_result_check_mode.rule_set_state is defined
check_mode: yes
- name: ensure facts are gathered for {{ host1 }}
- debug: msg="{{ all_hosts_result_check_mode }}" assert:
that:
- name: ensure everything is changed for all hosts of {{ ccr1 }} - host_result_check_mode.rule_set_state[item]['vvold']['current_state'] == False
assert: - host_result_check_mode.rule_set_state[item]['vvold']['desired_state'] == False
that: - host_result_check_mode.rule_set_state[item]['vvold']['previous_state'] == False
- all_hosts_result_check_mode.changed with_items:
- all_hosts_result_check_mode.rule_set_state is defined - '{{ hostvars[esxi1].ansible_host }}'
- name: ensure facts are gathered for all hosts of {{ ccr1 }}
assert:
that:
- all_hosts_result_check_mode.rule_set_state[item]['vvold']['current_state'] == True
- all_hosts_result_check_mode.rule_set_state[item]['vvold']['desired_state'] == True
- all_hosts_result_check_mode.rule_set_state[item]['vvold']['previous_state'] == False
with_items:
- DC0_C0_H0
- DC0_C0_H1
- DC0_C0_H2
- name: Disable vvold for {{ host1 }} in check mode
vmware_host_firewall_manager:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
esxi_hostname: "{{ host1 }}"
rules:
- name: vvold
enabled: False
register: host_result_check_mode
check_mode: yes
- debug: msg="{{ host_result_check_mode }}"
- name: ensure vvold is disabled for {{ host1 }}
assert:
that:
- host_result_check_mode.changed == False
- host_result_check_mode.rule_set_state is defined
- name: ensure facts are gathered for {{ host1 }}
assert:
that:
- host_result_check_mode.rule_set_state[item]['vvold']['current_state'] == False
- host_result_check_mode.rule_set_state[item]['vvold']['desired_state'] == False
- host_result_check_mode.rule_set_state[item]['vvold']['previous_state'] == False
with_items:
- "{{ host1 }}"

@ -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: Disable Hyperthreading for a given host
vmware_host_hyperthreading:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
state: disabled
register: host_hyperthreading_facts
- debug: var=host_hyperthreading_facts
- assert:
that:
- host_hyperthreading_facts is defined
- host_hyperthreading_facts.changed
- name: Disable Hyperthreading for a given host in check mode
vmware_host_hyperthreading:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
state: disabled
register: host_hyperthreading_facts_check_mode
check_mode: yes
- debug: var=host_hyperthreading_facts_check_mode
- assert:
that:
- host_hyperthreading_facts_check_mode is defined
- host_hyperthreading_facts_check_mode.changed
- name: Disable Hyperthreading for all hosts in given cluster
vmware_host_hyperthreading:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: disabled
register: host_hyperthreading_facts
- debug: var=host_hyperthreading_facts
- assert:
that:
- host_hyperthreading_facts is defined
- host_hyperthreading_facts.changed
- name: Disable Hyperthreading for all hosts in given cluster in check mode - name: Enable Hyperthreading everywhere
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 }}"
validate_certs: no validate_certs: no
state: disabled state: disabled
register: host_hyperthreading_facts_check_mode register: enable_hyperthreading_everywhere
check_mode: yes ignore_errors: true
- debug: var=host_hyperthreading_facts_check_mode - when: enable_hyperthreading_everywhere is succeeded
block:
- assert:
that: - name: Disable Hyperthreading for a given host
- host_hyperthreading_facts_check_mode is defined vmware_host_hyperthreading:
- host_hyperthreading_facts_check_mode.changed hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no
state: disabled
register: host_hyperthreading_facts
- debug: var=host_hyperthreading_facts
- assert:
that:
- host_hyperthreading_facts is defined
- host_hyperthreading_facts.changed
- name: Disable Hyperthreading for a given host in check mode
vmware_host_hyperthreading:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no
state: disabled
register: host_hyperthreading_facts_check_mode
check_mode: yes
- debug: var=host_hyperthreading_facts_check_mode
- assert:
that:
- host_hyperthreading_facts_check_mode is defined
- name: Disable Hyperthreading for all hosts in given cluster
vmware_host_hyperthreading:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: disabled
register: host_hyperthreading_facts
- debug: var=host_hyperthreading_facts
- assert:
that:
- host_hyperthreading_facts is defined
- host_hyperthreading_facts is changed
- name: Enable Hyperthreading for all hosts in given cluster in check mode
vmware_host_hyperthreading:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: enabled
register: host_hyperthreading_facts_check_mode
check_mode: yes
- debug: var=host_hyperthreading_facts_check_mode
- assert:
that:
- host_hyperthreading_facts_check_mode is defined
- 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
- 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: Ensure IPv6 is off
uri: vmware_host_ipv6:
url: http://{{ vcsim }}:5000/killall hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: start vcsim password: "{{ vcenter_password }}"
uri: cluster_name: "{{ ccr1 }}"
url: http://{{ vcsim }}:5000/spawn?cluster=2 validate_certs: no
register: vcsim_instance state: disabled
register: host_ipv6_facts
- debug:
var: vcsim_instance - name: Enable IPv6 support for a given host
vmware_host_ipv6:
- name: Wait for vcsim server to come up online hostname: "{{ vcenter_hostname }}"
wait_for: username: "{{ vcenter_username }}"
host: "{{ vcsim }}" password: "{{ vcenter_password }}"
port: 443 esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: started validate_certs: no
state: enabled
- name: get a list of clusters from vcsim register: host_ipv6_facts
uri: - debug: var=host_ipv6_facts
url: http://{{ vcsim }}:5000/govc_find?filter=CCR - assert:
register: clusters that:
- host_ipv6_facts is defined
- name: get a cluster - host_ipv6_facts.changed
set_fact:
ccr1: "{{ clusters.json[0] | basename }}" - name: Enable IPv6 support for a given host in check mode
vmware_host_ipv6:
- name: get a list of hosts from vcsim hostname: "{{ vcenter_hostname }}"
uri: username: "{{ vcenter_username }}"
url: http://{{ vcsim }}:5000/govc_find?filter=H password: "{{ vcenter_password }}"
register: hosts esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no
- name: get a host state: enabled
set_fact: register: host_ipv6_facts_check_mode
host1: "{{ hosts.json[0] | basename }}" check_mode: yes
- debug: var=host_ipv6_facts_check_mode
- debug: var=ccr1 - assert:
- debug: var=host1 that:
- host_ipv6_facts_check_mode is defined
- name: Enable IPv6 support for a given host - not (host_ipv6_facts_check_mode is changed)
vmware_host_ipv6:
hostname: "{{ vcsim }}" - name: Enable IPv6 support for all hosts in given cluster
username: "{{ vcsim_instance.json.username }}" vmware_host_ipv6:
password: "{{ vcsim_instance.json.password }}" hostname: "{{ vcenter_hostname }}"
esxi_hostname: "{{ host1 }}" username: "{{ vcenter_username }}"
validate_certs: no password: "{{ vcenter_password }}"
state: enabled cluster_name: "{{ ccr1 }}"
register: host_ipv6_facts validate_certs: no
state: enabled
- debug: var=host_ipv6_facts register: hosts_ipv6_facts
- debug: var=hosts_ipv6_facts
- assert: - assert:
that: that:
- host_ipv6_facts is defined - hosts_ipv6_facts is defined
- host_ipv6_facts.changed - hosts_ipv6_facts.changed
- name: Enable IPv6 support for a given host 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 }}"
esxi_hostname: "{{ host1 }}" cluster_name: "{{ ccr1 }}"
validate_certs: no validate_certs: no
state: enabled state: enabled
register: host_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=host_ipv6_facts_check_mode - assert:
that:
- assert: - hosts_ipv6_facts_check_mode is defined
that: - not (hosts_ipv6_facts_check_mode is changed)
- host_ipv6_facts_check_mode is defined
- host_ipv6_facts_check_mode.changed
- name: Enable IPv6 support for all hosts in given cluster
vmware_host_ipv6:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: enabled
register: hosts_ipv6_facts
- debug: var=hosts_ipv6_facts
- assert:
that:
- hosts_ipv6_facts is defined
- hosts_ipv6_facts.changed
- name: Enable IPv6 support for all hosts in given cluster in check mode
vmware_host_ipv6:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: enabled
register: hosts_ipv6_facts_check_mode
check_mode: yes
- debug: var=hosts_ipv6_facts_check_mode
- assert:
that:
- hosts_ipv6_facts_check_mode is defined
- hosts_ipv6_facts_check_mode.changed

@ -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 vmware_host_kernel_manager:
hostname: '{{ vcenter_hostname }}'
- name: start vcsim username: '{{ vcenter_username }}'
uri: password: '{{ vcenter_password }}'
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&host=1 validate_certs: False
register: vcsim_instance esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
kernel_module_name: "tcpip4"
- debug: var=vcsim_instance kernel_module_option: "ipv6=0"
register: my_results_01
- name: Wait for vcsim server to come up online - debug: var=my_results_01
wait_for: - name: Check that the provided kernel_module_name has kernel_module_option set
host: "{{ vcsim }}" assert:
port: 443 that:
state: started - "'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: get a list of hosts from vcsim
uri: - name: host connected, module exists, same options for idempotence test
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=host' }}" vmware_host_kernel_manager:
register: hostlist hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
- set_fact: password: '{{ vcenter_password }}'
host1: "{{ hostlist['json'][0] }}" validate_certs: False
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
- name: host connected, module exists, options exist, arguments different kernel_module_name: "tcpip4"
vmware_host_kernel_manager: kernel_module_option: "ipv6=0"
hostname: '{{ vcsim }}' register: my_results_02
username: '{{ vcsim_instance.json.username }}' - name: Check that changed is false
password: '{{ vcsim_instance.json.password }}' assert:
validate_certs: False that:
esxi_hostname: '{{ host1 }}' - not (my_results_02 is changed)
kernel_module_name: "tcpip4"
kernel_module_option: "ipv6=0"
register: my_results_01
- name: Check that the provided kernel_module_name has kernel_module_option set
assert:
that:
- "my_results_01.results['DC0_H0']['configured_options'] == 'ipv6=0'"
- name: host connected, module exists, same options for idempotence test
vmware_host_kernel_manager:
hostname: '{{ vcsim }}'
username: '{{ vcsim_instance.json.username }}'
password: '{{ vcsim_instance.json.password }}'
validate_certs: False
esxi_hostname: '{{ host1 }}'
kernel_module_name: "tcpip4"
kernel_module_option: "ipv6=0"
register: my_results_02
- name: Check that changed is false
assert:
that:
- "my_results_02.results['DC0_H0']['changed'] == false"

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

@ -3,216 +3,166 @@
# 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: vmware_host_ntp:
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 state: present
register: vcsim_instance ntp_servers:
- 0.pool.ntp.org
- debug: validate_certs: no
var: vcsim_instance register: present
- debug: var=present
- name: Wait for vcsim server to come up online
wait_for: - name: Add another NTP server to a host
host: "{{ vcsim }}" vmware_host_ntp:
port: 443 hostname: "{{ vcenter_hostname }}"
state: started username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
- name: get a list of Cluster from vcsim esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
uri: state: present
url: http://{{ vcsim }}:5000/govc_find?filter=CCR ntp_servers:
register: clusters - 1.pool.ntp.org
validate_certs: no
- name: get a cluster register: present
set_fact: - debug: var=present
ccr1: "{{ clusters.json[0] | basename }}"
- name: Remove NTP server from a host
- name: get a list of hosts from vcsim vmware_host_ntp:
uri: hostname: "{{ vcenter_hostname }}"
url: http://{{ vcsim }}:5000/govc_find?filter=H username: "{{ vcenter_username }}"
register: hosts password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
- name: get a host state: absent
set_fact: ntp_servers:
host1: "{{ hosts.json[0] | basename }}" - 1.pool.ntp.org
validate_certs: no
- debug: var=ccr1 register: absent_one
- debug: var=host1 - debug: var=absent_one
- name: Add NTP server to 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:
- 0.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 another NTP server to a host vmware_host_ntp:
vmware_host_ntp: hostname: "{{ vcenter_hostname }}"
hostname: "{{ vcsim }}" username: "{{ vcenter_username }}"
username: "{{ vcsim_instance['json']['username'] }}" password: "{{ vcenter_password }}"
password: "{{ vcsim_instance['json']['password'] }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
esxi_hostname: "{{ host1 }}" state: present
state: present ntp_servers:
ntp_server: - 2.pool.ntp.org
- 1.pool.ntp.org - 3.pool.ntp.org
validate_certs: no - 4.pool.ntp.org
register: present validate_certs: no
register: present
- debug: var=present - debug: var=present
- name: Remove NTP server 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:
- 1.pool.ntp.org - 0.pool.ntp.org
validate_certs: no - 1.pool.ntp.org
register: absent_one - 2.pool.ntp.org
- 3.pool.ntp.org
- debug: var=absent_one - 4.pool.ntp.org
- 6.pool.ntp.org
- name: Remove NTP server from a host validate_certs: no
vmware_host_ntp: register: absent_all
hostname: "{{ vcsim }}" - debug: var=absent_all
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}" - name: Configure NTP servers for a host
esxi_hostname: "{{ host1 }}" vmware_host_ntp:
state: present hostname: "{{ vcenter_hostname }}"
ntp_server: username: "{{ vcenter_username }}"
- 1.pool.ntp.org password: "{{ vcenter_password }}"
validate_certs: no esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: present ntp_servers:
- 0.pool.ntp.org
- debug: var=present - 1.pool.ntp.org
- 2.pool.ntp.org
- name: Add more NTP servers to a host validate_certs: no
vmware_host_ntp: register: ntp_servers
hostname: "{{ vcsim }}" - debug: var=ntp_servers
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}" - name: Configure NTP servers for a host
esxi_hostname: "{{ host1 }}" vmware_host_ntp:
state: present hostname: "{{ vcenter_hostname }}"
ntp_server: username: "{{ vcenter_username }}"
- 2.pool.ntp.org password: "{{ vcenter_password }}"
- 3.pool.ntp.org esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
- 4.pool.ntp.org ntp_servers:
validate_certs: no - 3.pool.ntp.org
register: present - 4.pool.ntp.org
- 5.pool.ntp.org
- debug: var=present verbose: true
validate_certs: no
- name: Remove all NTP servers from a host register: ntp_servers
vmware_host_ntp: - debug: var=ntp_servers
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}" - name: Add NTP server to a host in check mode
password: "{{ vcsim_instance['json']['password'] }}" vmware_host_ntp:
esxi_hostname: "{{ host1 }}" hostname: "{{ vcenter_hostname }}"
state: absent username: "{{ vcenter_username }}"
ntp_server: password: "{{ vcenter_password }}"
- 0.pool.ntp.org esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
- 1.pool.ntp.org state: present
- 2.pool.ntp.org ntp_servers:
- 3.pool.ntp.org - 0.pool.ntp.org
- 4.pool.ntp.org validate_certs: no
- 6.pool.ntp.org register: present
validate_certs: no check_mode: yes
register: absent_all - debug: var=present
- debug: var=absent_all - name: Remove NTP server to a host in check mode
vmware_host_ntp:
- name: Configure NTP servers for a host hostname: "{{ vcenter_hostname }}"
vmware_host_ntp: username: "{{ vcenter_username }}"
hostname: "{{ vcsim }}" password: "{{ vcenter_password }}"
username: "{{ vcsim_instance['json']['username'] }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
password: "{{ vcsim_instance['json']['password'] }}" state: absent
esxi_hostname: "{{ host1 }}" ntp_servers:
ntp_server: - 0.pool.ntp.org
- 0.pool.ntp.org validate_certs: no
- 1.pool.ntp.org register: present
- 2.pool.ntp.org check_mode: yes
validate_certs: no - debug: var=present
register: ntp_servers
- name: Configure NTP servers for a host in check mode
- debug: var=ntp_servers vmware_host_ntp:
hostname: "{{ vcenter_hostname }}"
- name: Configure NTP servers for a host username: "{{ vcenter_username }}"
vmware_host_ntp: password: "{{ vcenter_password }}"
hostname: "{{ vcsim }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
username: "{{ vcsim_instance['json']['username'] }}" ntp_servers:
password: "{{ vcsim_instance['json']['password'] }}" - 0.pool.ntp.org
esxi_hostname: "{{ host1 }}" - 1.pool.ntp.org
ntp_server: - 2.pool.ntp.org
- 3.pool.ntp.org validate_certs: no
- 4.pool.ntp.org register: ntp_servers
- 5.pool.ntp.org check_mode: yes
verbose: true - debug: var=ntp_servers
validate_certs: no
register: ntp_servers
- debug: var=ntp_servers
- name: Add NTP server to a host in check mode
vmware_host_ntp:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
esxi_hostname: "{{ host1 }}"
state: present
ntp_server:
- 0.pool.ntp.org
validate_certs: no
register: present
check_mode: yes
- debug: var=present
- name: Remove NTP server to a host in check mode
vmware_host_ntp:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
esxi_hostname: "{{ host1 }}"
state: absent
ntp_server:
- 0.pool.ntp.org
validate_certs: no
register: present
check_mode: yes
- debug: var=present
- name: Configure NTP servers for a host in check mode
vmware_host_ntp:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
esxi_hostname: "{{ host1 }}"
ntp_server:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
validate_certs: no
register: ntp_servers
check_mode: yes
- 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: vmware_host_ntp_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 validate_certs: no
register: vcsim_instance register: host_ntp
- debug: var=host_ntp
- debug: - assert:
var: vcsim_instance that:
- host_ntp.hosts_ntp_facts is defined
- 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:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
register: host_ntp
- debug: var=host_ntp
- assert:
that:
- 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: vmware_host_package_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 validate_certs: no
register: vcsim_instance register: host_packages
- debug: var=host_packages
- debug: - assert:
var: vcsim_instance that:
- host_packages.hosts_package_facts is defined
- 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:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
register: host_packages
- debug: var=host_packages
- assert:
that:
- 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
vmware_host_powermgmt_policy:
- name: Start vcsim hostname: "{{ vcenter_hostname }}"
uri: username: "{{ vcenter_username }}"
url: http://{{ vcsim }}:5000/spawn?cluster=2 password: "{{ vcenter_password }}"
register: vcsim_instance esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
policy: high-performance
- debug: validate_certs: no
var: vcsim_instance register: host_result
- debug: var=host_result
- name: Wait for vcsim server to come up online - name: Ensure Power Management Policy for esxi1
wait_for: assert:
host: "{{ vcsim }}" that:
port: 443 - host_result.result['{{ hostvars[esxi1].ansible_host }}'].current_state == "high-performance"
state: started
- name: Set the Power Management Policy on all hosts of {{ ccr1 }}
- name: Get a list of Cluster from vcsim vmware_host_powermgmt_policy:
uri: hostname: "{{ vcenter_hostname }}"
url: http://{{ vcsim }}:5000/govc_find?filter=CCR username: "{{ vcenter_username }}"
register: clusters password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
- name: Get a cluster policy: balanced
set_fact: validate_certs: no
ccr1: "{{ clusters.json[0] | basename }}" register: all_hosts_result
- debug: var=all_hosts_result
- name: Get a list of hosts from vcsim - name: Ensure Power Management Policy is changed for all hosts of {{ ccr1 }}
uri: assert:
url: http://{{ vcsim }}:5000/govc_find?filter=H that:
register: hosts - all_hosts_result is changed
- all_hosts_result.result is defined
- name: Get a host
set_fact: - name: Set the Power Management Policy for esxi1 in check mode
host1: "{{ hosts.json[0] | basename }}" vmware_host_powermgmt_policy:
hostname: "{{ vcenter_hostname }}"
- debug: var=ccr1 username: "{{ vcenter_username }}"
- debug: var=host1 password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
# The following test cases aren't supported by vcsim policy: high-performance
- name: Set the Power Management Policy for {{ host1 }} validate_certs: no
vmware_host_powermgmt_policy: register: host_result
hostname: "{{ vcsim }}" check_mode: yes
username: "{{ vcsim_instance.json.username }}" - debug: var=host_result
password: "{{ vcsim_instance.json.password }}" - name: Ensure Power Management Policy for esxi1 in check mode
esxi_hostname: "{{ host1 }}" assert:
policy: high-performance that:
validate_certs: no - host_result is changed
register: host_result - host_result.result is defined
- debug: msg="{{ host_result }}" - name: Set the Power Management Policy on all hosts of {{ ccr1 }}
vmware_host_powermgmt_policy:
- name: Ensure Power Management Policy for {{ host1 }} hostname: "{{ vcenter_hostname }}"
assert: username: "{{ vcenter_username }}"
that: password: "{{ vcenter_password }}"
- host_result is changed cluster_name: "{{ ccr1 }}"
- host_result.result is defined policy: balanced
validate_certs: no
- name: Set the Power Management Policy on all hosts of {{ ccr1 }} register: all_hosts_result
vmware_host_powermgmt_policy: check_mode: yes
hostname: "{{ vcsim }}" - debug: var=all_hosts_result
username: "{{ vcsim_instance.json.username }}" - name: Ensure we are still using the 'balanced' mode
password: "{{ vcsim_instance.json.password }}" assert:
esxi_hostname: "{{ host1 }}" that:
policy: balanced - not (all_hosts_result is changed)
validate_certs: no - "all_hosts_result.result['{{ hostvars[esxi1].ansible_host }}']current_state == 'balanced'"
register: all_hosts_result - "all_hosts_result.result['{{ hostvars[esxi2].ansible_host }}']current_state == 'balanced'"
- debug: msg="{{ all_hosts_result }}"
- name: Ensure Power Management Policy is changed for all hosts of {{ ccr1 }}
assert:
that:
- all_hosts_result is changed
- all_hosts_result.result is defined
- name: Set the Power Management Policy for {{ host1 }} in check mode
vmware_host_powermgmt_policy:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}"
policy: high-performance
validate_certs: no
register: host_result
check_mode: yes
- debug: msg="{{ host_result }}"
- name: Ensure Power Management Policy for {{ host1 }} in check mode
assert:
that:
- host_result is changed
- host_result.result is defined
- name: Set the Power Management Policy on all hosts of {{ ccr1 }} in check mode
vmware_host_powermgmt_policy:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}"
policy: balanced
validate_certs: no
register: all_hosts_result
check_mode: yes
- debug: msg="{{ all_hosts_result }}"
- name: Ensure Power Management Policy is changed for all hosts of {{ ccr1 }} in check mode
assert:
that:
- all_hosts_result is changed
- all_hosts_result.result is defined

@ -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 vmware_host_powerstate:
hostname: "{{ vcenter_hostname }}"
- debug: username: "{{ vcenter_username }}"
var: vcsim_instance password: "{{ vcenter_password }}"
validate_certs: False
- name: Wait for vcsim server to come up online state: power-down-to-standby
wait_for: esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
host: "{{ vcsim }}" force: True
port: 443 register: host_powerstate
state: started
- debug: var=host_powerstate
- name: get a list of hosts from vcsim
uri: - assert:
url: http://{{ vcsim }}:5000/govc_find?filter=H that:
register: hosts - host_powerstate.results is changed
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: Restart Host
vmware_host_powerstate:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: False
state: power-down-to-standby
esxi_hostname: "{{ host1 }}"
force: True
register: host_powerstate
- debug: var=host_powerstate
- assert:
that:
- host_powerstate.results is changed

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

@ -1,80 +1,25 @@
# 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: vmware_host_scanhba:
url: http://{{ vcsim }}:5000/killall hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: start vcsim password: "{{ vcenter_password }}"
uri: validate_certs: no
url: http://{{ vcsim }}:5000/spawn?cluster=2 cluster_name: '{{ ccr1 }}'
register: vcsim_instance refresh_storage: false
register: host_scan_results
- debug: - debug: msg="{{ host_scan_results }}"
var: vcsim_instance - name: ensure a change occured (as in the scan happened) and the task didnt fail
assert:
- name: Wait for vcsim server to come up online that:
wait_for: - host_scan_results.changed
host: "{{ vcsim }}" - not host_scan_results.failed
port: 443
state: started
- name: get a list of Datacenter from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- name: get a datacenter
set_fact:
dc1: "{{ datacenters.json[0] | basename }}"
- debug: var=dc1
- name: get a list of Cluster from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
register: clusters
- name: get a cluster
set_fact:
ccr1: "{{ clusters.json[0] | basename }}"
- debug: var=ccr1
- name: add host
vmware_host:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
esxi_hostname: test_host_system_0001
esxi_username: "{{ vcsim_instance.json.username }}"
esxi_password: "{{ vcsim_instance.json.password }}"
datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
state: present
- name: Recan HBA's for an entire cluster (there should be at least one host as above)
vmware_host_scanhba:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
cluster_name: '{{ ccr1 }}'
refresh_storage: false
register: host_scan_results
- debug: msg="{{ host_scan_results }}"
- name: ensure a change occured (as in the scan happened) and the task didnt fail
assert:
that:
- host_scan_results.changed
- not host_scan_results.failed

@ -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 vmware_host_service_facts:
hostname: "{{ vcenter_hostname }}"
- name: start vcsim username: "{{ vcenter_username }}"
uri: password: "{{ vcenter_password }}"
url: http://{{ vcsim }}:5000/spawn?cluster=2 esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: vcsim_instance validate_certs: no
register: host_services
- debug:
var: vcsim_instance - debug:
var: host_services
- name: Wait for vcsim server to come up online
wait_for: - assert:
host: "{{ vcsim }}" that:
port: 443 - host_services.host_service_facts is defined
state: started
- <<: *host_srv_facts
- name: get a list of hosts from vcsim name: Check facts about all hosts in given cluster in check mode
uri: check_mode: yes
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts - debug:
var: host_services
- name: get a host
set_fact: - assert:
host1: "{{ hosts.json[0] | basename }}" that:
- host_services.host_service_facts is defined
- debug: var=host1
- name: Change facts about all hosts in given cluster
vmware_host_service_facts:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
register: host_services
- debug: var=host_services
- assert:
that:
- 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: vmware_host_service_manager:
url: http://{{ vcsim }}:5000/killall hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: start vcsim password: "{{ vcenter_password }}"
uri: validate_certs: no
url: http://{{ vcsim }}:5000/spawn?cluster=2 cluster_name: "{{ ccr1 }}"
register: vcsim_instance service_name: ntpd
state: present
- debug: register: all_hosts_result
var: vcsim_instance - debug: var=all_hosts_result
- name: Wait for vcsim server to come up online - name: Stop ntpd service on a given host
wait_for: vmware_host_service_manager:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 443 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
validate_certs: no
- name: get a list of Cluster from vcsim esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
uri: service_name: ntpd
url: http://{{ vcsim }}:5000/govc_find?filter=CCR state: absent
register: clusters register: single_hosts_result
- name: ensure facts are gathered
- name: get a cluster assert:
set_fact: that:
ccr1: "{{ clusters.json[0] | basename }}" - single_hosts_result is changed
- name: get a list of hosts from vcsim - name: Start ntpd service on all hosts in given cluster in check mode
uri: vmware_host_service_manager:
url: http://{{ vcsim }}:5000/govc_find?filter=H hostname: "{{ vcenter_hostname }}"
register: hosts username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
- name: get a cluster validate_certs: no
set_fact: cluster_name: "{{ ccr1 }}"
host1: "{{ hosts.json[0] | basename }}" service_name: ntpd
state: present
- debug: var=ccr1 register: all_hosts_result_check_mode
- debug: var=host1 check_mode: yes
- name: ensure facts are gathered for all hosts
- name: Start ntpd service on all hosts in given cluster assert:
vmware_host_service_manager: that:
hostname: "{{ vcsim }}" - all_hosts_result_check_mode is changed
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}" - name: Stop ntpd service on a given host in check mode
validate_certs: no vmware_host_service_manager:
cluster_name: "{{ ccr1 }}" hostname: "{{ vcenter_hostname }}"
service_name: ntpd username: "{{ vcenter_username }}"
state: present password: "{{ vcenter_password }}"
register: all_hosts_result validate_certs: no
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
- name: ensure facts are gathered for all hosts service_name: ntpd
assert: state: absent
that: register: single_hosts_result_check_mode
- all_hosts_result.changed check_mode: yes
- name: ensure facts are gathered
- name: Stop ntpd service on a given host assert:
vmware_host_service_manager: that:
hostname: "{{ vcsim }}" - not (single_hosts_result_check_mode is changed)
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}" - name: Start ntpd service on all hosts in given cluster
validate_certs: no vmware_host_service_manager:
esxi_hostname: "{{ host1 }}" hostname: "{{ vcenter_hostname }}"
service_name: ntpd username: "{{ vcenter_username }}"
state: absent password: "{{ vcenter_password }}"
register: single_hosts_result validate_certs: no
cluster_name: "{{ ccr1 }}"
- name: ensure facts are gathered service_name: ntpd
assert: state: present
that: register: all_hosts_result_check_mode
- single_hosts_result.changed == False - name: finally, ensure ntp is running on the cluster
assert:
- name: Start ntpd service on all hosts in given cluster in check mode that:
vmware_host_service_manager: - all_hosts_result_check_mode is changed
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
cluster_name: "{{ ccr1 }}"
service_name: ntpd
state: present
register: all_hosts_result_check_mode
check_mode: yes
- name: ensure facts are gathered for all hosts
assert:
that:
- all_hosts_result_check_mode.changed
- name: Stop ntpd service on a given host in check mode
vmware_host_service_manager:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
esxi_hostname: "{{ host1 }}"
service_name: ntpd
state: absent
register: single_hosts_result_check_mode
check_mode: yes
- name: ensure facts are gathered
assert:
that:
- single_hosts_result_check_mode.changed == False

@ -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
vmware_host_snmp:
# SNMP works only with standalone ESXi server hostname: '{{ hostvars[esxi1].ansible_host }}'
- name: start vcsim username: '{{ hostvars[esxi1].ansible_user }}'
uri: password: '{{ hostvars[esxi1].ansible_password }}'
url: http://{{ vcsim }}:5000/spawn?esx=1 community: [ test ]
register: vcsim_instance state: enabled
validate_certs: no
- debug: register: snmp_enabled_check_mode
var: vcsim_instance check_mode: yes
- debug: var=snmp_enabled_check_mode
- name: Wait for vcsim server to come up online - assert:
wait_for: that:
host: "{{ vcsim }}" - snmp_enabled_check_mode is defined
port: 443 - snmp_enabled_check_mode.changed
state: started
- name: Enable and configure SNMP community
- name: Enable and configure SNMP community in check mode vmware_host_snmp:
vmware_host_snmp: hostname: '{{ hostvars[esxi1].ansible_host }}'
hostname: "{{ vcsim }}" username: '{{ hostvars[esxi1].ansible_user }}'
username: "{{ vcsim_instance.json.username }}" password: '{{ hostvars[esxi1].ansible_password }}'
password: "{{ vcsim_instance.json.password }}" community: [ test ]
community: [ test ] state: enabled
state: enabled validate_certs: no
validate_certs: no register: snmp_enabled
register: snmp_enabled_check_mode - debug: var=snmp_enabled
check_mode: yes - assert:
that:
- debug: var=snmp_enabled_check_mode - snmp_enabled is defined
- snmp_enabled.changed
- assert:
that: - name: Disable SNMP
- snmp_enabled_check_mode is defined vmware_host_snmp:
- snmp_enabled_check_mode.changed hostname: '{{ hostvars[esxi1].ansible_host }}'
username: '{{ hostvars[esxi1].ansible_user }}'
- name: Enable and configure SNMP community password: '{{ hostvars[esxi1].ansible_password }}'
vmware_host_snmp: state: disabled
hostname: "{{ vcsim }}" validate_certs: no
username: "{{ vcsim_instance.json.username }}" register: snmp_disabled
password: "{{ vcsim_instance.json.password }}" - debug: var=snmp_enabled
community: [ test ] - assert:
state: enabled that:
validate_certs: no - snmp_enabled is defined
register: snmp_enabled - snmp_enabled.changed
check_mode: yes
- debug: var=snmp_enabled
- assert:
that:
- snmp_enabled is defined
- 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 vmware_host_vmhba_facts:
hostname: "{{ vcenter_hostname }}"
- name: start vcsim username: "{{ vcenter_username }}"
uri: password: "{{ vcenter_password }}"
url: http://{{ vcsim }}:5000/spawn?cluster=2 esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: vcsim_instance validate_certs: no
register: host_vmhbas
- debug:
var: vcsim_instance - debug:
var: host_vmhbas
- name: Wait for vcsim server to come up online
wait_for: - assert:
host: "{{ vcsim }}" that:
port: 443 - host_vmhbas.hosts_vmhbas_facts is defined
state: started
- <<: *vmhba_data
- name: get a list of hosts from vcsim name: Gather vmhba facts in check mode
uri: check_mode: yes
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts - debug:
var: host_vmhbas
- name: get a host
set_fact: - assert:
host1: "{{ hosts.json[0] | basename }}" that:
- host_vmhbas.hosts_vmhbas_facts is defined
- debug: var=host1
- name: Gather vmhba facts
vmware_host_vmhba_facts:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
register: host_vmhbas
- debug: var=host_vmhbas
- assert:
that:
- 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 validate_certs: no
register: vcsim_instance register: host_vmnics
- debug: var=host_vmnics
- debug: - assert:
var: vcsim_instance that:
- host_vmnics.hosts_vmnics_facts is defined
- name: Wait for vcsim server to come up online
wait_for: - name: Gather extended vmnic facts about a host
host: "{{ vcsim }}" vmware_host_vmnic_facts:
port: 443 hostname: "{{ vcenter_hostname }}"
state: started username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
- name: get a list of hosts from vcsim esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
uri: validate_certs: no
url: http://{{ vcsim }}:5000/govc_find?filter=H capabilities: true
register: hosts directpath_io: true
sriov: true
- name: get a host register: host_vmnics_extended
set_fact: - debug: var=host_vmnics_extended
host1: "{{ hosts.json[0] | basename }}" - assert:
that:
- debug: var=host1 - host_vmnics_extended.hosts_vmnics_facts is defined
- name: Gather vmnic facts about a host
vmware_host_vmnics_facts:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
register: host_vmnics
- debug: var=host_vmnics
- assert:
that:
- host_vmnics.hosts_vmnics_facts is defined
- name: Gather extended vmnic facts about a host
vmware_host_vmnics_facts:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
capabilities: true
directpath_io: true
sriov: true
register: host_vmnics_extended
- debug: var=host_vmnics_extended
- assert:
that:
- host_vmnics_extended.hosts_vmnics_facts is defined

Loading…
Cancel
Save