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

vmware: refactoring of vmware test roles -- part7 (#55732)

Refactoring of the following roles to make use of the new
`prepare_vmware_tests` role.

- `vmware_resource_pool`
- `vmware_resource_pool_facts`
- `vmware_target_canonical_facts`
- `vmware_vcenter_settings`
- `vmware_vcenter_statistics`
- `vmware_vm_facts`
- `vmware_vm_host_drs_rule`
- `vmware_vm_vm_drs_rule`
- `vmware_vmkernel`
- `vmware_vmkernel_facts`
- `vmware_vspan_session`
- `vmware_vswitch`
- `vmware_vswitch_facts`

This patch depends on: https://github.com/ansible/ansible/pull/55719

Original PR: https://github.com/ansible/ansible/pull/54882
This commit is contained in:
Gonéri Le Bouder 2019-05-02 23:19:02 -04:00 committed by ansibot
parent 2ef8b297ff
commit affaedfca8
22 changed files with 464 additions and 786 deletions

View file

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

View file

@ -3,57 +3,17 @@
# 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 SCSI target releated operations # TODO: vcsim does not support SCSI target releated operations
- 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 }}"
- 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 target facts for all ESXi host from given cluster - name: Gather target facts for all ESXi host from given cluster
vmware_target_canonical_facts: vmware_target_canonical_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: False validate_certs: False
cluster_name: "{{ ccr1 }}" cluster_name: "{{ ccr1 }}"
register: target_0001_results register: target_0001_results
@ -65,11 +25,11 @@
- name: Gather target facts for ESXi host - name: Gather target facts for ESXi host
vmware_target_canonical_facts: vmware_target_canonical_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: False validate_certs: False
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
register: target_0002_results register: target_0002_results
- assert: - assert:

View file

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

View file

@ -2,44 +2,14 @@
# 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 - import_role:
wait_for: name: prepare_vmware_tests
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 datacenter
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- name: get a datacenter
set_fact:
dc1: "{{ datacenters.json[0] | basename }}"
- name: Configure general settings in check mode - name: Configure general settings in check mode
vmware_vcenter_settings: vmware_vcenter_settings:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
database: database:
max_connections: 50 max_connections: 50
task_cleanup: true task_cleanup: true
@ -72,18 +42,13 @@
register: all_settings_results_check_mode register: all_settings_results_check_mode
check_mode: yes check_mode: yes
- debug: msg="{{ all_settings_results_check_mode }}" - debug: var=all_settings_results_check_mode
- name: ensure general settings were configured
assert:
that:
- all_settings_results_check_mode.changed
- name: Configure general settings - name: Configure general settings
vmware_vcenter_settings: vmware_vcenter_settings:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
database: database:
max_connections: 50 max_connections: 50
task_cleanup: true task_cleanup: true
@ -115,4 +80,4 @@
validate_certs: no validate_certs: no
register: all_settings_results register: all_settings_results
- debug: msg="{{ all_settings_results }}" - debug: var=all_settings_results

View file

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

View file

@ -2,44 +2,30 @@
# 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 - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim - name: Disable all the statistics
uri: vmware_vcenter_statistics:
url: http://{{ vcsim }}:5000/killall hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: start vcsim password: "{{ vcenter_password }}"
uri: interval_past_day:
url: http://{{ vcsim }}:5000/spawn?cluster=2 enabled: false
register: vcsim_instance interval_past_week:
enabled: false
- debug: interval_past_month:
var: vcsim_instance enabled: false
interval_past_year:
- name: Wait for vcsim server to come up online enabled: false
wait_for: validate_certs: no
host: "{{ vcsim }}" register: statistics_results_check_mode
port: 443
state: started
- name: get datacenter
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- name: get a datacenter
set_fact:
dc1: "{{ datacenters.json[0] | basename }}"
- name: Configure statistics in check mode - name: Configure statistics in check mode
vmware_vcenter_statistics: vmware_vcenter_statistics: &stats
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
interval_past_day: interval_past_day:
enabled: true enabled: true
interval_minutes: 5 interval_minutes: 5
@ -64,46 +50,37 @@
register: statistics_results_check_mode register: statistics_results_check_mode
check_mode: yes check_mode: yes
- debug: msg="{{ statistics_results_check_mode }}" - debug: var=statistics_results_check_mode
- name: ensure statistics were configured - name: ensure statistics were configured
assert: assert:
that: that:
# Doesn't really work with vcsim. No matter which settings are used; they are always shown as already configured!? # Doesn't really work with vcsim. No matter which settings are used; they are always shown as already configured!?
- statistics_results_check_mode.changed == False - statistics_results_check_mode is changed
when: vcsim is not defined
- name: Configure statistics - name: Configure statistics
vmware_vcenter_statistics: vmware_vcenter_statistics:
hostname: "{{ vcsim }}" <<: *stats
username: "{{ vcsim_instance.json.username }}"
password: "{{ vcsim_instance.json.password }}"
interval_past_day:
enabled: true
interval_minutes: 5
save_for_days: 3
level: 2
interval_past_week:
enabled: true
interval_minutes: 30
save_for_weeks: 1
level: 2
interval_past_month:
enabled: true
interval_hours: 2
save_for_months: 1
level: 1
interval_past_year:
enabled: true
interval_days: 1
save_for_years: 1
level: 1
validate_certs: no
register: statistics_results register: statistics_results
- debug: msg="{{ statistics_results }}" - debug: var=statistics_results
- name: ensure statistics were configured - name: ensure statistics were configured
assert: assert:
that: that:
# Doesn't really work with vcsim. No matter which settings are used; they are always shown as already configured!? - statistics_results is changed
- statistics_results.changed == False when: vcsim is not defined
- name: Configure statistics (again)
vmware_vcenter_statistics:
<<: *stats
register: statistics_results
- debug: var=statistics_results
- name: ensure statistics were configured
assert:
that:
- not (statistics_results is changed)
when: vcsim is not defined

View file

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

View file

@ -3,37 +3,24 @@
# Copyright, (c) 2018, Fedor Vompe <f.vompe@comptek.ru> # Copyright, (c) 2018, Fedor Vompe <f.vompe@comptek.ru>
# 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 - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}" vars:
port: 5000 setup_attach_host: true
state: started setup_datastore: true
setup_virtualmachines: true
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- debug: var=vcsim_instance
- name: Get facts about available vms - name: Get facts about available vms
vmware_vm_facts: vmware_vm_facts:
validate_certs: false validate_certs: false
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
register: vm_facts_0001 register: vm_facts_0001
- debug: var=vm_facts_0001
- name: Verify if VM facts exist - name: Verify if VM facts exist
assert: assert:
that: that:
@ -53,9 +40,9 @@
- name: Get facts about available vms in check mode - name: Get facts about available vms in check mode
vmware_vm_facts: vmware_vm_facts:
validate_certs: false validate_certs: false
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
register: vm_facts_0001 register: vm_facts_0001
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

@ -2,73 +2,81 @@
# Copyright: (c) 2017, Karsten Kaj Jakobsen <kj@patientsky.com> # Copyright: (c) 2017, Karsten Kaj Jakobsen <kj@patientsky.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 manage DRS rule - when: vcsim is not defined
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
- name: Create DRS VM group
vmware_drs_group:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: False
# Options
cluster_name: '{{ ccr1 }}'
datacenter_name: '{{ dc1 }}'
group_name: DC0_C0_VM_GR1
vms: '{{ infra.vm_list }}'
state: present
register: drs_vm_group_01_results
- debug: var=drs_vm_group_01_results
- name: Wait for flask server - name: Create DRS Host group
wait_for: vmware_drs_group:
host: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
port: 5000 username: "{{ vcenter_username }}"
state: started password: "{{ vcenter_password }}"
validate_certs: False
# Options
cluster_name: '{{ ccr1 }}'
datacenter_name: '{{ dc1 }}'
group_name: DC0_C0_HOST_GR1
hosts:
- '{{ hostvars[esxi1].ansible_host }}'
- '{{ hostvars[esxi2].ansible_host }}'
state: present
register: drs_host_group_01_results
- debug: var=drs_host_group_01_results
- name: Kill vcsim - name: Create mandatory DRS Affinity rule for VM/Host
uri: vmware_vm_host_drs_rule:
url: http://{{ vcsim }}:5000/killall validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
drs_rule_name: drs_rule_host_aff_0001
vm_group_name: DC0_C0_VM_GR1
host_group_name: DC0_C0_HOST_GR1
cluster_name: "{{ ccr1 }}"
enabled: True
affinity_rule: True
mandatory: True
register: drs_rule_host_0001_results
- debug: var=drs_rule_host_0001_results
- assert:
that:
- "{{ drs_rule_host_0001_results.changed }}"
- name: Start vcsim # TODO: create host/vm group when vcsim supports this
uri: - name: Create non-mandatory DRS Anti-Affinity rule for VM/Host
url: http://{{ vcsim }}:5000/spawn?datacenter=2&cluster=1&folder=0&ds=2&pool=2 vmware_vm_host_drs_rule:
register: vcsim_instance validate_certs: False
hostname: "{{ vcenter_hostname }}"
- name: Wait for vcsim server username: "{{ vcenter_username }}"
wait_for: password: "{{ vcenter_password }}"
host: "{{ vcsim }}" drs_rule_name: drs_rule_host_aff_0001
port: 443 vm_group_name: DC0_C0_VM_GR1
state: started host_group_name: DC0_C0_HOST_GR1
cluster_name: "{{ ccr1 }}"
- debug: var=vcsim_instance enabled: True
affinity_rule: False
# TODO: create host/vm group when vcsim supports this mandatory: False
register: drs_rule_host_0002_results
- name: Create mandatory DRS Affinity rule for VM/Host - debug: var=drs_rule_host_0002_results
vmware_vm_host_drs_rule: - assert:
validate_certs: False that:
hostname: "{{ vcsim }}" - "{{ drs_rule_host_0001_results.changed }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
drs_rule_name: drs_rule_host_aff_0001
vm_group_name: DC0_C0_VM_GR1
host_group_name: DC0_C0_HOST_GR1
cluster_name: DC0_C0
enabled: True
affinity_rule: True
mandatory: True
register: drs_rule_host_0001_results
- debug: var=drs_rule_host_0001_results
- assert:
that:
- "{{ drs_rule_host_0001_results.changed }}"
# TODO: create host/vm group when vcsim supports this
- name: Create non-mandatory DRS Anti-Affinity rule for VM/Host
vmware_vm_host_drs_rule:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
drs_rule_name: drs_rule_host_aff_0001
vm_group_name: DC0_C0_VM_GR1
host_group_name: DC0_C0_HOST_GR2
cluster_name: DC0_C0
enabled: True
affinity_rule: False
mandatory: False
register: drs_rule_host_0002_results
- debug: var=drs_rule_host_0002_results
- assert:
that:
- "{{ drs_rule_host_0001_results.changed }}"

View file

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

View file

@ -3,70 +3,46 @@
# 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 manage DRS rule # TODO: vcsim does not support manage DRS rule
- when: vcsim is not defined
block:
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
- name: Create a DRS Affinity rule for vms
vmware_vm_vm_drs_rule:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
drs_rule_name: drs_rule_0001
cluster_name: "{{ ccr1 }}"
vms: "{{ infra.vm_list }}"
enabled: True
affinity_rule: True
mandatory: True
register: drs_rule_0001_results
- debug: var=drs_rule_0001_results
- assert:
that:
- "{{ drs_rule_0001_results.changed }}"
- name: wait for flask server - name: Create a DRS Anti-Affinity rule for vms
wait_for: vmware_vm_vm_drs_rule:
host: "{{ vcsim }}" validate_certs: False
port: 5000 hostname: "{{ vcenter_hostname }}"
state: started username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
- name: kill vcsim drs_rule_name: drs_rule_0001
uri: cluster_name: "{{ ccr1 }}"
url: http://{{ vcsim }}:5000/killall vms: "{{ infra.vm_list }}"
enabled: False
- name: start vcsim affinity_rule: False
uri: mandatory: False
url: http://{{ vcsim }}:5000/spawn?datacenter=2&cluster=1&folder=0&ds=2&pool=2 register: drs_rule_0002_results
register: vcsim_instance - debug: var=drs_rule_0002_results
- assert:
- name: wait for vcsim server that:
wait_for: - "{{ drs_rule_0002_results.changed }}"
host: "{{ vcsim }}"
port: 443
state: started
- debug: var=vcsim_instance
- name: Create a DRS Affinity rule for vms
vmware_vm_vm_drs_rule:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
drs_rule_name: drs_rule_0001
cluster_name: DC0_C0
vms:
- DC0_C0_RP0_VM0
- DC0_C0_RP0_VM1
enabled: True
affinity_rule: True
mandatory: True
register: drs_rule_0001_results
- debug: var=drs_rule_0001_results
- assert:
that:
- "{{ drs_rule_0001_results.changed }}"
- name: Create a DRS Anti-Affinity rule for vms
vmware_vm_vm_drs_rule:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
drs_rule_name: drs_rule_0001
cluster_name: DC0_C0
vms:
- DC0_C0_RP0_VM0
- DC0_C0_RP0_VM1
enabled: False
affinity_rule: False
mandatory: False
register: drs_rule_0002_results
- debug: var=drs_rule_0002_results
- assert:
that:
- "{{ drs_rule_0002_results.changed }}"

View file

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

View file

@ -1,138 +1,65 @@
# Test code for the vmware_vmkernel module. # Test code for the vmware_vmkernel 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:
# TODO: vcsim does not support HostVirtualNicManager-related operations # TODO: vcsim does not support HostVirtualNicManager-related operations
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_switch: true
- name: Wait for Flask controller to come up online - name: create basic portgroup
wait_for: vmware_portgroup:
host: "{{ vcsim }}" validate_certs: False
port: 5000 hostname: "{{ vcenter_hostname }}"
state: started username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
switch_name: "{{ switch1 }}"
cluster_name: "{{ ccr1 }}"
portgroup_name: vMotion
vlan_id: 0
state: present
register: dvs_pg_result_0001
- name: kill vcsim - debug: var=dvs_pg_result_0001
uri: - name: Create VMkernel adapter with vMotion TCP/IP stack
url: http://{{ vcsim }}:5000/killall vmware_vmkernel: &new_vmkernel
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
vswitch: "{{ switch1 }}"
portgroup: vMotion
mtu: 9000
network:
type: static
ip_address: 192.168.100.100
subnet_mask: 255.255.255.0
tcpip_stack: vmotion
state: present
validate_certs: no
register: host_vmkernel
- debug: var=host_vmkernel
- name: start vcsim - name: Create VMkernel adapter in check mode
uri: vmware_vmkernel:
url: http://{{ vcsim }}:5000/spawn?cluster=2 <<: *new_vmkernel
register: vcsim_instance register: host_vmkernel
check_mode: yes
- debug: var=host_vmkernel
- debug: - name: Delete VMkernel adapter
var: vcsim_instance vmware_vmkernel:
hostname: "{{ vcenter_hostname }}"
- name: Wait for vcsim server to come up online username: "{{ vcenter_username }}"
wait_for: password: "{{ vcenter_password }}"
host: "{{ vcsim }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
port: 443 vswitch: "{{ switch1 }}"
state: started device: '{{ host_vmkernel.device }}'
portgroup: vMotion
- name: get a list of hosts from vcsim state: absent
uri: validate_certs: no
url: http://{{ vcsim }}:5000/govc_find?filter=H register: host_vmkernel
register: hosts - debug: var=host_vmkernel
- name: get a host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: Create VMkernel adapter
vmware_vmkernel:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
vswitch: vSwitch1
portgroup: vMotion
mtu: 1500
enable_vmotion: True
state: present
validate_certs: no
register: host_vmkernel
- debug: var=host_vmkernel
- name: Create VMkernel adapter in check mode
vmware_vmkernel:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
vswitch: vSwitch1
portgroup: vMotion
mtu: 1500
enable_vmotion: True
state: present
validate_certs: no
register: host_vmkernel
check_mode: yes
- debug: var=host_vmkernel
- name: Delete VMkernel adapter
vmware_vmkernel:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
vswitch: vSwitch1
portgroup: vMotion
state: absent
validate_certs: no
register: host_vmkernel
- debug: var=host_vmkernel
- name: Create VMkernel adapter with vMotion TCP/IP stack
vmware_vmkernel:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
vswitch: vSwitch1
portgroup: vMotion
mtu: 9000
network:
type: static
ip_address: 192.168.100.100
subnet_mask: 255.255.255.0
tcpip_stack: vmotion
state: present
validate_certs: no
register: host_vmkernel
- debug: var=host_vmkernel
- name: Delete VMkernel adapter
vmware_vmkernel:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
vswitch: vSwitch1
portgroup: vMotion
state: absent
validate_certs: no
register: host_vmkernel
- debug: var=host_vmkernel
- name: Create VMkernel adapter with DHCP
vmware_vmkernel:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
vswitch: vSwitch1
portgroup: vMotion
mtu: 9000
network:
type: dhcp
state: present
validate_certs: no
register: host_vmkernel
- debug: var=host_vmkernel

View file

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

View file

@ -3,69 +3,36 @@
# 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 HostVirtualNicManager related to operations # TODO: vcsim does not support HostVirtualNicManager 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 VMkernel facts for a given host
wait_for: vmware_vmkernel_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_vmkernel
- debug: var=host_vmkernel
- assert:
that:
- host_vmkernel.host_vmk_facts is defined
- name: kill vcsim - name: Gather VMkernel facts for a given host in check mode
uri: vmware_vmkernel_facts:
url: http://{{ vcsim }}:5000/killall hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: start vcsim password: "{{ vcenter_password }}"
uri: esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
url: http://{{ vcsim }}:5000/spawn?cluster=2 validate_certs: no
register: vcsim_instance register: host_vmkernel_check_mode
check_mode: yes
- debug: - debug: var=host_vmkernel
var: vcsim_instance - assert:
that:
- name: Wait for vcsim server to come up online - host_vmkernel_check_mode.host_vmk_facts is defined
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 VMkernel facts about all hosts in given cluster
vmware_vmkernel_facts:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
register: host_vmkernel
- debug: var=host_vmkernel
- assert:
that:
- host_vmkernel.host_vmk_facts is defined
- name: Gather VMkernel facts about all hosts in given cluster in check mode
vmware_vmkernel_facts:
hostname: "{{ vcsim }}"
username: "{{ user }}"
password: "{{ passwd }}"
esxi_hostname: "{{ host1 }}"
validate_certs: no
register: host_vmkernel_check_mode
check_mode: yes
- debug: var=host_vmkernel
- assert:
that:
- host_vmkernel_check_mode.host_vmk_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,42 +2,19 @@
# Copyright: (c) 2018, Peter Gyorgy <gyorgy.peter@edu.bme.hu> # Copyright: (c) 2018, Peter Gyorgy <gyorgy.peter@edu.bme.hu>
# 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 - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}" vars:
port: 5000 setup_attach_host: 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
- 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
- debug: var=vcsim_instance
- debug: var=datacenters
- name: add distributed vSwitch - name: add distributed vSwitch
vmware_dvswitch: vmware_dvswitch:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter_name: "{{ item | basename }}" datacenter_name: "{{ dc1 }}"
state: present state: present
switch_name: dvswitch_0001 switch_name: dvswitch_0001
mtu: 9000 mtu: 9000
@ -45,35 +22,17 @@
discovery_proto: lldp discovery_proto: lldp
discovery_operation: both discovery_operation: both
register: dvs_result_0001 register: dvs_result_0001
with_items: - debug: var=dvs_result_0001
- "{{ datacenters['json'] }}"
- name: ensure distributed vswitch is present - name: ensure distributed vswitch is present
assert: assert:
that: that:
- "{{ dvs_result_0001.changed == true }}" - "{{ dvs_result_0001.changed == true }}"
- name: get a list of distributed vswitch from vcsim after adding
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DVS
register: new_dvs_0001
- debug:
msg: "{{ item | basename }}"
with_items: "{{ new_dvs_0001['json'] }}"
- set_fact: new_dvs_name="{% for dvs in new_dvs_0001['json'] %} {{ True if (dvs | basename) == 'dvswitch_0001' else False }}{% endfor %}"
- debug: var=new_dvs_name
- assert:
that:
- "{{ 'True' in new_dvs_name }}"
- name: Create vlan portgroup with all security and port policies - name: Create vlan portgroup with all security and port policies
vmware_dvs_portgroup: vmware_dvs_portgroup:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
validate_certs: False validate_certs: False
portgroup_name: vlan-123-portrgoup portgroup_name: vlan-123-portrgoup
switch_name: dvswitch_0001 switch_name: dvswitch_0001
@ -104,39 +63,40 @@
that: that:
- portgroup_create_result.changed - portgroup_create_result.changed
- name: create a session. - when: vcsim is not defined
vmware_vspan_session: block:
hostname: "{{ vcsim }}" - name: create a session.
username: "{{ vcsim_instance['json']['username'] }}" vmware_vspan_session:
password: "{{ vcsim_instance['json']['password'] }}" hostname: "{{ vcenter_hostname }}"
validate_certs: False username: "{{ vcenter_username }}"
switch: dvswitch_0001 password: "{{ vcenter_password }}"
name: "session_0001" validate_certs: False
state: "present" switch: dvswitch_0001
enabled: True name: "session_0001"
description: "basic_description" state: "present"
source_port_transmitted: 13 enabled: True
source_port_received: 13 description: "basic_description"
destination_port: 12 source_port_transmitted: 13
register: vspan_session_create_result source_port_received: 13
destination_port: 12
register: vspan_session_create_result
- debug: var=vspan_session_create_result
- name: ensure session was created
assert:
that:
- vspan_session_create_result.changed
- name: ensure session was created - name: delete a session.
assert: vmware_vspan_session:
that: hostname: "{{ vcenter_hostname }}"
- vspan_session_create_result.changed username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
- name: delete a session. validate_certs: False
vmware_vspan_session: switch: dvswitch_0001
hostname: "{{ vcsim }}" name: "session_0001"
username: "{{ vcsim_instance['json']['username'] }}" state: "absent"
password: "{{ vcsim_instance['json']['password'] }}" register: vspan_session_delete_result
validate_certs: False - name: ensure session was deleted
switch: dvswitch_0001 assert:
name: "session_0001" that:
state: "absent" - vspan_session_delete_result.changed
register: vspan_session_delete_result
- name: ensure session was deleted
assert:
that:
- vspan_session_delete_result.changed

View file

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

View file

@ -2,143 +2,113 @@
# 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)
# TODO: akasurde: VCSIM does not suport network manager system - 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 # TODO: akasurde: VCSIM does not suport network manager system
wait_for: # FIXME: Implement check-mode support
host: '{{ vcsim }}'
port: 5000
state: started
- name: Kill vcsim - name: Add a nic to a switch
uri: vmware_vswitch:
url: http://{{ vcsim }}:5000/killall hostname: '{{ hostvars[esxi1].ansible_host }}'
username: '{{ hostvars[esxi1].ansible_user }}'
password: '{{ hostvars[esxi1].ansible_password }}'
validate_certs: no
switch: vmswitch_0001
nics: vnic_1
state: present
register: add_nic_run
- assert:
that:
- add_nic_run.changed == true
- name: Start vcsim - name: Add a nic to a switch again
uri: vmware_vswitch:
url: http://{{ vcsim }}:5000/spawn?cluster=2 hostname: '{{ hostvars[esxi1].ansible_host }}'
register: vcsim_instance username: '{{ hostvars[esxi1].ansible_user }}'
password: '{{ hostvars[esxi1].ansible_password }}'
validate_certs: no
switch: vmswitch_0001
nics: vnic_1
state: present
register: add_nic_again_run
- assert:
that:
- add_nic_again_run.changed == false
- name: Wait for Flask controller to come up online - name: Remove a switch (check-mode)
wait_for: vmware_vswitch:
host: '{{ vcsim }}' hostname: '{{ hostvars[esxi1].ansible_host }}'
port: 443 username: '{{ hostvars[esxi1].ansible_user }}'
state: started password: '{{ hostvars[esxi1].ansible_password }}'
validate_certs: no
switch: vmswitch_0001
state: absent
check_mode: yes
register: remove_nic_check
# FIXME: Implement check-mode support
- assert:
that:
- remove_nic_check.changed == true
- debug: # FIXME: Removing a switch fails
var: vcsim_instance - name: Remove a switch
vmware_vswitch:
hostname: '{{ hostvars[esxi1].ansible_host }}'
username: '{{ hostvars[esxi1].ansible_user }}'
password: '{{ hostvars[esxi1].ansible_password }}'
validate_certs: no
switch: vmswitch_0001
state: absent
register: remove_nic_run
- assert:
that:
- remove_nic_run.changed == true
# FIXME: Implement check-mode support - name: Remove a switch again (check-mode)
- name: Add a nic to a switch (check-mode) vmware_vswitch:
vmware_vswitch: &add_nic hostname: '{{ hostvars[esxi1].ansible_host }}'
hostname: '{{ vcsim }}' username: '{{ hostvars[esxi1].ansible_user }}'
username: '{{ vcsim_instance.json.username }}' password: '{{ hostvars[esxi1].ansible_password }}'
password: '{{ vcsim_instance.json.password }}' validate_certs: no
validate_certs: no switch: vmswitch_0001
switch: vmswitch_0001 state: absent
nics: vnic_1 check_mode: yes
state: present register: remove_nic_again_check
check_mode: yes # FIXME: Implement check-mode support
register: add_nic_check - assert:
that:
- remove_nic_again_check_mode.changed == false
- assert: # FIXME: Removing a switch fails
that: - name: Remove a switch again
- add_nic_check.changed == true vmware_vswitch:
- add_nic_check.skipped == true hostname: '{{ hostvars[esxi1].ansible_host }}'
username: '{{ hostvars[esxi1].ansible_user }}'
password: '{{ hostvars[esxi1].ansible_password }}'
validate_certs: no
switch: vmswitch_0001
state: absent
register: remove_nic_again_run
- assert:
that:
- remove_nic_again_run.changed == false
- name: Add a nic to a switch - name: Add vswitch to a specific host system
vmware_vswitch: *add_nic vmware_vswitch:
register: add_nic_run validate_certs: False
hostname: '{{ hostvars[esxi1].ansible_host }}'
- assert: username: '{{ hostvars[esxi1].ansible_user }}'
that: password: '{{ hostvars[esxi1].ansible_password }}'
- add_nic_run.changed == true switch: vmswitch_0002
nics: vnic_1
# FIXME: Implement check-mode support esxi_hostname: guest1
- name: Add a nic to a switch again (check-mode) register: add_vswitch_with_host_system
vmware_vswitch: *add_nic - debug: var=add_vswitch_with_host_system
check_mode: yes - assert:
register: add_nic_again_check that:
- add_vswitch_with_host_system.changed == true
- assert:
that:
- add_nic_again_check.changed == false
- name: Add a nic to a switch again
vmware_vswitch: *add_nic
register: add_nic_again_run
- assert:
that:
- add_nic_again_run.changed == false
- name: Remove a switch (check-mode)
vmware_vswitch: &remove_nic
hostname: '{{ vcsim }}'
username: '{{ vcsim_instance.json.username }}'
password: '{{ vcsim_instance.json.password }}'
validate_certs: no
switch: vmswitch_0001
state: absent
check_mode: yes
register: remove_nic_check
# FIXME: Implement check-mode support
- assert:
that:
- remove_nic_check.changed == true
# FIXME: Removing a switch fails
- name: Remove a switch
vmware_vswitch: *remove_nic
register: remove_nic_run
- assert:
that:
- remove_nic_run.changed == true
- name: Remove a switch again (check-mode)
vmware_vswitch: *remove_nic
check_mode: yes
register: remove_nic_again_check
# FIXME: Implement check-mode support
- assert:
that:
- remove_nic_again_check_mode.changed == false
# FIXME: Removing a switch fails
- name: Remove a switch again
vmware_vswitch: *remove_nic
register: remove_nic_again_run
- assert:
that:
- remove_nic_again_run.changed == false
- name: get a list of Host Systems from vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=H' }}"
register: host_systems
- name: get a host system
set_fact: hs1="{{ host_systems['json'][0] | basename }}"
- debug: var=hs1
- name: Add vswitch to a specific host system
vmware_vswitch:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
switch: vmswitch_0002
nics: vnic_1
esxi_hostname: hs1
register: add_vswitch_with_host_system
- debug: var=add_vswitch_with_host_system
- assert:
that:
- add_vswitch_with_host_system.changed == true

View file

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

View file

@ -2,49 +2,19 @@
# 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
# TODO: vcsim does not support networkConfig related to operations # TODO: vcsim does not support networkConfig related to operations
- 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 host
set_fact:
host1: "{{ hosts.json[0] | basename }}"
- debug: var=host1
- name: Gather vswitch facts about all hosts in given cluster - name: Gather vswitch facts about all hosts in given cluster
vmware_vswitch_facts: vmware_vswitch_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ user }}" username: "{{ vcenter_username }}"
password: "{{ passwd }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
register: switch_facts register: switch_facts
@ -56,10 +26,10 @@
- name: Gather vswitch facts about all hosts in given cluster in check mode - name: Gather vswitch facts about all hosts in given cluster in check mode
vmware_vswitch_facts: vmware_vswitch_facts:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ user }}" username: "{{ vcenter_username }}"
password: "{{ passwd }}" password: "{{ vcenter_password }}"
esxi_hostname: "{{ host1 }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
validate_certs: no validate_certs: no
register: switch_facts_check_mode register: switch_facts_check_mode
check_mode: yes check_mode: yes