vmware: test-refactoring
- In order to keep the integration with `ansible-test`, we prefer to avoid any interaction with the Ansible inventory file. - split up the prepare_vmware_tests/defaults/main.yml in two configuration files: one for vcsim and one for a real environment - remove all the access to hostvars - directly interact with the ESXi to mount/umount the datastore https://github.com/ansible/ansible/pull/56516 - record the virtual machine folder in the environment configuration - vmware_guest_move: Use https://github.com/ansible/ansible/pull/55237
This commit is contained in:
parent
4adb7cfb5f
commit
6bb21c3db0
52 changed files with 612 additions and 532 deletions
|
@ -1,25 +0,0 @@
|
|||
dc1: DC0
|
||||
ccr1: DC0_C0
|
||||
ds1: LocalDS_0
|
||||
ds2: LocalDS_1
|
||||
f0: F0
|
||||
switch1: switch1
|
||||
dvswitch1: DVS0
|
||||
# The ESXi entries in the inventory
|
||||
esxi1: "{{ groups['esxi-lab'][0] }}"
|
||||
esxi2: "{{ groups['esxi-lab'][1] }}"
|
||||
infra:
|
||||
datastores:
|
||||
LocalDS_0:
|
||||
type: nfs
|
||||
server: 192.168.123.1
|
||||
path: /srv/esx_lab/isos
|
||||
ro: true
|
||||
LocalDS_1:
|
||||
type: nfs
|
||||
server: 192.168.123.1
|
||||
path: /srv/esx_lab/vms
|
||||
ro: false
|
||||
vm_list:
|
||||
- DC0_C0_RP0_VM0
|
||||
- DC0_C0_RP0_VM1
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: load vars
|
||||
include_vars:
|
||||
file: real_lab.yml
|
||||
|
||||
- include_tasks: teardown.yml
|
||||
|
||||
- when: setup_esxi_instance is not defined
|
||||
block:
|
||||
- include_tasks: setup_datacenter.yml
|
||||
- include_tasks: setup_cluster.yml
|
||||
- include_tasks: setup_attach_hosts.yml
|
||||
when: setup_attach_host is defined
|
||||
- include_tasks: setup_datastore.yml
|
||||
when: setup_datastore is defined
|
||||
- include_tasks: setup_virtualmachines.yml
|
||||
when: setup_virtualmachines is defined
|
||||
- include_tasks: setup_switch.yml
|
||||
when: setup_switch is defined
|
||||
- include_tasks: setup_dvswitch.yml
|
||||
when: setup_dvswitch is defined
|
||||
- include_tasks: setup_resource_pool.yml
|
||||
when: setup_resource_pool is defined
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
- name: load vars
|
||||
include_vars:
|
||||
file: vcsim.yml
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
|
||||
- name: start vcsim (all dressed)
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?cluster=1&folder=1&ds=2
|
||||
register: vcsim_instance
|
||||
when: setup_esxi_instance is not defined
|
||||
|
||||
- name: start vcsim (ESXi only)
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?esx=1
|
||||
register: vcsim_instance
|
||||
when: setup_esxi_instance is defined
|
||||
|
||||
# - name: get a list of Hosts from vcsim
|
||||
# uri:
|
||||
# url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
# register: vcsim_host_list
|
||||
|
||||
# - name: get a list of Hosts from vcsim
|
||||
# uri:
|
||||
# url: http://{{ vcsim }}:5000/govc_find?filter=F
|
||||
# register: vcsim_host_folder
|
||||
# - debug: var=vcsim_host_folder
|
||||
|
||||
- set_fact:
|
||||
vcenter_hostname: "{{ vcsim }}"
|
||||
vcenter_username: "user"
|
||||
vcenter_password: "pass"
|
|
@ -1,65 +1,6 @@
|
|||
---
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- include_tasks: teardown.yml
|
||||
|
||||
- when: vcsim is not defined and setup_esxi_instance is not defined
|
||||
block:
|
||||
- include_tasks: setup_datacenter.yml
|
||||
- include_tasks: setup_cluster.yml
|
||||
- include_tasks: setup_attach_hosts.yml
|
||||
when: setup_attach_host is defined
|
||||
- include_tasks: setup_datastore.yml
|
||||
when: setup_datastore is defined
|
||||
- include_tasks: setup_virtualmachines.yml
|
||||
when: setup_virtualmachines is defined
|
||||
- include_tasks: setup_switch.yml
|
||||
when: setup_switch is defined
|
||||
- include_tasks: setup_dvswitch.yml
|
||||
when: setup_dvswitch is defined
|
||||
|
||||
import_tasks: init_real_lab.yml
|
||||
|
||||
- when: vcsim is defined
|
||||
block:
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
|
||||
- name: start vcsim (all dressed)
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?cluster=1&folder=1&ds=2
|
||||
register: vcsim_instance
|
||||
when: setup_esxi_instance is not defined
|
||||
|
||||
- name: start vcsim (ESXi only)
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?esx=1
|
||||
register: vcsim_instance
|
||||
when: setup_esxi_instance is defined
|
||||
|
||||
- name: get a list of Hosts from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=H
|
||||
register: vcsim_host_list
|
||||
|
||||
- name: get a list of Hosts from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=F
|
||||
register: vcsim_host_folder
|
||||
- debug: var=vcsim_host_folder
|
||||
|
||||
- name: add the hosts in the inventory
|
||||
add_host:
|
||||
hostname: '{{ item | basename }}'
|
||||
groups:
|
||||
- 'esxi-lab'
|
||||
with_items: '{{ vcsim_host_list.json }}'
|
||||
|
||||
- debug:
|
||||
var: vcsim_host_list
|
||||
|
||||
- set_fact:
|
||||
vcenter_hostname: "{{ vcsim }}"
|
||||
vcenter_username: "user"
|
||||
vcenter_password: "pass"
|
||||
import_tasks: init_vcsim.yml
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
datacenter_name: '{{ dc1 }}'
|
||||
cluster_name: '{{ ccr1 }}'
|
||||
esxi_hostname: '{{ item }}'
|
||||
esxi_username: '{{ hostvars[item].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[item].ansible_password }}'
|
||||
esxi_username: '{{ esxi_user }}'
|
||||
esxi_password: '{{ esxi_password }}'
|
||||
state: present
|
||||
validate_certs: no
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
|
||||
- name: Disable the Maintenance Mode
|
||||
vmware_maintenancemode:
|
||||
|
@ -20,4 +20,4 @@
|
|||
password: "{{ vcenter_password }}"
|
||||
esxi_hostname: '{{ item }}'
|
||||
state: absent
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
|
|
|
@ -6,3 +6,14 @@
|
|||
datacenter_name: '{{ dc1 }}'
|
||||
state: present
|
||||
validate_certs: no
|
||||
|
||||
- name: Create a VM folder on given Datacenter
|
||||
vcenter_folder:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: '{{ dc1 }}'
|
||||
folder_name: '{{ f0 }}'
|
||||
folder_type: vm
|
||||
state: present
|
||||
validate_certs: no
|
||||
|
|
|
@ -1,34 +1,33 @@
|
|||
---
|
||||
- debug: var=datastores
|
||||
- name: Mount NFS (ds1) datastores to ESXi
|
||||
vmware_host_datastore:
|
||||
hostname: '{{ item }}'
|
||||
username: '{{ hostvars[item].ansible_user }}'
|
||||
password: '{{ hostvars[item].ansible_password }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
||||
datastore_name: '{{ ds1 }}'
|
||||
datastore_type: '{{ infra.datastores[ds1].type }}'
|
||||
nfs_server: '{{ infra.datastores[ds1].server }}'
|
||||
nfs_path: '{{ infra.datastores[ds1].path }}'
|
||||
nfs_ro: '{{ infra.datastores[ds2].ro }}'
|
||||
esxi_hostname: '{{ item }}'
|
||||
state: present
|
||||
validate_certs: no
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
|
||||
- name: Mount NFS (ds2) datastores on the ESXi
|
||||
vmware_host_datastore:
|
||||
hostname: '{{ item }}'
|
||||
username: '{{ hostvars[item].ansible_user }}'
|
||||
password: '{{ hostvars[item].ansible_password }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
||||
datastore_name: '{{ ds2 }}'
|
||||
datastore_type: '{{ infra.datastores[ds2].type }}'
|
||||
nfs_server: '{{ infra.datastores[ds2].server }}'
|
||||
nfs_path: '{{ infra.datastores[ds2].path }}'
|
||||
nfs_ro: '{{ infra.datastores[ds2].ro }}'
|
||||
esxi_hostname: '{{ item }}'
|
||||
state: present
|
||||
validate_certs: no
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
|
||||
- name: The vcenter needs a bit of time to refresh the DS list
|
||||
vmware_datastore_facts:
|
||||
|
@ -36,6 +35,7 @@
|
|||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
cluster: '{{ ccr1 }}'
|
||||
register: setup_datastore_datatstore_facts
|
||||
failed_when: setup_datastore_datatstore_facts.datastores|length != 2
|
||||
until: setup_datastore_datatstore_facts is succeeded
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- name: Add resource pool to vCenter
|
||||
vmware_resource_pool:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: '{{ dc1 }}'
|
||||
cluster: '{{ cluster_name }}'
|
||||
resource_pool: DC0_C0_RP1
|
||||
mem_shares: normal
|
||||
mem_limit: -1
|
||||
mem_reservation: 0
|
||||
mem_expandable_reservations: yes
|
||||
cpu_shares: normal
|
||||
cpu_limit: -1
|
||||
cpu_reservation: 0
|
||||
cpu_expandable_reservations: yes
|
||||
state: present
|
|
@ -2,9 +2,10 @@
|
|||
- name: Add a VMware vSwitchs
|
||||
vmware_vswitch:
|
||||
validate_certs: no
|
||||
hostname: '{{ hostvars[item].ansible_host }}'
|
||||
username: '{{ hostvars[item].ansible_user }}'
|
||||
password: '{{ hostvars[item].ansible_password }}'
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
esxi_hostname: '{{ item }}'
|
||||
switch_name: "{{ switch1 }}"
|
||||
state: present
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
---
|
||||
- name: Create a VM folder on given Datacenter
|
||||
vcenter_folder:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: '{{ dc1 }}'
|
||||
folder_name: '{{ f0 }}'
|
||||
folder_type: vm
|
||||
state: present
|
||||
validate_certs: no
|
||||
|
||||
- name: Create VMs
|
||||
vmware_guest:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
|
@ -17,9 +6,8 @@
|
|||
password: "{{ vcenter_password }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
validate_certs: no
|
||||
folder: '{{ f0 }}'
|
||||
cluster: '{{ ccr1 }}'
|
||||
name: '{{ item }}'
|
||||
folder: '{{ item.folder }}'
|
||||
name: '{{ item.name }}'
|
||||
state: poweredon
|
||||
guest_id: debian8_64Guest
|
||||
disk:
|
||||
|
@ -35,4 +23,32 @@
|
|||
iso_path: "[{{ ds1 }}] Fedora-Workstation-Live-x86_64-29-1.2.iso"
|
||||
networks:
|
||||
- name: VM Network
|
||||
with_items: '{{ infra.vm_list }}'
|
||||
with_items: '{{ virtual_machines }}'
|
||||
|
||||
|
||||
- name: Create VMs in cluster
|
||||
vmware_guest:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
validate_certs: no
|
||||
folder: '{{ item.folder }}'
|
||||
cluster: '{{ item.cluster }}'
|
||||
name: '{{ item.name }}'
|
||||
state: poweredon
|
||||
guest_id: debian8_64Guest
|
||||
disk:
|
||||
- size_gb: 1
|
||||
type: thin
|
||||
datastore: '{{ ds2 }}'
|
||||
hardware:
|
||||
memory_mb: 128
|
||||
num_cpus: 1
|
||||
scsi: paravirtual
|
||||
cdrom:
|
||||
type: iso
|
||||
iso_path: "[{{ ds1 }}] Fedora-Workstation-Live-x86_64-29-1.2.iso"
|
||||
networks:
|
||||
- name: VM Network
|
||||
with_items: '{{ virtual_machines_in_cluster }}'
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
---
|
||||
- name: Remove "{{ vm_name }}"
|
||||
- name: Remove VM
|
||||
vmware_guest:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
cluster: "{{ ccr1 }}"
|
||||
name: "{{ item }}"
|
||||
name: "{{ item.name }}"
|
||||
force: yes
|
||||
state: absent
|
||||
with_items: '{{ infra.vm_list }}'
|
||||
with_items: '{{ virtual_machines + virtual_machines_in_cluster }}'
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Remove the DVSwitch
|
||||
|
@ -27,11 +27,12 @@
|
|||
vmware_vswitch:
|
||||
validate_certs: no
|
||||
hostname: '{{ item }}'
|
||||
username: '{{ hostvars[item].ansible_user }}'
|
||||
password: '{{ hostvars[item].ansible_password }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
switch_name: "{{ switch1 }}"
|
||||
state: absent
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Remove ESXi Hosts to vCenter
|
||||
vmware_host:
|
||||
|
@ -41,69 +42,34 @@
|
|||
datacenter_name: '{{ dc1 }}'
|
||||
cluster_name: ccr1
|
||||
esxi_hostname: '{{ item }}'
|
||||
esxi_username: '{{ hostvars[item].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[item].ansible_password }}'
|
||||
esxi_username: '{{ esxi_user }}'
|
||||
esxi_password: '{{ esxi_password }}'
|
||||
state: absent
|
||||
validate_certs: no
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Manually umount the datastores
|
||||
# Work around to avoid an error from vmware_host_datastore saying
|
||||
# the FS is still in use
|
||||
shell: >
|
||||
esxcli storage nfs remove -v nfs_ro;
|
||||
esxcli storage nfs remove -v nfs_rw
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
delegate_to: '{{ item }}'
|
||||
ignore_errors: true
|
||||
|
||||
- name: Umount NFS datastores to ESXi (1/2)
|
||||
vmware_host_datastore:
|
||||
hostname: '{{ item }}'
|
||||
username: '{{ hostvars[item].ansible_user }}'
|
||||
password: '{{ hostvars[item].ansible_password }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
||||
datastore_name: '{{ ds1 }}'
|
||||
esxi_hostname: '{{ item }}'
|
||||
state: absent
|
||||
validate_certs: no
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
register: teardown_umount_nfs
|
||||
until: teardown_umount_nfs is succeeded
|
||||
retries: 15
|
||||
delay: 1
|
||||
ignore_errors: true
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
|
||||
- name: Umount NFS datastores to ESXi (2/2)
|
||||
vmware_host_datastore:
|
||||
hostname: '{{ item }}'
|
||||
username: '{{ hostvars[item].ansible_user }}'
|
||||
password: '{{ hostvars[item].ansible_password }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
||||
datastore_name: '{{ ds2 }}'
|
||||
esxi_hostname: '{{ item }}'
|
||||
state: absent
|
||||
validate_certs: no
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
register: teardown_umount_nfs
|
||||
until: teardown_umount_nfs is succeeded
|
||||
retries: 15
|
||||
delay: 1
|
||||
ignore_errors: true
|
||||
|
||||
# - name: get a final list of the datastore
|
||||
# vmware_datastore_facts:
|
||||
# validate_certs: False
|
||||
# hostname: '{{ item }}'
|
||||
# username: '{{ hostvars[item].ansible_user }}'
|
||||
# password: '{{ hostvars[item].ansible_password }}'
|
||||
# register: datastore_facts
|
||||
# with_items: "{{ groups['esxi-lab'] }}"
|
||||
|
||||
# - name: Ensure nothing is mounted
|
||||
# fail:
|
||||
# msg: "Some datastore are still mounted!"
|
||||
# when: "item.datastores|length > 0"
|
||||
# with_items: "{{ datastore_facts.results }}"
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
|
||||
- name: Remove the datacenter
|
||||
vmware_datacenter:
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
dc1: DC0
|
||||
ccr1: DC0_C0
|
||||
ds1: LocalDS_0
|
||||
ds2: LocalDS_1
|
||||
f0: F0
|
||||
switch1: switch1
|
||||
dvswitch1: DVS0
|
||||
# The ESXi entries in the inventory
|
||||
esxi_hosts:
|
||||
- esxi-67-1.lab
|
||||
- esxi-67-2.lab
|
||||
esxi_user: root
|
||||
esxi_password: "!234AaAa56"
|
||||
esxi1: "{{ esxi_hosts[0] }}"
|
||||
esxi2: "{{ esxi_hosts[1] }}"
|
||||
infra:
|
||||
datastores:
|
||||
LocalDS_0:
|
||||
type: nfs
|
||||
server: 192.168.123.1
|
||||
path: /srv/esx_lab/isos
|
||||
ro: true
|
||||
LocalDS_1:
|
||||
type: nfs
|
||||
server: 192.168.123.1
|
||||
path: /srv/esx_lab/vms
|
||||
ro: false
|
||||
virtual_machines:
|
||||
- name: DC0_H0_VM0
|
||||
folder: '{{ f0 }}'
|
||||
- name: DC0_H0_VM1
|
||||
folder: '{{ f0 }}'
|
||||
virtual_machines_in_cluster:
|
||||
- name: DC0_C0_RP0_VM0
|
||||
folder: '{{ f0 }}'
|
||||
cluster: '{{ ccr1 }}'
|
||||
- name: DC0_C0_RP0_VM1
|
||||
folder: '{{ f0 }}'
|
||||
cluster: '{{ ccr1 }}'
|
25
test/integration/targets/prepare_vmware_tests/vars/vcsim.yml
Normal file
25
test/integration/targets/prepare_vmware_tests/vars/vcsim.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
dc1: DC0
|
||||
ccr1: DC0_C0
|
||||
ds1: LocalDS_0
|
||||
ds2: LocalDS_1
|
||||
f0: F0
|
||||
esxi_hosts:
|
||||
- DC0_C0_H0
|
||||
- DC0_C0_H1
|
||||
- DC0_C0_H2
|
||||
esxi1: '{{ esxi_hosts[0] }}'
|
||||
esxi2: '{{ esxi_hosts[1] }}'
|
||||
esxi3: '{{ esxi_hosts[2] }}'
|
||||
switch1: switch1
|
||||
dvswitch1: DVS0
|
||||
virtual_machines:
|
||||
- name: DC0_H0_VM0
|
||||
folder: /F0/DC0/vm/F0
|
||||
- name: DC0_H0_VM1
|
||||
folder: /F0/DC0/vm/F0
|
||||
virtual_machines_in_cluster:
|
||||
- name: DC0_C0_RP0_VM0
|
||||
cluster: '{{ ccr1 }}'
|
||||
- name: DC0_C0_RP0_VM1
|
||||
cluster: '{{ ccr1 }}'
|
|
@ -3,20 +3,6 @@
|
|||
# Copyright (c) 2018, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Testcase 0001: Get a full list of datastores in a datacenter
|
||||
# - name: get list of facts about datastores
|
||||
# vmware_datastore_facts:
|
||||
# validate_certs: False
|
||||
# hostname: "{{ vcenter_hostname }}"
|
||||
# username: "{{ vcenter_username }}"
|
||||
# password: "{{ vcenter_password }}"
|
||||
# datacenter: "{{ dc1 }}"
|
||||
# register: datastore_facts_0001
|
||||
|
||||
# - assert:
|
||||
# that:
|
||||
# - "datastore_facts_0001.datastores|length == 0"
|
||||
|
||||
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
|
@ -29,11 +15,11 @@
|
|||
- name: get list of facts about datastores from the ESXi
|
||||
vmware_datastore_facts:
|
||||
validate_certs: False
|
||||
hostname: '{{ hostvars[item].ansible_host }}'
|
||||
username: '{{ hostvars[item].ansible_user }}'
|
||||
password: '{{ hostvars[item].ansible_password }}'
|
||||
hostname: '{{ item }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
register: facts_from_esxi
|
||||
with_items: "{{ groups['esxi-lab'] }}"
|
||||
with_items: "{{ esxi_hosts }}"
|
||||
- assert:
|
||||
that:
|
||||
- "facts_from_esxi.results[0].datastores|length == 2"
|
||||
|
@ -48,7 +34,6 @@
|
|||
gather_nfs_mount_info: true
|
||||
register: facts_from_vcenter_with_dc_filter
|
||||
|
||||
# Depends-On: https://github.com/ansible/ansible/pull/54879
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- name: get list of facts about datastores
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
cluster_name: '{{ ccr1 }}'
|
||||
datacenter_name: '{{ dc1 }}'
|
||||
group_name: TEST_VM_01
|
||||
vms:
|
||||
- DC0_C0_RP0_VM0
|
||||
- DC0_C0_RP0_VM1
|
||||
vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
|
||||
state: present
|
||||
register: drs_vm_group_01_results
|
||||
|
||||
|
@ -32,7 +30,7 @@
|
|||
that:
|
||||
- "drs_vm_group_01_results.changed"
|
||||
|
||||
- when: vcsim is defined or groups['esxi-lab'] | length >= 3
|
||||
- when: vcsim is defined or esxi_hosts | length >= 3
|
||||
block:
|
||||
- name: Create DRS Host group
|
||||
vmware_drs_group:
|
||||
|
@ -43,7 +41,7 @@
|
|||
cluster_name: '{{ ccr1 }}'
|
||||
datacenter_name: '{{ dc1 }}'
|
||||
group_name: TEST_HOST_01
|
||||
hosts: "{{ groups['esxi-lab'][0:3] }}"
|
||||
hosts: "{{ esxi_hosts[0:3] }}"
|
||||
state: present
|
||||
register: drs_host_group_01_results
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
|
||||
- when: vcsim is defined or groups['esxi-lab'] | length >= 3
|
||||
- when: vcsim is defined or esxi_hosts | length >= 3
|
||||
block:
|
||||
- name: Gather DRS group facts from given cluster
|
||||
vmware_drs_group_facts:
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
# 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)
|
||||
|
||||
- when: vcsim is defined or groups['esxi-lab'] | length >= 3
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
|
||||
- when: vcsim is defined or esxi_hosts | length >= 3
|
||||
block:
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
# 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)
|
||||
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- &dvs_facts
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_datacenter: true
|
||||
|
||||
- &dvs_data
|
||||
name: Add distributed vSwitch
|
||||
|
@ -26,13 +28,26 @@
|
|||
that:
|
||||
- dvs_result_0001.changed
|
||||
|
||||
- name: Create a VM folder on given Datacenter
|
||||
vcenter_folder:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: '{{ dc1 }}'
|
||||
folder_name: network_folder
|
||||
folder_type: network
|
||||
state: present
|
||||
validate_certs: no
|
||||
register:
|
||||
network_folder_result
|
||||
|
||||
- name: Add distributed vSwitch using folder
|
||||
vmware_dvswitch:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
folder: "/F0/{{ dc1 }}/network/F0"
|
||||
folder: "{{ network_folder_result.result.path }}"
|
||||
state: present
|
||||
switch_name: dvswitch_0002
|
||||
mtu: 9000
|
||||
|
|
|
@ -60,15 +60,15 @@
|
|||
that:
|
||||
- pvlans_result is changed
|
||||
|
||||
- <<: *pv_data
|
||||
name: Configure PVLANs in check mode
|
||||
register: pvlans_result_check_mode
|
||||
check_mode: yes
|
||||
|
||||
- debug:
|
||||
var: pvlans_result_check_mode
|
||||
|
||||
- name: ensure pvlans were configured
|
||||
assert:
|
||||
that:
|
||||
- pvlans_result_check_mode is changed
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- <<: *pv_data
|
||||
name: Configure PVLANs in check mode
|
||||
register: pvlans_result_check_mode
|
||||
check_mode: yes
|
||||
- debug:
|
||||
var: pvlans_result_check_mode
|
||||
- name: ensure pvlans were not changed
|
||||
assert:
|
||||
that:
|
||||
- not (pvlans_result_check_mode is changed)
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
- <<: *uplink_data
|
||||
name: Configure Uplink portgroup
|
||||
register: uplink_pg_result
|
||||
check_mode: no
|
||||
|
||||
- debug:
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'newvm_' + item|basename }}"
|
||||
name: "{{ 'newvm_' + item.name }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
hardware:
|
||||
num_cpus: 4
|
||||
boot_firmware: "bios"
|
||||
|
@ -20,8 +20,8 @@
|
|||
type: thin
|
||||
autoselect_datastore: True
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
folder: "{{ item.folder }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: clone_d1_c1_f0
|
||||
|
||||
- debug: var=clone_d1_c1_f0
|
||||
|
@ -32,34 +32,34 @@
|
|||
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]"
|
||||
|
||||
# VCSIM does not recognizes existing VMs boot firmware
|
||||
#- name: create new VMs again with boot_firmware as 'bios'
|
||||
# vmware_guest:
|
||||
# validate_certs: False
|
||||
# hostname: "{{ vcenter_hostname }}"
|
||||
# username: "{{ vcenter_username }}"
|
||||
# password: "{{ vcenter_password }}"
|
||||
# name: "{{ 'newvm_' + item|basename }}"
|
||||
# guest_id: centos64Guest
|
||||
# datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
# hardware:
|
||||
# num_cpus: 4
|
||||
# boot_firmware: "bios"
|
||||
# memory_mb: 512
|
||||
# disk:
|
||||
# - size: 1gb
|
||||
# type: thin
|
||||
# autoselect_datastore: True
|
||||
# state: poweredoff
|
||||
# folder: "{{ item|dirname }}"
|
||||
# with_items: "{{ vmlist['json'] }}"
|
||||
# register: clone_d1_c1_f0
|
||||
|
||||
#- debug: var=clone_d1_c1_f0
|
||||
|
||||
#- name: assert that changes were not made
|
||||
# assert:
|
||||
# that:
|
||||
# - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- name: create new VMs again with boot_firmware as 'bios'
|
||||
vmware_guest:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'newvm_' + item.name }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ dc1 }}"
|
||||
hardware:
|
||||
num_cpus: 4
|
||||
boot_firmware: "bios"
|
||||
memory_mb: 512
|
||||
disk:
|
||||
- size: 1gb
|
||||
type: thin
|
||||
autoselect_datastore: True
|
||||
state: poweredoff
|
||||
folder: "{{ item.folder }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: clone_d1_c1_f0
|
||||
- debug: var=clone_d1_c1_f0
|
||||
- name: assert that changes were not made
|
||||
assert:
|
||||
that:
|
||||
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
||||
|
||||
- name: create new VMs with boot_firmware as 'efi'
|
||||
vmware_guest:
|
||||
|
@ -67,9 +67,9 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'newvm_efi_' + item|basename }}"
|
||||
name: "{{ 'newvm_efi_' + item.name }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
hardware:
|
||||
num_cpus: 4
|
||||
boot_firmware: "efi"
|
||||
|
@ -79,8 +79,8 @@
|
|||
type: thin
|
||||
autoselect_datastore: True
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
folder: "{{ item.folder }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: clone_d1_c1_f0
|
||||
|
||||
- debug: var=clone_d1_c1_f0
|
||||
|
@ -91,31 +91,31 @@
|
|||
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]"
|
||||
|
||||
# VCSIM does not recognizes existing VMs boot firmware
|
||||
#- name: create new VMs again with boot_firmware as 'efi'
|
||||
# vmware_guest:
|
||||
# validate_certs: False
|
||||
# hostname: "{{ vcenter_hostname }}"
|
||||
# username: "{{ vcenter_username }}"
|
||||
# password: "{{ vcenter_password }}"
|
||||
# name: "{{ 'newvm_efi_' + item|basename }}"
|
||||
# guest_id: centos64Guest
|
||||
# datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
# hardware:
|
||||
# num_cpus: 4
|
||||
# boot_firmware: "efi"
|
||||
# memory_mb: 512
|
||||
# disk:
|
||||
# - size: 1gb
|
||||
# type: thin
|
||||
# autoselect_datastore: True
|
||||
# state: poweredoff
|
||||
# folder: "{{ item|dirname }}"
|
||||
# with_items: "{{ vmlist['json'] }}"
|
||||
# register: clone_d1_c1_f0
|
||||
|
||||
#- debug: var=clone_d1_c1_f0
|
||||
|
||||
#- name: assert that changes were not made
|
||||
# assert:
|
||||
# that:
|
||||
# - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- name: create new VMs again with boot_firmware as 'efi'
|
||||
vmware_guest:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'newvm_efi_' + item.name }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ dc1 }}"
|
||||
hardware:
|
||||
num_cpus: 4
|
||||
boot_firmware: "efi"
|
||||
memory_mb: 512
|
||||
disk:
|
||||
- size: 1gb
|
||||
type: thin
|
||||
autoselect_datastore: True
|
||||
state: poweredoff
|
||||
folder: "{{ item.folder }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: clone_d1_c1_f0
|
||||
- debug: var=clone_d1_c1_f0
|
||||
- name: assert that changes were not made
|
||||
assert:
|
||||
that:
|
||||
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
state: "{{ item }}"
|
||||
with_items:
|
||||
|
@ -30,7 +30,7 @@
|
|||
assert:
|
||||
that:
|
||||
- "check_mode_state.results|map(attribute='changed')|unique|list == [true]"
|
||||
- "check_mode_state.results|map(attribute='vm_name')|unique|list == [ infra.vm_list[0] ]"
|
||||
- "check_mode_state.results|map(attribute='vm_name')|unique|list == [ virtual_machines[0].name ]"
|
||||
|
||||
- name: Perform all operation on non-existent VM in check mode
|
||||
vmware_guest:
|
||||
|
|
|
@ -2,51 +2,19 @@
|
|||
# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 5000
|
||||
state: started
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
|
||||
- name: start vcsim with no folders
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
|
||||
register: vcsim_instance
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 443
|
||||
state: started
|
||||
|
||||
- name: get a list of VMS from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=VM
|
||||
register: vmlist
|
||||
|
||||
- debug:
|
||||
var: vcsim_instance
|
||||
|
||||
- debug:
|
||||
var: vmlist
|
||||
|
||||
- name: clone vm from template and customize GOS
|
||||
vmware_guest:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
name: "{{ 'net_customize_' + item|basename }}"
|
||||
template: "{{ item|basename }}"
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'net_customize_' + item.name }}"
|
||||
template: "{{ item.name }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
folder: "{{ item.folder }}"
|
||||
convert: thin
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: clone_customize
|
||||
|
||||
- debug:
|
||||
|
@ -60,16 +28,16 @@
|
|||
- name: clone vm from template and customize GOS again
|
||||
vmware_guest:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
name: "{{ 'net_customize_' + item|basename }}"
|
||||
template: "{{ item|basename }}"
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'net_customize_' + item.name }}"
|
||||
template: "{{ item.name }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
folder: "{{ item.folder }}"
|
||||
convert: thin
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: clone_customize_again
|
||||
|
||||
- debug:
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'thin_' + item|basename }}"
|
||||
template: "{{ item|basename }}"
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
name: "{{ 'thin_' + item.name }}"
|
||||
template: "{{ item.name }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
folder: "{{ item.folder }}"
|
||||
convert: thin
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: clone_thin
|
||||
|
||||
- debug: var=clone_thin
|
||||
|
@ -30,13 +30,13 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'thick_' + item|basename }}"
|
||||
template: "{{ item|basename }}"
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
name: "{{ 'thick_' + item.name }}"
|
||||
template: "{{ item.name }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
folder: "{{ item.folder }}"
|
||||
convert: thick
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: clone_thick
|
||||
|
||||
- debug: var=clone_thick
|
||||
|
@ -52,13 +52,13 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'eagerzeroedthick_' + item|basename }}"
|
||||
template: "{{ item|basename }}"
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
name: "{{ 'eagerzeroedthick_' + item.name }}"
|
||||
template: "{{ item.name }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
folder: "{{ item.folder }}"
|
||||
convert: eagerzeroedthick
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: clone_eagerzeroedthick
|
||||
|
||||
- debug: var=clone_eagerzeroedthick
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
password: "{{ vcenter_password }}"
|
||||
name: disk_mode_d1_c1_f0
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
hardware:
|
||||
num_cpus: 1
|
||||
memory_mb: 512
|
||||
|
|
|
@ -2,47 +2,19 @@
|
|||
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 5000
|
||||
state: started
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
- name: start vcsim with no folders
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
|
||||
register: vcsim_instance
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 443
|
||||
state: started
|
||||
|
||||
- name: get a list of VMS from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=VM
|
||||
register: vmlist
|
||||
|
||||
- debug: var=vcsim_instance
|
||||
- debug: var=vmlist
|
||||
|
||||
- name: create new linked clone without specifying snapshot_src
|
||||
vmware_guest:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
name: "{{ 'new_vm_' + item|basename }}"
|
||||
template: "{{ item|basename }}"
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'new_vm_' + item.name }}"
|
||||
template: "{{ item.name }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
folder: "{{ item|dirname }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
linked_clone: True
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: linked_clone_d1_c1_f0
|
||||
ignore_errors: True
|
||||
|
||||
|
@ -56,16 +28,15 @@
|
|||
- name: create new linked clone without specifying linked_clone
|
||||
vmware_guest:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
name: "{{ 'new_vm_' + item|basename }}"
|
||||
template: "{{ item|basename }}"
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ 'new_vm_' + item.name }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
folder: "{{ item|dirname }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
snapshot_src: "snap_shot1"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: linked_clone_d1_c1_f0
|
||||
ignore_errors: True
|
||||
|
||||
|
@ -126,4 +97,4 @@
|
|||
#- name: assert that changes were not made
|
||||
# assert:
|
||||
# that:
|
||||
# - "linked_clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
||||
# - "linked_clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
||||
|
|
|
@ -5,24 +5,44 @@
|
|||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_datacenter: true
|
||||
setup_attach_host: true
|
||||
setup_datastore: true
|
||||
setup_virtualmachines: true
|
||||
setup_resource_pool: true
|
||||
|
||||
|
||||
- include: poweroff_d1_c1_f0.yml
|
||||
- include: poweroff_d1_c1_f1.yml
|
||||
- include: check_mode.yml
|
||||
- include: clone_d1_c1_f0.yml
|
||||
- include: create_d1_c1_f0.yml
|
||||
- include: cdrom_d1_c1_f0.yml
|
||||
- include: create_rp_d1_c1_f0.yml
|
||||
- include: create_guest_invalid_d1_c1_f0.yml
|
||||
- include: mac_address_d1_c1_f0.yml
|
||||
- include: disk_type_d1_c1_f0.yml
|
||||
- include: create_nw_d1_c1_f0.yml
|
||||
- include: delete_vm.yml
|
||||
- include: non_existent_vm_ops.yml
|
||||
- block:
|
||||
- include: poweroff_d1_c1_f0.yml
|
||||
- include: poweroff_d1_c1_f1.yml
|
||||
- include: check_mode.yml
|
||||
- include: clone_d1_c1_f0.yml
|
||||
- include: create_d1_c1_f0.yml
|
||||
- include: cdrom_d1_c1_f0.yml
|
||||
- include: create_rp_d1_c1_f0.yml
|
||||
- include: create_guest_invalid_d1_c1_f0.yml
|
||||
- include: mac_address_d1_c1_f0.yml
|
||||
- include: disk_type_d1_c1_f0.yml
|
||||
- include: create_nw_d1_c1_f0.yml
|
||||
- include: delete_vm.yml
|
||||
- include: non_existent_vm_ops.yml
|
||||
always:
|
||||
- name: Remove VM
|
||||
vmware_guest:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
cluster: "{{ ccr1 }}"
|
||||
name: '{{ item }}'
|
||||
force: yes
|
||||
state: absent
|
||||
with_items:
|
||||
- CDROM-Test
|
||||
- CDROM-Test-38679
|
||||
- newvm_2
|
||||
- newvm_3
|
||||
- newvmnw_4
|
||||
- DC0_H0_VM12
|
||||
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
|
@ -31,17 +51,66 @@
|
|||
setup_datastore: true
|
||||
setup_virtualmachines: true
|
||||
|
||||
- include: network_negative_test.yml
|
||||
# VCSIM does not return list of portgroups for dvswitch so commenting following TC
|
||||
#- include: network_with_portgroup.yml
|
||||
# Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test
|
||||
# - include: network_with_dvpg.yml
|
||||
#- include: template_d1_c1_f0.yml
|
||||
- include: vapp_d1_c1_f0.yml
|
||||
- include: disk_size_d1_c1_f0.yml
|
||||
- include: network_with_device.yml
|
||||
- include: disk_mode_d1_c1_f0.yml
|
||||
- include: linked_clone_d1_c1_f0.yml
|
||||
- include: boot_firmware_d1_c1_f0.yml
|
||||
- include: clone_with_convert.yml
|
||||
- include: clone_customize_guest_test.yml
|
||||
- block:
|
||||
- include: network_negative_test.yml
|
||||
# VCSIM does not return list of portgroups for dvswitch so commenting following TC
|
||||
#- include: network_with_portgroup.yml
|
||||
# Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test
|
||||
# - include: network_with_dvpg.yml
|
||||
#- include: template_d1_c1_f0.yml
|
||||
- include: vapp_d1_c1_f0.yml
|
||||
- include: disk_size_d1_c1_f0.yml
|
||||
- include: network_with_device.yml
|
||||
- include: disk_mode_d1_c1_f0.yml
|
||||
- include: linked_clone_d1_c1_f0.yml
|
||||
always:
|
||||
- name: Remove VM
|
||||
vmware_guest:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
cluster: "{{ ccr1 }}"
|
||||
name: '{{ item }}'
|
||||
force: yes
|
||||
state: absent
|
||||
with_items:
|
||||
- disk_mode_d1_c1_f0
|
||||
- network_with_device
|
||||
- new_vm_no_nw_type
|
||||
- vApp-Test
|
||||
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_attach_host: true
|
||||
setup_datastore: true
|
||||
setup_virtualmachines: true
|
||||
- block:
|
||||
- include: boot_firmware_d1_c1_f0.yml
|
||||
- include: clone_with_convert.yml
|
||||
- include: clone_customize_guest_test.yml
|
||||
always:
|
||||
- name: Remove VM
|
||||
vmware_guest:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
cluster: "{{ ccr1 }}"
|
||||
name: '{{ item }}'
|
||||
force: yes
|
||||
state: absent
|
||||
with_items:
|
||||
- newvm_DC0_H0_VM0
|
||||
- newvm_DC0_H0_VM1
|
||||
- newvm_efi_DC0_H0_VM0
|
||||
- newvm_efi_DC0_H0_VM1
|
||||
- thin_DC0_H0_VM0
|
||||
- thin_DC0_H0_VM1
|
||||
- thick_DC0_H0_VM0
|
||||
- thick_DC0_H0_VM1
|
||||
- eagerzeroedthick_DC0_H0_VM0
|
||||
- eagerzeroedthick_DC0_H0_VM1
|
||||
- net_customize_DC0_H0_VM0
|
||||
- net_customize_DC0_H0_VM1
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ item }}"
|
||||
name: "{{ item.name }}"
|
||||
state: poweredoff
|
||||
with_items: "{{ infra.vm_list }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: poweroff_d1_c1_f0
|
||||
|
||||
- debug:
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ item }}"
|
||||
name: "{{ item.name }}"
|
||||
state: poweredoff
|
||||
folder: "DC1/C1/F1"
|
||||
with_items: "{{ infra.vm_list }}"
|
||||
folder: "{{ item.folder }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: poweroff_d1_c1_f1
|
||||
|
||||
- debug: var=poweroff_d1_c1_f1
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
register: vm1_facts
|
||||
- debug: var=vm1_facts
|
||||
- name: assert that values are set
|
||||
|
@ -36,7 +36,7 @@
|
|||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
check_mode: yes
|
||||
register: vm1_facts
|
||||
- debug: var=vm1_facts
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: present
|
||||
attributes:
|
||||
- name: 'sample_1'
|
||||
|
@ -42,8 +42,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: present
|
||||
attributes:
|
||||
- name: 'sample_1'
|
||||
|
@ -67,8 +67,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: absent
|
||||
attributes:
|
||||
- name: 'sample_1'
|
||||
|
@ -94,8 +94,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: absent
|
||||
attributes:
|
||||
- name: 'sample_1'
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
datacenter: '{{ dc1 }}'
|
||||
register: disk_facts
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
register: guest_facts_0001
|
||||
|
||||
- debug:
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- "guest_facts_0001['instance']['hw_name'] == infra.vm_list[0]"
|
||||
- "guest_facts_0001['instance']['hw_name'] == virtual_machines[0].name"
|
||||
- "guest_facts_0001['instance']['hw_product_uuid'] is defined"
|
||||
- "guest_facts_0001['instance']['hw_cores_per_socket'] is defined"
|
||||
- "guest_facts_0001['instance']['hw_datastores'] is defined"
|
||||
|
@ -86,7 +86,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- "guest_facts_0002['instance']['hw_name'] == infra.vm_list[0]"
|
||||
- "guest_facts_0002['instance']['hw_name'] == virtual_machines[0].name"
|
||||
- "guest_facts_0002['instance']['hw_product_uuid'] is defined"
|
||||
- "guest_facts_0002['instance']['hw_product_uuid'] == vm1_uuid"
|
||||
- "guest_facts_0002['instance']['hw_cores_per_socket'] is defined"
|
||||
|
@ -124,8 +124,8 @@
|
|||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: present
|
||||
snapshot_name: snap1
|
||||
|
||||
|
@ -172,7 +172,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- "guest_facts_0005['instance']['hw_name'] == infra.vm_list[0]"
|
||||
- "guest_facts_0005['instance']['hw_name'] == virtual_machines[0].name"
|
||||
- "guest_facts_0005['instance']['hw_product_uuid'] is defined"
|
||||
- "guest_facts_0005['instance']['hw_product_uuid'] == vm1_uuid"
|
||||
- "guest_facts_0005['instance']['hw_cores_per_socket'] is defined"
|
||||
|
@ -187,4 +187,4 @@
|
|||
- "guest_facts_0005['instance']['instance_uuid'] is defined"
|
||||
- "guest_facts_0005['instance']['instance_uuid'] == vm1_instance_uuid"
|
||||
- "guest_facts_0001['instance']['moid'] is defined"
|
||||
- "guest_facts_0001['instance']['vimref'] is defined"
|
||||
- "guest_facts_0001['instance']['vimref'] is defined"
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ item }}"
|
||||
name: "{{ item.name }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
with_items: "{{ infra.vm_list }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: folders
|
||||
|
||||
- debug: var=item
|
||||
|
@ -38,8 +38,8 @@
|
|||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
register: guest_facts_0001
|
||||
|
||||
- debug: var=guest_facts_0001
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
folder_type: vm
|
||||
state: present
|
||||
validate_certs: no
|
||||
register: dest_folder
|
||||
|
||||
# Testcase 0001: Move vm and get changed status
|
||||
- name: Move VM (Changed)
|
||||
|
@ -27,8 +28,9 @@
|
|||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
dest_folder: '/F0/DC0/vm/f1'
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
# Depends-On: https://github.com/ansible/ansible/pull/55237
|
||||
dest_folder: "{{ dest_folder.result.path }}"
|
||||
register: vm_facts_0001
|
||||
|
||||
|
||||
|
@ -40,8 +42,8 @@
|
|||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
dest_folder: 'F0/DC0/vm/f1'
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
dest_folder: "{{ dest_folder.result.path }}"
|
||||
register: vm_facts_0002
|
||||
|
||||
- debug:
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: powered-off
|
||||
folder: '/dc1/vm/f0'
|
||||
register: poweroff_d1_c1_f0
|
||||
|
||||
- debug: var=poweroff_d1_c1_f0
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
name: "{{ item|basename }}"
|
||||
state: powered-off
|
||||
folder: "{{ item|dirname }}"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: poweroff_d1_c1_f0
|
||||
|
||||
- debug: var=poweroff_d1_c1_f0
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: absent
|
||||
snapshot_name: snap_a
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: present
|
||||
snapshot_name: "snap_{{item}}"
|
||||
description: "snap named {{item}}"
|
||||
|
@ -45,8 +45,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: present
|
||||
snapshot_name: snap_a
|
||||
new_snapshot_name: snap_c
|
||||
|
@ -59,8 +59,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: present
|
||||
snapshot_name: snap_a
|
||||
description: "snap named a"
|
||||
|
@ -73,8 +73,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: present
|
||||
snapshot_name: snap_c
|
||||
new_description: "renamed to snap_c from snap_a"
|
||||
|
@ -89,8 +89,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: absent
|
||||
snapshot_name: snap_b
|
||||
remove_children: True
|
||||
|
@ -103,8 +103,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: remove_all
|
||||
|
||||
# Test0008: Create snap_a again and revert to it
|
||||
|
@ -115,8 +115,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: present
|
||||
snapshot_name: snap_a
|
||||
description: "snap named a"
|
||||
|
@ -130,8 +130,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: revert
|
||||
snapshot_name: snap_a
|
||||
|
||||
|
@ -143,8 +143,8 @@
|
|||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
state: present
|
||||
snapshot_name: snap_a
|
||||
description: "snap named a"
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
folder: "{{ f0 }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
register: vm_snapshot_facts
|
||||
|
||||
- debug: var=vm_snapshot_facts
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "{{ infra.vm_list[0] }}"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
folder: "{{ virtual_machines[0].folder }}"
|
||||
datacenter: "{{ dc1 }}"
|
||||
state: poweredon
|
||||
folder: "{{ f0 }}"
|
||||
|
||||
# FixMe: govcsim does not support VMware tools status reporting
|
||||
## Testcase 0001: Wait for VMware tools to become available by name
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
# Testcase: Add Host
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_attach_host: true
|
||||
|
||||
- name: Add first ESXi Host to vCenter
|
||||
vmware_host:
|
||||
|
@ -13,8 +17,8 @@
|
|||
datacenter_name: '{{ dc1 }}'
|
||||
cluster_name: '{{ ccr1 }}'
|
||||
esxi_hostname: '{{ esxi1 }}'
|
||||
esxi_username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
esxi_username: '{{ esxi_user }}'
|
||||
esxi_password: '{{ esxi_password }}'
|
||||
state: present
|
||||
validate_certs: no
|
||||
register: readd_host_result
|
||||
|
@ -27,8 +31,8 @@
|
|||
datacenter_name: '{{ dc1 }}'
|
||||
cluster_name: '{{ ccr1 }}'
|
||||
esxi_hostname: '{{ esxi1 }}'
|
||||
esxi_username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
esxi_username: '{{ esxi_user }}'
|
||||
esxi_password: '{{ esxi_password }}'
|
||||
state: present
|
||||
validate_certs: no
|
||||
register: readd_host_result
|
||||
|
@ -45,11 +49,10 @@
|
|||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ esxi2 }}'
|
||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
||||
esxi_username: '{{ esxi_user }}'
|
||||
esxi_password: '{{ esxi_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
|
||||
|
@ -119,8 +122,8 @@
|
|||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ esxi2 }}'
|
||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
||||
esxi_username: '{{ esxi_user }}'
|
||||
esxi_password: '{{ esxi_password }}'
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
folder_name: "/{{ dc1 }}/host/Staging"
|
||||
state: present
|
||||
|
@ -139,8 +142,8 @@
|
|||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ esxi2 }}'
|
||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
||||
esxi_username: '{{ esxi_user }}'
|
||||
esxi_password: '{{ esxi_password }}'
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
folder_name: "/{{ dc1 }}/host/Staging"
|
||||
state: present
|
||||
|
@ -158,8 +161,8 @@
|
|||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
esxi_hostname: '{{ esxi2 }}'
|
||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
||||
esxi_username: '{{ esxi_user }}'
|
||||
esxi_password: '{{ esxi_password }}'
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
state: reconnect
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
vmware_host_facts:
|
||||
validate_certs: False
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
register: facts
|
||||
- debug: var=facts
|
||||
- name: verify some data,like ansible_processor
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_esxi_instance: true
|
||||
setup_attach_host: true
|
||||
|
||||
- name: Gather firewall facts for a given ESXi
|
||||
vmware_host_firewall_facts:
|
||||
|
|
|
@ -73,5 +73,5 @@
|
|||
assert:
|
||||
that:
|
||||
- not (all_hosts_result is changed)
|
||||
- "all_hosts_result.result['{{ esxi1 }}']current_state == 'balanced'"
|
||||
- "all_hosts_result.result['{{ esxi2 }}']current_state == 'balanced'"
|
||||
- "all_hosts_result.result['{{ esxi1 }}'].current_state == 'balanced'"
|
||||
- "all_hosts_result.result['{{ esxi2 }}'].current_state == 'balanced'"
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
# SNMP works only with standalone ESXi server
|
||||
- name: Enable and configure SNMP community in check mode
|
||||
vmware_host_snmp:
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
community: [ test ]
|
||||
state: enabled
|
||||
validate_certs: no
|
||||
|
@ -28,9 +28,9 @@
|
|||
|
||||
- name: Enable and configure SNMP community
|
||||
vmware_host_snmp:
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
community: [ test ]
|
||||
state: enabled
|
||||
validate_certs: no
|
||||
|
@ -43,9 +43,9 @@
|
|||
|
||||
- name: Disable SNMP
|
||||
vmware_host_snmp:
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
state: disabled
|
||||
validate_certs: no
|
||||
register: snmp_disabled
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
- &user_fact_data
|
||||
name: Gather facts about users
|
||||
vmware_local_user_facts:
|
||||
hostname: "{{ hostvars[esxi1].ansible_host }}"
|
||||
username: "{{ hostvars[esxi1].ansible_user }}"
|
||||
password: "{{ hostvars[esxi1].ansible_password }}"
|
||||
hostname: "{{ esxi1 }}"
|
||||
username: "{{ esxi_user }}"
|
||||
password: "{{ esxi_password }}"
|
||||
validate_certs: False
|
||||
register: all_user_facts
|
||||
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- debug: var=ccr1
|
||||
|
||||
- debug: var=host1
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_datacenter: true
|
||||
setup_attach_host: true
|
||||
setup_cluster: true
|
||||
|
||||
- name: Create portgroup without Portgroup and vSwitch
|
||||
vmware_portgroup:
|
||||
|
|
|
@ -3,14 +3,20 @@
|
|||
# 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)
|
||||
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_datastore: true
|
||||
setup_virtualmachines: true
|
||||
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- name: Get facts from a given ESXi
|
||||
vmware_vm_facts:
|
||||
validate_certs: false
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
|
@ -59,7 +65,7 @@
|
|||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
name: "DC0_H0_VM0"
|
||||
name: "{{ virtual_machines[0].name }}"
|
||||
register: folder_path_info
|
||||
|
||||
- set_fact:
|
||||
|
@ -75,6 +81,7 @@
|
|||
folder: "{{ folder_path }}"
|
||||
register: vm_facts
|
||||
when: folder_path_info.folders is defined
|
||||
- debug: var=vm_facts
|
||||
|
||||
- name: Check if facts are returned for VM with folder specified
|
||||
assert:
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
setup_attach_host: true
|
||||
setup_datastore: true
|
||||
setup_virtualmachines: true
|
||||
|
||||
- name: Create DRS VM group
|
||||
vmware_drs_group:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
|
@ -20,7 +21,7 @@
|
|||
cluster_name: '{{ ccr1 }}'
|
||||
datacenter_name: '{{ dc1 }}'
|
||||
group_name: DC0_C0_VM_GR1
|
||||
vms: '{{ infra.vm_list }}'
|
||||
vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
|
||||
state: present
|
||||
register: drs_vm_group_01_results
|
||||
- debug: var=drs_vm_group_01_results
|
||||
|
@ -35,9 +36,7 @@
|
|||
cluster_name: '{{ ccr1 }}'
|
||||
datacenter_name: '{{ dc1 }}'
|
||||
group_name: DC0_C0_HOST_GR1
|
||||
hosts:
|
||||
- '{{ hostvars[esxi1].ansible_host }}'
|
||||
- '{{ hostvars[esxi2].ansible_host }}'
|
||||
hosts: '{{ esxi_hosts }}'
|
||||
state: present
|
||||
register: drs_host_group_01_results
|
||||
- debug: var=drs_host_group_01_results
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
password: "{{ vcenter_password }}"
|
||||
drs_rule_name: drs_rule_0001
|
||||
cluster_name: "{{ ccr1 }}"
|
||||
vms: "{{ infra.vm_list }}"
|
||||
vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
|
||||
enabled: True
|
||||
affinity_rule: True
|
||||
mandatory: True
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
- name: Add a nic to a switch
|
||||
vmware_vswitch:
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
validate_certs: no
|
||||
switch: vmswitch_0001
|
||||
nics: vnic_1
|
||||
|
@ -28,9 +28,9 @@
|
|||
|
||||
- name: Add a nic to a switch again
|
||||
vmware_vswitch:
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
validate_certs: no
|
||||
switch: vmswitch_0001
|
||||
nics: vnic_1
|
||||
|
@ -42,9 +42,9 @@
|
|||
|
||||
- name: Remove a switch (check-mode)
|
||||
vmware_vswitch:
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
validate_certs: no
|
||||
switch: vmswitch_0001
|
||||
state: absent
|
||||
|
@ -58,9 +58,9 @@
|
|||
# FIXME: Removing a switch fails
|
||||
- name: Remove a switch
|
||||
vmware_vswitch:
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
validate_certs: no
|
||||
switch: vmswitch_0001
|
||||
state: absent
|
||||
|
@ -71,9 +71,9 @@
|
|||
|
||||
- name: Remove a switch again (check-mode)
|
||||
vmware_vswitch:
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
validate_certs: no
|
||||
switch: vmswitch_0001
|
||||
state: absent
|
||||
|
@ -87,9 +87,9 @@
|
|||
# FIXME: Removing a switch fails
|
||||
- name: Remove a switch again
|
||||
vmware_vswitch:
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
validate_certs: no
|
||||
switch: vmswitch_0001
|
||||
state: absent
|
||||
|
@ -101,9 +101,9 @@
|
|||
- name: Add vswitch to a specific host system
|
||||
vmware_vswitch:
|
||||
validate_certs: False
|
||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
||||
hostname: '{{ esxi1 }}'
|
||||
username: '{{ esxi_user }}'
|
||||
password: '{{ esxi_password }}'
|
||||
switch: vmswitch_0002
|
||||
nics: vnic_1
|
||||
esxi_hostname: guest1
|
||||
|
|
Loading…
Reference in a new issue