1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #55730 from goneri/vmware_refact_part5

vmware: refactoring of vmware test roles -- part5
This commit is contained in:
Gonéri Le Bouder 2019-05-02 09:28:17 -04:00 committed by GitHub
parent 39d1794ed9
commit 636f8cbdab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 1428 additions and 2319 deletions

View file

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

View file

@ -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 }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
esxi_hostname: test_host_system_0001
esxi_username: "{{ vcsim_instance.json.username }}"
esxi_password: "{{ vcsim_instance.json.password }}"
datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
fetch_ssl_thumbprint: False
state: present
register: add_host_result
- name: get a list of host system from vcsim after adding host system - name: Add first ESXi Host to vCenter
uri: vmware_host:
url: http://{{ vcsim }}:5000/govc_find?filter=H hostname: '{{ vcenter_hostname }}'
register: host_list username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter_name: '{{ dc1 }}'
cluster_name: '{{ ccr1 }}'
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
esxi_username: '{{ hostvars[esxi1].ansible_user }}'
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
state: present
validate_certs: no
register: readd_host_result
- name: ensure host system is present - name: Add first ESXi Host to vCenter (again)
assert: vmware_host:
that: hostname: '{{ vcenter_hostname }}'
- add_host_result is changed username: '{{ vcenter_username }}'
- "{% for host in host_list.json if ((host | basename) == 'test_host_system_0001') -%} True {%- else -%} False {%- endfor %}" password: '{{ vcenter_password }}'
datacenter_name: '{{ dc1 }}'
cluster_name: '{{ ccr1 }}'
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
esxi_username: '{{ hostvars[esxi1].ansible_user }}'
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
state: present
validate_certs: no
register: readd_host_result
# Testcase: Add Host again - name: ensure precend task didn't changed anything
- name: add host again assert:
vmware_host: that:
hostname: "{{ vcsim }}" - not ( readd_host_result is changed)
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 - name: add second host via add_or_reconnect
assert: vmware_host:
that: hostname: "{{ vcenter_hostname }}"
- not ( readd_host_result is changed) 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
# Testcase: Add Host via add_or_reconnect state - when: vcsim is not defined
- name: add host via add_or_reconnect block:
vmware_host: - name: disconnect host 2
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 }}"
esxi_hostname: test_host_system_0002 validate_certs: no
esxi_username: "{{ vcsim_instance.json.username }}" esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
esxi_password: "{{ vcsim_instance.json.password }}" datacenter_name: "{{ dc1 }}"
datacenter_name: "{{ dc1 }}" cluster_name: "{{ ccr1 }}"
cluster_name: "{{ ccr1 }}" fetch_ssl_thumbprint: False
fetch_ssl_thumbprint: False state: absent
state: add_or_reconnect
register: add_or_reconnect_host_result
- name: get a list of host system from vcsim after adding host system - name: remove host again
uri: vmware_host:
url: http://{{ vcsim }}:5000/govc_find?filter=H hostname: "{{ vcenter_hostname }}"
register: host_list username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
state: absent
register: reremove_host_result
- name: ensure precend task didn't changed anything
assert:
that:
- not ( reremove_host_result is changed)
- name: 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 }}"
#
# - name: ensure folder is present
# assert:
# that:
# - folder_results.changed
#
# - name: Create host folder again
# vcenter_folder:
# hostname: "{{ vcsim }}"
# username: "{{ vcsim_instance.json.username }}"
# password: "{{ vcsim_instance.json.password }}"
# validate_certs: no
# datacenter: "{{ dc1 }}"
# folder_name: "Staging"
# folder_type: host
# state: present
# register: folder_results
#
# - debug: msg="{{ folder_results }}"
#
# - name: ensure folder is present
# assert:
# that:
# - folder_results.changed == False
#
# - name: Add host to folder in check mode
# vmware_host:
# hostname: "{{ vcsim }}"
# username: "{{ vcsim_instance.json.username }}"
# password: "{{ vcsim_instance.json.password }}"
# validate_certs: no
# esxi_hostname: test_host_system_0003
# esxi_username: "{{ vcsim_instance.json.username }}"
# esxi_password: "{{ vcsim_instance.json.password }}"
# datacenter_name: "{{ dc1 }}"
# folder_name: "Staging"
# state: present
# register: add_host_to_folder_result
# check_mode: yes
#
# - name: get a list of host system from vcsim after adding host system
# uri:
# url: http://{{ vcsim }}:5000/govc_find?filter=H
# register: host_list
#
# - name: ensure host system is not present
# assert:
# that:
# - add_host_to_folder_result is changed
# - not ("{% for host in host_list.json if ((host | basename) == 'test_host_system_0003') -%} True {%- else -%} False {%- endfor %}")
#
# - name: Add host to folder
# vmware_host:
# hostname: "{{ vcsim }}"
# username: "{{ vcsim_instance.json.username }}"
# password: "{{ vcsim_instance.json.password }}"
# validate_certs: no
# esxi_hostname: test_host_system_0003
# esxi_username: "{{ vcsim_instance.json.username }}"
# esxi_password: "{{ vcsim_instance.json.password }}"
# datacenter_name: "{{ dc1 }}"
# folder_name: "Staging"
# state: present
# register: add_host_to_folder_result
#
# - name: get a list of host system from vcsim after adding host system
# uri:
# url: http://{{ vcsim }}:5000/govc_find?filter=H
# register: host_list
#
# - name: ensure host system is present
# assert:
# that:
# - add_host_to_folder_result is changed
# - "{% for host in host_list.json if ((host | basename) == 'test_host_system_0003') -%} True {%- else -%} False {%- endfor %}"
## Testcase: Reconnect Host - debug: msg="{{ folder_results }}"
#
# 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 - name: ensure folder is present
# assert:
# EnterMaintenanceMode_Task need to be implemented in vcsim for this test to work that:
# https://github.com/vmware/govmomi/tree/master/vcsim#supported-methods - folder_results.changed
#
#- 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 - name: Add host to folder in check mode
# vmware_host:
# EnterMaintenanceMode_Task need to be implemented in vcsim for this test to work hostname: "{{ vcenter_hostname }}"
# https://github.com/vmware/govmomi/tree/master/vcsim#supported-methods username: "{{ vcenter_username }}"
# password: "{{ vcenter_password }}"
#- name: remove host again 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 folder_name: "/{{ dc1 }}/host/Staging"
# esxi_hostname: test_host_system_0001 state: present
# datacenter_name: "{{ dc1 }}" register: add_host_to_folder_result
# cluster_name: "{{ ccr1 }}" check_mode: yes
# state: absent
# register: reremove_host_result - name: ensure host system is not present
# assert:
#- name: ensure precend task didn't changed anything that:
# assert: - add_host_to_folder_result is changed
# that:
# - not ( reremove_host_result is changed) - name: Add host to folder
vmware_host:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
datacenter_name: "{{ dc1 }}"
folder_name: "/{{ dc1 }}/host/Staging"
state: present
register: add_host_to_folder_result
- name: ensure host system is present
assert:
that:
- add_host_to_folder_result is changed
- name: reconnect host
vmware_host:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
esxi_hostname: '{{ hostvars[esxi2].ansible_host }}'
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
datacenter_name: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
state: reconnect
register: reconnect_host_result
- name: ensure host system has been reconnected
assert:
that:
- reconnect_host_result is changed
# it would be a good idea to check the events on the host to see the reconnect
# https://github.com/vmware/govmomi/blob/master/govc/USAGE.md#events
# "govc events ..." need to be callable from
# https://github.com/ansible/vcenter-test-container/flask_control.py

View file

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

View file

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

View file

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

View file

@ -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
validate_certs: no
register: host_active_directory_facts_check_mode
check_mode: yes
- debug: var=host_active_directory_facts_check_mode - debug: var=host_active_directory_facts_check_mode
- assert: - assert:
that: that:
- host_active_directory_facts_check_mode is defined - host_active_directory_facts_check_mode is defined
- host_active_directory_facts_check_mode.changed - host_active_directory_facts_check_mode.changed
- name: Join an AD domain - name: Join an AD domain
vmware_host_active_directory: vmware_host_active_directory:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ad_domain: example.local ad_domain: example.local
ad_user: adjoin ad_user: adjoin
ad_password: Password123$ ad_password: Password123$
ad_state: present ad_state: present
validate_certs: no validate_certs: no
register: host_active_directory_facts register: host_active_directory_facts
ignore_errors: true
- debug: var=host_active_directory_facts - debug: var=host_active_directory_facts
- assert: - assert:
that: that:
- host_active_directory_facts is defined - host_active_directory_facts is defined
- host_active_directory_facts.changed - host_active_directory_facts.changed
- name: Leave AD domain in check mode - name: Leave AD domain in check mode
vmware_host_active_directory: vmware_host_active_directory:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ad_state: absent ad_state: absent
validate_certs: no validate_certs: no
register: host_active_directory_facts_2_check_mode register: host_active_directory_facts_2_check_mode
check_mode: yes check_mode: yes
- debug: var=host_active_directory_facts_2_check_mode - debug: var=host_active_directory_facts_2_check_mode
- assert: - assert:
that: that:
- host_active_directory_facts_2_check_mode is defined - host_active_directory_facts_2_check_mode is defined
- host_active_directory_facts_2_check_mode.changed - host_active_directory_facts_2_check_mode.changed
- name: Leave AD domain - name: Leave AD domain
vmware_host_active_directory: vmware_host_active_directory:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ad_state: absent ad_state: absent
validate_certs: no validate_certs: no
register: host_active_directory_facts_2 register: host_active_directory_facts_2
ignore_errors: true
- debug: var=host_active_directory_facts_2 - debug: var=host_active_directory_facts_2
- assert: - assert:
that: that:
- host_active_directory_facts_2 is defined - host_active_directory_facts_2 is defined
- host_active_directory_facts_2.changed - host_active_directory_facts_2.changed

View file

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

View file

@ -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 - name: Gather capability facts for all ESXi host from given cluster
uri: vmware_host_capability_facts:
url: http://{{ vcsim }}:5000/killall hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: False
cluster_name: "{{ ccr1 }}"
register: capability_0001_results
- assert:
that:
- not (capability_0001_results is changed)
- capability_0001_results.hosts_capability_facts is defined
- name: start vcsim - name: Gather capability facts for ESXi host
uri: vmware_host_capability_facts:
url: http://{{ vcsim }}:5000/spawn?cluster=2 hostname: "{{ vcenter_hostname }}"
register: vcsim_instance username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
- debug: validate_certs: False
var: vcsim_instance esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: capability_0002_results
- name: Wait for vcsim server to come up online - assert:
wait_for: that:
host: "{{ vcsim }}" - not (capability_0002_results is changed)
port: 443 - capability_0002_results.hosts_capability_facts is defined
state: started
- name: get a list of Cluster from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
register: clusters
- name: get a cluster
set_fact:
ccr1: "{{ clusters.json[0] | basename }}"
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1
- debug: var=host1
- name: Gather capability facts for all ESXi host from given cluster
vmware_host_capability_facts:
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"

View file

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

View file

@ -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
- debug:
var: all_hosts_result
- name: ensure facts are gathered for all hosts - name: ensure facts are gathered for all hosts
assert: assert:
that: that:
- all_hosts_result.hosts_facts - 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
assert:
that:
- single_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
check_mode: yes
- name: ensure facts are gathered for all hosts
assert:
that:
- single_hosts_result_check_mode.hosts_facts
- name: ensure facts are gathered for all hosts - name: gather facts about a given host
assert: vmware_host_config_facts:
that: hostname: "{{ vcenter_hostname }}"
- single_hosts_result_check_mode.hosts_facts 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

View file

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

View file

@ -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)
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Change an invalid key
vmware_host_config_manager:
validate_certs: no
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
options:
'This.Is.No.Where': 'verbose'
failed_when: False
register: invalid_key
- debug: var=invalid_key
- name: ensure we raise the correct error
assert:
that:
- '"Unsupported option This.Is.No.Where" in invalid_key.msg'
# TODO: vcsim does not support update host configuartion # TODO: vcsim does not support update host configuartion
- when: vcsim is not defined
block:
- name: Change facts about all hosts in given cluster
vmware_host_config_manager:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
options:
'Config.HostAgent.log.level': 'verbose'
validate_certs: no
- name: Wait for Flask controller to come up online - name: Change facts about a given host
wait_for: vmware_host_config_manager:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 5000 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
options:
'Config.HostAgent.log.level': 'info'
validate_certs: no
register: host_result
- name: kill vcsim - debug: var=host_result
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim - name: ensure change was applied
uri: assert:
url: http://{{ vcsim }}:5000/spawn?cluster=2 that:
register: vcsim_instance - host_result is changed
- debug: - name: Change facts about all hosts in given cluster in check mode
var: vcsim_instance 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: Wait for vcsim server to come up online - name: ensure changes are done to all hosts
wait_for: assert:
host: "{{ vcsim }}" that:
port: 443 - all_hosts_result_check_mode.changed
state: started
- name: get a list of Cluster from vcsim - name: Change facts about a given host in check mode
uri: vmware_host_config_manager:
url: http://{{ vcsim }}:5000/govc_find?filter=CCR hostname: "{{ vcenter_hostname }}"
register: clusters 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: get a cluster - name: ensure changes are done to given hosts
set_fact: assert:
ccr1: "{{ clusters.json[0] | basename }}" that:
- all_hosts_result_check_mode.changed
- 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
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
- name: ensure changes are done to given hosts
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 }}"
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: "{{ 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
assert:
that:
- all_hosts_result_check_mode.changed

View file

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

View file

@ -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

View file

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

View file

@ -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']

View file

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

View file

@ -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"

View file

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

View file

@ -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: vmware_host_firewall_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
cluster_name: "{{ ccr1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
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: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
validate_certs: no
esxi_hostname: "{{ host1 }}"
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"

View file

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

View file

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

View file

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

View file

@ -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
- 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 }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no validate_certs: no
state: disabled state: disabled
register: host_hyperthreading_facts register: enable_hyperthreading_everywhere
ignore_errors: true
- debug: var=host_hyperthreading_facts - when: enable_hyperthreading_everywhere is succeeded
block:
- assert: - name: Disable Hyperthreading for a given host
that: vmware_host_hyperthreading:
- host_hyperthreading_facts is defined hostname: "{{ vcenter_hostname }}"
- host_hyperthreading_facts.changed username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no
state: disabled
register: host_hyperthreading_facts
- name: Disable Hyperthreading for a given host in check mode - debug: var=host_hyperthreading_facts
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 is defined
- host_hyperthreading_facts.changed
- assert: - name: Disable Hyperthreading for a given host in check mode
that: vmware_host_hyperthreading:
- host_hyperthreading_facts_check_mode is defined hostname: "{{ vcenter_hostname }}"
- host_hyperthreading_facts_check_mode.changed 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
- name: Disable Hyperthreading for all hosts in given cluster - debug: var=host_hyperthreading_facts_check_mode
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_check_mode is defined
- assert: - name: Disable Hyperthreading for all hosts in given cluster
that: vmware_host_hyperthreading:
- host_hyperthreading_facts is defined hostname: "{{ vcenter_hostname }}"
- host_hyperthreading_facts.changed username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: disabled
register: host_hyperthreading_facts
- name: Disable Hyperthreading for all hosts in given cluster in check mode - debug: var=host_hyperthreading_facts
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_check_mode
check_mode: yes
- debug: var=host_hyperthreading_facts_check_mode - assert:
that:
- host_hyperthreading_facts is defined
- host_hyperthreading_facts is changed
- assert: - name: Enable Hyperthreading for all hosts in given cluster in check mode
that: vmware_host_hyperthreading:
- host_hyperthreading_facts_check_mode is defined hostname: "{{ vcenter_hostname }}"
- host_hyperthreading_facts_check_mode.changed 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

View file

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

View file

@ -1,118 +1,81 @@
# Test code for the vmware_host_ipv6 module. # Test code for the vmware_host_ipv6 module.
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de> # Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- when: vcsim is not defined
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Wait for Flask controller to come up online - name: Ensure IPv6 is off
wait_for: vmware_host_ipv6:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 5000 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: disabled
register: host_ipv6_facts
- name: kill vcsim - name: Enable IPv6 support for a given host
uri: vmware_host_ipv6:
url: http://{{ vcsim }}:5000/killall hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no
state: enabled
register: host_ipv6_facts
- debug: var=host_ipv6_facts
- assert:
that:
- host_ipv6_facts is defined
- host_ipv6_facts.changed
- name: start vcsim - name: Enable IPv6 support for a given host in check mode
uri: vmware_host_ipv6:
url: http://{{ vcsim }}:5000/spawn?cluster=2 hostname: "{{ vcenter_hostname }}"
register: vcsim_instance username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no
state: enabled
register: host_ipv6_facts_check_mode
check_mode: yes
- debug: var=host_ipv6_facts_check_mode
- assert:
that:
- host_ipv6_facts_check_mode is defined
- not (host_ipv6_facts_check_mode is changed)
- debug: - name: Enable IPv6 support for all hosts in given cluster
var: vcsim_instance vmware_host_ipv6:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: enabled
register: hosts_ipv6_facts
- debug: var=hosts_ipv6_facts
- assert:
that:
- hosts_ipv6_facts is defined
- hosts_ipv6_facts.changed
- name: Wait for vcsim server to come up online - name: Enable IPv6 support for all hosts in given cluster in check mode
wait_for: vmware_host_ipv6:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 443 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
- name: get a list of clusters from vcsim validate_certs: no
uri: state: enabled
url: http://{{ vcsim }}:5000/govc_find?filter=CCR register: hosts_ipv6_facts_check_mode
register: clusters check_mode: yes
- debug: var=hosts_ipv6_facts_check_mode
- name: get a cluster - assert:
set_fact: that:
ccr1: "{{ clusters.json[0] | basename }}" - hosts_ipv6_facts_check_mode is defined
- not (hosts_ipv6_facts_check_mode is changed)
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1
- debug: var=host1
- name: Enable IPv6 support for a given host
vmware_host_ipv6:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
state: enabled
register: host_ipv6_facts
- debug: var=host_ipv6_facts
- assert:
that:
- host_ipv6_facts is defined
- host_ipv6_facts.changed
- name: Enable IPv6 support for a given host in check mode
vmware_host_ipv6:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
state: enabled
register: host_ipv6_facts_check_mode
check_mode: yes
- debug: var=host_ipv6_facts_check_mode
- assert:
that:
- host_ipv6_facts_check_mode is defined
- host_ipv6_facts_check_mode.changed
- name: Enable IPv6 support for all hosts in given cluster
vmware_host_ipv6:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: enabled
register: hosts_ipv6_facts
- debug: var=hosts_ipv6_facts
- assert:
that:
- hosts_ipv6_facts is defined
- hosts_ipv6_facts.changed
- name: Enable IPv6 support for all hosts in given cluster in check mode
vmware_host_ipv6:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
cluster_name: "{{ ccr1 }}"
validate_certs: no
state: enabled
register: hosts_ipv6_facts_check_mode
check_mode: yes
- debug: var=hosts_ipv6_facts_check_mode
- assert:
that:
- hosts_ipv6_facts_check_mode is defined
- hosts_ipv6_facts_check_mode.changed

View file

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

View file

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

View file

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

View file

@ -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
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Wait for Flask controller to come up online - name: Add NTP server to a host
wait_for: vmware_host_ntp:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 5000 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present
ntp_servers:
- 0.pool.ntp.org
validate_certs: no
register: present
- debug: var=present
- name: kill vcsim - name: Add another NTP server to a host
uri: vmware_host_ntp:
url: http://{{ vcsim }}:5000/killall hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present
ntp_servers:
- 1.pool.ntp.org
validate_certs: no
register: present
- debug: var=present
- name: start vcsim - name: Remove NTP server from a host
uri: vmware_host_ntp:
url: http://{{ vcsim }}:5000/spawn?cluster=2 hostname: "{{ vcenter_hostname }}"
register: vcsim_instance username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: absent
ntp_servers:
- 1.pool.ntp.org
validate_certs: no
register: absent_one
- debug: var=absent_one
- debug: - name: Remove NTP server from a host
var: vcsim_instance vmware_host_ntp:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present
ntp_servers:
- 1.pool.ntp.org
validate_certs: no
register: present
- debug: var=present
- name: Wait for vcsim server to come up online - name: Add more NTP servers to a host
wait_for: vmware_host_ntp:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 443 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present
ntp_servers:
- 2.pool.ntp.org
- 3.pool.ntp.org
- 4.pool.ntp.org
validate_certs: no
register: present
- debug: var=present
- name: get a list of Cluster from vcsim - name: Remove all NTP servers from a host
uri: vmware_host_ntp:
url: http://{{ vcsim }}:5000/govc_find?filter=CCR hostname: "{{ vcenter_hostname }}"
register: clusters username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: absent
ntp_servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
- 3.pool.ntp.org
- 4.pool.ntp.org
- 6.pool.ntp.org
validate_certs: no
register: absent_all
- debug: var=absent_all
- name: get a cluster - name: Configure NTP servers for a host
set_fact: vmware_host_ntp:
ccr1: "{{ clusters.json[0] | basename }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ntp_servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
validate_certs: no
register: ntp_servers
- debug: var=ntp_servers
- name: get a list of hosts from vcsim - name: Configure NTP servers for a host
uri: vmware_host_ntp:
url: http://{{ vcsim }}:5000/govc_find?filter=H hostname: "{{ vcenter_hostname }}"
register: hosts username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
ntp_servers:
- 3.pool.ntp.org
- 4.pool.ntp.org
- 5.pool.ntp.org
verbose: true
validate_certs: no
register: ntp_servers
- debug: var=ntp_servers
- name: get a host - name: Add NTP server to a host in check mode
set_fact: vmware_host_ntp:
host1: "{{ hosts.json[0] | basename }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present
ntp_servers:
- 0.pool.ntp.org
validate_certs: no
register: present
check_mode: yes
- debug: var=present
- debug: var=ccr1 - name: Remove NTP server to a host in check mode
- debug: var=host1 vmware_host_ntp:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: absent
ntp_servers:
- 0.pool.ntp.org
validate_certs: no
register: present
check_mode: yes
- debug: var=present
- name: Add NTP server to a host - name: Configure NTP servers for a host in check mode
vmware_host_ntp: vmware_host_ntp:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
state: present ntp_servers:
ntp_server: - 0.pool.ntp.org
- 0.pool.ntp.org - 1.pool.ntp.org
validate_certs: no - 2.pool.ntp.org
register: present validate_certs: no
register: ntp_servers
- debug: var=present check_mode: yes
- debug: var=ntp_servers
- name: Add another NTP server to a host
vmware_host_ntp:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
esxi_hostname: "{{ host1 }}"
state: present
ntp_server:
- 1.pool.ntp.org
validate_certs: no
register: present
- debug: var=present
- name: Remove NTP server from a host
vmware_host_ntp:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
esxi_hostname: "{{ host1 }}"
state: absent
ntp_server:
- 1.pool.ntp.org
validate_certs: no
register: absent_one
- debug: var=absent_one
- name: Remove NTP server from a host
vmware_host_ntp:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
esxi_hostname: "{{ host1 }}"
state: present
ntp_server:
- 1.pool.ntp.org
validate_certs: no
register: present
- debug: var=present
- name: Add more NTP servers to a host
vmware_host_ntp:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
esxi_hostname: "{{ host1 }}"
state: present
ntp_server:
- 2.pool.ntp.org
- 3.pool.ntp.org
- 4.pool.ntp.org
validate_certs: no
register: present
- debug: var=present
- name: Remove all NTP servers from a host
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
- 1.pool.ntp.org
- 2.pool.ntp.org
- 3.pool.ntp.org
- 4.pool.ntp.org
- 6.pool.ntp.org
validate_certs: no
register: absent_all
- debug: var=absent_all
- name: Configure NTP servers for a host
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
- debug: var=ntp_servers
- name: Configure NTP servers for a host
vmware_host_ntp:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
esxi_hostname: "{{ host1 }}"
ntp_server:
- 3.pool.ntp.org
- 4.pool.ntp.org
- 5.pool.ntp.org
verbose: true
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

View file

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

View file

@ -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
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Wait for Flask controller to come up online - name: Gather NTP facts about all hosts in given host
wait_for: vmware_host_ntp_facts:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 5000 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
- name: kill vcsim validate_certs: no
uri: register: host_ntp
url: http://{{ vcsim }}:5000/killall - debug: var=host_ntp
- assert:
- name: start vcsim that:
uri: - host_ntp.hosts_ntp_facts is defined
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- debug:
var: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: Gather NTP facts about all hosts in given host
vmware_host_ntp_facts:
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

View file

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

View file

@ -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
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Wait for Flask controller to come up online - name: Gather facts about all hosts in given cluster
wait_for: vmware_host_package_facts:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 5000 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
- name: kill vcsim validate_certs: no
uri: register: host_packages
url: http://{{ vcsim }}:5000/killall - debug: var=host_packages
- assert:
- name: start vcsim that:
uri: - host_packages.hosts_package_facts is defined
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- debug:
var: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: Gather facts about all hosts in given cluster
vmware_host_package_facts:
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

View file

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

View file

@ -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 # The following test cases aren't supported by vcsim
uri: - name: Set the Power Management Policy for esxi1
url: http://{{ vcsim }}:5000/killall vmware_host_powermgmt_policy:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
policy: high-performance
validate_certs: no
register: host_result
- debug: var=host_result
- name: Ensure Power Management Policy for esxi1
assert:
that:
- host_result.result['{{ hostvars[esxi1].ansible_host }}'].current_state == "high-performance"
- name: Start vcsim - name: Set the Power Management Policy on all hosts of {{ ccr1 }}
uri: vmware_host_powermgmt_policy:
url: http://{{ vcsim }}:5000/spawn?cluster=2 hostname: "{{ vcenter_hostname }}"
register: vcsim_instance username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
policy: balanced
validate_certs: no
register: all_hosts_result
- debug: var=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
- debug: - name: Set the Power Management Policy for esxi1 in check mode
var: vcsim_instance vmware_host_powermgmt_policy:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
policy: high-performance
validate_certs: no
register: host_result
check_mode: yes
- debug: var=host_result
- name: Ensure Power Management Policy for esxi1 in check mode
assert:
that:
- host_result is changed
- host_result.result is defined
- name: Wait for vcsim server to come up online - name: Set the Power Management Policy on all hosts of {{ ccr1 }}
wait_for: vmware_host_powermgmt_policy:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 443 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
cluster_name: "{{ ccr1 }}"
- name: Get a list of Cluster from vcsim policy: balanced
uri: validate_certs: no
url: http://{{ vcsim }}:5000/govc_find?filter=CCR register: all_hosts_result
register: clusters check_mode: yes
- debug: var=all_hosts_result
- name: Get a cluster - name: Ensure we are still using the 'balanced' mode
set_fact: assert:
ccr1: "{{ clusters.json[0] | basename }}" that:
- not (all_hosts_result is changed)
- name: Get a list of hosts from vcsim - "all_hosts_result.result['{{ hostvars[esxi1].ansible_host }}']current_state == 'balanced'"
uri: - "all_hosts_result.result['{{ hostvars[esxi2].ansible_host }}']current_state == 'balanced'"
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: Get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=ccr1
- debug: var=host1
# The following test cases aren't supported by vcsim
- name: Set the Power Management Policy for {{ host1 }}
vmware_host_powermgmt_policy:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
esxi_hostname: "{{ host1 }}"
policy: high-performance
validate_certs: no
register: host_result
- debug: msg="{{ host_result }}"
- name: Ensure Power Management Policy for {{ host1 }}
assert:
that:
- host_result is changed
- host_result.result is defined
- name: Set the Power Management Policy on all hosts of {{ ccr1 }}
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
- 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

View file

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

View file

@ -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
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim # https://kb.vmware.com/s/article/2001651?lang=en_US
uri: # It seems like we need a Power managment interface to be able to run the
url: http://{{ vcsim }}:5000/killall # module.
# I currently get:
# "Failed to power down '192.168.123.7' to standby as host system due to : ('The operation is not supported on the object.', None)"
- name: Restart Host
vmware_host_powerstate:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: False
state: power-down-to-standby
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
force: True
register: host_powerstate
- name: start vcsim - debug: var=host_powerstate
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- debug: - assert:
var: vcsim_instance that:
- host_powerstate.results is changed
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: Restart Host
vmware_host_powerstate:
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

View file

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

View file

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

View file

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

View file

@ -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
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Wait for Flask controller to come up online - &host_srv_facts
wait_for: name: Check facts about all hosts in given cluster
host: "{{ vcsim }}" vmware_host_service_facts:
port: 5000 hostname: "{{ vcenter_hostname }}"
state: started username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no
register: host_services
- name: kill vcsim - debug:
uri: var: host_services
url: http://{{ vcsim }}:5000/killall
- name: start vcsim - assert:
uri: that:
url: http://{{ vcsim }}:5000/spawn?cluster=2 - host_services.host_service_facts is defined
register: vcsim_instance
- debug: - <<: *host_srv_facts
var: vcsim_instance name: Check facts about all hosts in given cluster in check mode
check_mode: yes
- name: Wait for vcsim server to come up online - debug:
wait_for: var: host_services
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of hosts from vcsim - assert:
uri: that:
url: http://{{ vcsim }}:5000/govc_find?filter=H - host_services.host_service_facts is defined
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: Change facts about all hosts in given cluster
vmware_host_service_facts:
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

View file

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

View file

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

View file

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

View file

@ -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 # SNMP works only with standalone ESXi server
uri: - name: Enable and configure SNMP community in check mode
url: http://{{ vcsim }}:5000/killall vmware_host_snmp:
hostname: '{{ hostvars[esxi1].ansible_host }}'
username: '{{ hostvars[esxi1].ansible_user }}'
password: '{{ hostvars[esxi1].ansible_password }}'
community: [ test ]
state: enabled
validate_certs: no
register: snmp_enabled_check_mode
check_mode: yes
- debug: var=snmp_enabled_check_mode
- assert:
that:
- snmp_enabled_check_mode is defined
- snmp_enabled_check_mode.changed
# SNMP works only with standalone ESXi server - name: Enable and configure SNMP community
- name: start vcsim vmware_host_snmp:
uri: hostname: '{{ hostvars[esxi1].ansible_host }}'
url: http://{{ vcsim }}:5000/spawn?esx=1 username: '{{ hostvars[esxi1].ansible_user }}'
register: vcsim_instance password: '{{ hostvars[esxi1].ansible_password }}'
community: [ test ]
state: enabled
validate_certs: no
register: snmp_enabled
- debug: var=snmp_enabled
- assert:
that:
- snmp_enabled is defined
- snmp_enabled.changed
- debug: - name: Disable SNMP
var: vcsim_instance vmware_host_snmp:
hostname: '{{ hostvars[esxi1].ansible_host }}'
- name: Wait for vcsim server to come up online username: '{{ hostvars[esxi1].ansible_user }}'
wait_for: password: '{{ hostvars[esxi1].ansible_password }}'
host: "{{ vcsim }}" state: disabled
port: 443 validate_certs: no
state: started register: snmp_disabled
- debug: var=snmp_enabled
- name: Enable and configure SNMP community in check mode - assert:
vmware_host_snmp: that:
hostname: "{{ vcsim }}" - snmp_enabled is defined
username: "{{ vcsim_instance.json.username }}" - snmp_enabled.changed
password: "{{ vcsim_instance.json.password }}"
community: [ test ]
state: enabled
validate_certs: no
register: snmp_enabled_check_mode
check_mode: yes
- debug: var=snmp_enabled_check_mode
- assert:
that:
- snmp_enabled_check_mode is defined
- snmp_enabled_check_mode.changed
- name: Enable and configure SNMP community
vmware_host_snmp:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
community: [ test ]
state: enabled
validate_certs: no
register: snmp_enabled
check_mode: yes
- debug: var=snmp_enabled
- assert:
that:
- snmp_enabled is defined
- snmp_enabled.changed

View file

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

View file

@ -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

View file

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

View file

@ -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
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Wait for Flask controller to come up online - &vmhba_data
wait_for: name: Gather vmhba facts
host: "{{ vcsim }}" vmware_host_vmhba_facts:
port: 5000 hostname: "{{ vcenter_hostname }}"
state: started username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no
register: host_vmhbas
- name: kill vcsim - debug:
uri: var: host_vmhbas
url: http://{{ vcsim }}:5000/killall
- name: start vcsim - assert:
uri: that:
url: http://{{ vcsim }}:5000/spawn?cluster=2 - host_vmhbas.hosts_vmhbas_facts is defined
register: vcsim_instance
- debug: - <<: *vmhba_data
var: vcsim_instance name: Gather vmhba facts in check mode
check_mode: yes
- name: Wait for vcsim server to come up online - debug:
wait_for: var: host_vmhbas
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of hosts from vcsim - assert:
uri: that:
url: http://{{ vcsim }}:5000/govc_find?filter=H - host_vmhbas.hosts_vmhbas_facts is defined
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- 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

View file

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

View file

@ -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
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- name: Wait for Flask controller to come up online - name: Gather vmnic facts about a host
wait_for: vmware_host_vmnic_facts:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 5000 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no
register: host_vmnics
- debug: var=host_vmnics
- assert:
that:
- host_vmnics.hosts_vmnics_facts is defined
- name: kill vcsim - name: Gather extended 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 capabilities: true
directpath_io: true
- debug: sriov: true
var: vcsim_instance register: host_vmnics_extended
- debug: var=host_vmnics_extended
- name: Wait for vcsim server to come up online - assert:
wait_for: that:
host: "{{ vcsim }}" - host_vmnics_extended.hosts_vmnics_facts is defined
port: 443
state: started
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: Gather vmnic facts about a host
vmware_host_vmnics_facts:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
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