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
|
- when: vcsim is not defined
|
||||||
block:
|
import_tasks: init_real_lab.yml
|
||||||
- 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
|
|
||||||
|
|
||||||
|
|
||||||
- when: vcsim is defined
|
- when: vcsim is defined
|
||||||
block:
|
import_tasks: init_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
|
|
||||||
|
|
||||||
- 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"
|
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
datacenter_name: '{{ dc1 }}'
|
datacenter_name: '{{ dc1 }}'
|
||||||
cluster_name: '{{ ccr1 }}'
|
cluster_name: '{{ ccr1 }}'
|
||||||
esxi_hostname: '{{ item }}'
|
esxi_hostname: '{{ item }}'
|
||||||
esxi_username: '{{ hostvars[item].ansible_user }}'
|
esxi_username: '{{ esxi_user }}'
|
||||||
esxi_password: '{{ hostvars[item].ansible_password }}'
|
esxi_password: '{{ esxi_password }}'
|
||||||
state: present
|
state: present
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
with_items: "{{ groups['esxi-lab'] }}"
|
with_items: "{{ esxi_hosts }}"
|
||||||
|
|
||||||
- name: Disable the Maintenance Mode
|
- name: Disable the Maintenance Mode
|
||||||
vmware_maintenancemode:
|
vmware_maintenancemode:
|
||||||
|
@ -20,4 +20,4 @@
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
esxi_hostname: '{{ item }}'
|
esxi_hostname: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
with_items: "{{ groups['esxi-lab'] }}"
|
with_items: "{{ esxi_hosts }}"
|
||||||
|
|
|
@ -6,3 +6,14 @@
|
||||||
datacenter_name: '{{ dc1 }}'
|
datacenter_name: '{{ dc1 }}'
|
||||||
state: present
|
state: present
|
||||||
validate_certs: no
|
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
|
- name: Mount NFS (ds1) datastores to ESXi
|
||||||
vmware_host_datastore:
|
vmware_host_datastore:
|
||||||
hostname: '{{ item }}'
|
hostname: '{{ item }}'
|
||||||
username: '{{ hostvars[item].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[item].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
|
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
||||||
datastore_name: '{{ ds1 }}'
|
datastore_name: '{{ ds1 }}'
|
||||||
datastore_type: '{{ infra.datastores[ds1].type }}'
|
datastore_type: '{{ infra.datastores[ds1].type }}'
|
||||||
nfs_server: '{{ infra.datastores[ds1].server }}'
|
nfs_server: '{{ infra.datastores[ds1].server }}'
|
||||||
nfs_path: '{{ infra.datastores[ds1].path }}'
|
nfs_path: '{{ infra.datastores[ds1].path }}'
|
||||||
nfs_ro: '{{ infra.datastores[ds2].ro }}'
|
nfs_ro: '{{ infra.datastores[ds2].ro }}'
|
||||||
esxi_hostname: '{{ item }}'
|
|
||||||
state: present
|
state: present
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
with_items: "{{ groups['esxi-lab'] }}"
|
with_items: "{{ esxi_hosts }}"
|
||||||
|
|
||||||
- name: Mount NFS (ds2) datastores on the ESXi
|
- name: Mount NFS (ds2) datastores on the ESXi
|
||||||
vmware_host_datastore:
|
vmware_host_datastore:
|
||||||
hostname: '{{ item }}'
|
hostname: '{{ item }}'
|
||||||
username: '{{ hostvars[item].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[item].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
|
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
||||||
datastore_name: '{{ ds2 }}'
|
datastore_name: '{{ ds2 }}'
|
||||||
datastore_type: '{{ infra.datastores[ds2].type }}'
|
datastore_type: '{{ infra.datastores[ds2].type }}'
|
||||||
nfs_server: '{{ infra.datastores[ds2].server }}'
|
nfs_server: '{{ infra.datastores[ds2].server }}'
|
||||||
nfs_path: '{{ infra.datastores[ds2].path }}'
|
nfs_path: '{{ infra.datastores[ds2].path }}'
|
||||||
nfs_ro: '{{ infra.datastores[ds2].ro }}'
|
nfs_ro: '{{ infra.datastores[ds2].ro }}'
|
||||||
esxi_hostname: '{{ item }}'
|
|
||||||
state: present
|
state: present
|
||||||
validate_certs: no
|
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
|
- name: The vcenter needs a bit of time to refresh the DS list
|
||||||
vmware_datastore_facts:
|
vmware_datastore_facts:
|
||||||
|
@ -36,6 +35,7 @@
|
||||||
hostname: '{{ vcenter_hostname }}'
|
hostname: '{{ vcenter_hostname }}'
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
|
cluster: '{{ ccr1 }}'
|
||||||
register: setup_datastore_datatstore_facts
|
register: setup_datastore_datatstore_facts
|
||||||
failed_when: setup_datastore_datatstore_facts.datastores|length != 2
|
failed_when: setup_datastore_datatstore_facts.datastores|length != 2
|
||||||
until: setup_datastore_datatstore_facts is succeeded
|
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
|
- name: Add a VMware vSwitchs
|
||||||
vmware_vswitch:
|
vmware_vswitch:
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
hostname: '{{ hostvars[item].ansible_host }}'
|
hostname: '{{ vcenter_hostname }}'
|
||||||
username: '{{ hostvars[item].ansible_user }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ hostvars[item].ansible_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
|
esxi_hostname: '{{ item }}'
|
||||||
switch_name: "{{ switch1 }}"
|
switch_name: "{{ switch1 }}"
|
||||||
state: present
|
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
|
- name: Create VMs
|
||||||
vmware_guest:
|
vmware_guest:
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
|
@ -17,9 +6,8 @@
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
folder: '{{ f0 }}'
|
folder: '{{ item.folder }}'
|
||||||
cluster: '{{ ccr1 }}'
|
name: '{{ item.name }}'
|
||||||
name: '{{ item }}'
|
|
||||||
state: poweredon
|
state: poweredon
|
||||||
guest_id: debian8_64Guest
|
guest_id: debian8_64Guest
|
||||||
disk:
|
disk:
|
||||||
|
@ -35,4 +23,32 @@
|
||||||
iso_path: "[{{ ds1 }}] Fedora-Workstation-Live-x86_64-29-1.2.iso"
|
iso_path: "[{{ ds1 }}] Fedora-Workstation-Live-x86_64-29-1.2.iso"
|
||||||
networks:
|
networks:
|
||||||
- name: VM Network
|
- 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:
|
vmware_guest:
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
cluster: "{{ ccr1 }}"
|
cluster: "{{ ccr1 }}"
|
||||||
name: "{{ item }}"
|
name: "{{ item.name }}"
|
||||||
force: yes
|
force: yes
|
||||||
state: absent
|
state: absent
|
||||||
with_items: '{{ infra.vm_list }}'
|
with_items: '{{ virtual_machines + virtual_machines_in_cluster }}'
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
- name: Remove the DVSwitch
|
- name: Remove the DVSwitch
|
||||||
|
@ -27,11 +27,12 @@
|
||||||
vmware_vswitch:
|
vmware_vswitch:
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
hostname: '{{ item }}'
|
hostname: '{{ item }}'
|
||||||
username: '{{ hostvars[item].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[item].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
switch_name: "{{ switch1 }}"
|
switch_name: "{{ switch1 }}"
|
||||||
state: absent
|
state: absent
|
||||||
with_items: "{{ groups['esxi-lab'] }}"
|
with_items: "{{ esxi_hosts }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
- name: Remove ESXi Hosts to vCenter
|
- name: Remove ESXi Hosts to vCenter
|
||||||
vmware_host:
|
vmware_host:
|
||||||
|
@ -41,69 +42,34 @@
|
||||||
datacenter_name: '{{ dc1 }}'
|
datacenter_name: '{{ dc1 }}'
|
||||||
cluster_name: ccr1
|
cluster_name: ccr1
|
||||||
esxi_hostname: '{{ item }}'
|
esxi_hostname: '{{ item }}'
|
||||||
esxi_username: '{{ hostvars[item].ansible_user }}'
|
esxi_username: '{{ esxi_user }}'
|
||||||
esxi_password: '{{ hostvars[item].ansible_password }}'
|
esxi_password: '{{ esxi_password }}'
|
||||||
state: absent
|
state: absent
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
with_items: "{{ groups['esxi-lab'] }}"
|
with_items: "{{ esxi_hosts }}"
|
||||||
ignore_errors: yes
|
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)
|
- name: Umount NFS datastores to ESXi (1/2)
|
||||||
vmware_host_datastore:
|
vmware_host_datastore:
|
||||||
hostname: '{{ item }}'
|
hostname: '{{ item }}'
|
||||||
username: '{{ hostvars[item].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[item].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
|
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
||||||
datastore_name: '{{ ds1 }}'
|
datastore_name: '{{ ds1 }}'
|
||||||
esxi_hostname: '{{ item }}'
|
|
||||||
state: absent
|
state: absent
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
with_items: "{{ groups['esxi-lab'] }}"
|
with_items: "{{ esxi_hosts }}"
|
||||||
register: teardown_umount_nfs
|
|
||||||
until: teardown_umount_nfs is succeeded
|
|
||||||
retries: 15
|
|
||||||
delay: 1
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Umount NFS datastores to ESXi (2/2)
|
- name: Umount NFS datastores to ESXi (2/2)
|
||||||
vmware_host_datastore:
|
vmware_host_datastore:
|
||||||
hostname: '{{ item }}'
|
hostname: '{{ item }}'
|
||||||
username: '{{ hostvars[item].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[item].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
|
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
||||||
datastore_name: '{{ ds2 }}'
|
datastore_name: '{{ ds2 }}'
|
||||||
esxi_hostname: '{{ item }}'
|
|
||||||
state: absent
|
state: absent
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
with_items: "{{ groups['esxi-lab'] }}"
|
with_items: "{{ esxi_hosts }}"
|
||||||
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 }}"
|
|
||||||
|
|
||||||
- name: Remove the datacenter
|
- name: Remove the datacenter
|
||||||
vmware_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
|
# Copyright (c) 2018, Ansible Project
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
# Testcase 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:
|
- import_role:
|
||||||
name: prepare_vmware_tests
|
name: prepare_vmware_tests
|
||||||
|
@ -29,11 +15,11 @@
|
||||||
- name: get list of facts about datastores from the ESXi
|
- name: get list of facts about datastores from the ESXi
|
||||||
vmware_datastore_facts:
|
vmware_datastore_facts:
|
||||||
validate_certs: False
|
validate_certs: False
|
||||||
hostname: '{{ hostvars[item].ansible_host }}'
|
hostname: '{{ item }}'
|
||||||
username: '{{ hostvars[item].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[item].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
register: facts_from_esxi
|
register: facts_from_esxi
|
||||||
with_items: "{{ groups['esxi-lab'] }}"
|
with_items: "{{ esxi_hosts }}"
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "facts_from_esxi.results[0].datastores|length == 2"
|
- "facts_from_esxi.results[0].datastores|length == 2"
|
||||||
|
@ -48,7 +34,6 @@
|
||||||
gather_nfs_mount_info: true
|
gather_nfs_mount_info: true
|
||||||
register: facts_from_vcenter_with_dc_filter
|
register: facts_from_vcenter_with_dc_filter
|
||||||
|
|
||||||
# Depends-On: https://github.com/ansible/ansible/pull/54879
|
|
||||||
- when: vcsim is not defined
|
- when: vcsim is not defined
|
||||||
block:
|
block:
|
||||||
- name: get list of facts about datastores
|
- name: get list of facts about datastores
|
||||||
|
|
|
@ -19,9 +19,7 @@
|
||||||
cluster_name: '{{ ccr1 }}'
|
cluster_name: '{{ ccr1 }}'
|
||||||
datacenter_name: '{{ dc1 }}'
|
datacenter_name: '{{ dc1 }}'
|
||||||
group_name: TEST_VM_01
|
group_name: TEST_VM_01
|
||||||
vms:
|
vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
|
||||||
- DC0_C0_RP0_VM0
|
|
||||||
- DC0_C0_RP0_VM1
|
|
||||||
state: present
|
state: present
|
||||||
register: drs_vm_group_01_results
|
register: drs_vm_group_01_results
|
||||||
|
|
||||||
|
@ -32,7 +30,7 @@
|
||||||
that:
|
that:
|
||||||
- "drs_vm_group_01_results.changed"
|
- "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:
|
block:
|
||||||
- name: Create DRS Host group
|
- name: Create DRS Host group
|
||||||
vmware_drs_group:
|
vmware_drs_group:
|
||||||
|
@ -43,7 +41,7 @@
|
||||||
cluster_name: '{{ ccr1 }}'
|
cluster_name: '{{ ccr1 }}'
|
||||||
datacenter_name: '{{ dc1 }}'
|
datacenter_name: '{{ dc1 }}'
|
||||||
group_name: TEST_HOST_01
|
group_name: TEST_HOST_01
|
||||||
hosts: "{{ groups['esxi-lab'][0:3] }}"
|
hosts: "{{ esxi_hosts[0:3] }}"
|
||||||
state: present
|
state: present
|
||||||
register: drs_host_group_01_results
|
register: drs_host_group_01_results
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
- import_role:
|
- import_role:
|
||||||
name: prepare_vmware_tests
|
name: prepare_vmware_tests
|
||||||
|
|
||||||
- when: vcsim is defined or groups['esxi-lab'] | length >= 3
|
- when: vcsim is defined or esxi_hosts | length >= 3
|
||||||
block:
|
block:
|
||||||
- name: Gather DRS group facts from given cluster
|
- name: Gather DRS group facts from given cluster
|
||||||
vmware_drs_group_facts:
|
vmware_drs_group_facts:
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
|
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- when: vcsim is defined or groups['esxi-lab'] | length >= 3
|
- import_role:
|
||||||
|
name: prepare_vmware_tests
|
||||||
|
|
||||||
|
- when: vcsim is defined or esxi_hosts | length >= 3
|
||||||
block:
|
block:
|
||||||
- import_role:
|
- import_role:
|
||||||
name: prepare_vmware_tests
|
name: prepare_vmware_tests
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
# 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
|
||||||
|
|
||||||
- when: vcsim is not defined
|
- when: vcsim is not defined
|
||||||
block:
|
block:
|
||||||
- &dvs_facts
|
- &dvs_facts
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
- import_role:
|
- import_role:
|
||||||
name: prepare_vmware_tests
|
name: prepare_vmware_tests
|
||||||
|
vars:
|
||||||
|
setup_datacenter: true
|
||||||
|
|
||||||
- &dvs_data
|
- &dvs_data
|
||||||
name: Add distributed vSwitch
|
name: Add distributed vSwitch
|
||||||
|
@ -26,13 +28,26 @@
|
||||||
that:
|
that:
|
||||||
- dvs_result_0001.changed
|
- 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
|
- name: Add distributed vSwitch using folder
|
||||||
vmware_dvswitch:
|
vmware_dvswitch:
|
||||||
validate_certs: False
|
validate_certs: False
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
folder: "/F0/{{ dc1 }}/network/F0"
|
folder: "{{ network_folder_result.result.path }}"
|
||||||
state: present
|
state: present
|
||||||
switch_name: dvswitch_0002
|
switch_name: dvswitch_0002
|
||||||
mtu: 9000
|
mtu: 9000
|
||||||
|
|
|
@ -60,15 +60,15 @@
|
||||||
that:
|
that:
|
||||||
- pvlans_result is changed
|
- pvlans_result is changed
|
||||||
|
|
||||||
- <<: *pv_data
|
- when: vcsim is not defined
|
||||||
name: Configure PVLANs in check mode
|
block:
|
||||||
register: pvlans_result_check_mode
|
- <<: *pv_data
|
||||||
check_mode: yes
|
name: Configure PVLANs in check mode
|
||||||
|
register: pvlans_result_check_mode
|
||||||
- debug:
|
check_mode: yes
|
||||||
var: pvlans_result_check_mode
|
- debug:
|
||||||
|
var: pvlans_result_check_mode
|
||||||
- name: ensure pvlans were configured
|
- name: ensure pvlans were not changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- pvlans_result_check_mode is changed
|
- not (pvlans_result_check_mode is changed)
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
|
|
||||||
- <<: *uplink_data
|
- <<: *uplink_data
|
||||||
name: Configure Uplink portgroup
|
name: Configure Uplink portgroup
|
||||||
|
register: uplink_pg_result
|
||||||
check_mode: no
|
check_mode: no
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ 'newvm_' + item|basename }}"
|
name: "{{ 'newvm_' + item.name }}"
|
||||||
guest_id: centos64Guest
|
guest_id: centos64Guest
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
hardware:
|
hardware:
|
||||||
num_cpus: 4
|
num_cpus: 4
|
||||||
boot_firmware: "bios"
|
boot_firmware: "bios"
|
||||||
|
@ -20,8 +20,8 @@
|
||||||
type: thin
|
type: thin
|
||||||
autoselect_datastore: True
|
autoselect_datastore: True
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ item.folder }}"
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: clone_d1_c1_f0
|
register: clone_d1_c1_f0
|
||||||
|
|
||||||
- debug: var=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]"
|
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]"
|
||||||
|
|
||||||
# VCSIM does not recognizes existing VMs boot firmware
|
# VCSIM does not recognizes existing VMs boot firmware
|
||||||
#- name: create new VMs again with boot_firmware as 'bios'
|
- when: vcsim is not defined
|
||||||
# vmware_guest:
|
block:
|
||||||
# validate_certs: False
|
- name: create new VMs again with boot_firmware as 'bios'
|
||||||
# hostname: "{{ vcenter_hostname }}"
|
vmware_guest:
|
||||||
# username: "{{ vcenter_username }}"
|
validate_certs: False
|
||||||
# password: "{{ vcenter_password }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
# name: "{{ 'newvm_' + item|basename }}"
|
username: "{{ vcenter_username }}"
|
||||||
# guest_id: centos64Guest
|
password: "{{ vcenter_password }}"
|
||||||
# datacenter: "{{ (item|basename).split('_')[0] }}"
|
name: "{{ 'newvm_' + item.name }}"
|
||||||
# hardware:
|
guest_id: centos64Guest
|
||||||
# num_cpus: 4
|
datacenter: "{{ dc1 }}"
|
||||||
# boot_firmware: "bios"
|
hardware:
|
||||||
# memory_mb: 512
|
num_cpus: 4
|
||||||
# disk:
|
boot_firmware: "bios"
|
||||||
# - size: 1gb
|
memory_mb: 512
|
||||||
# type: thin
|
disk:
|
||||||
# autoselect_datastore: True
|
- size: 1gb
|
||||||
# state: poweredoff
|
type: thin
|
||||||
# folder: "{{ item|dirname }}"
|
autoselect_datastore: True
|
||||||
# with_items: "{{ vmlist['json'] }}"
|
state: poweredoff
|
||||||
# register: clone_d1_c1_f0
|
folder: "{{ item.folder }}"
|
||||||
|
with_items: "{{ virtual_machines }}"
|
||||||
#- debug: var=clone_d1_c1_f0
|
register: clone_d1_c1_f0
|
||||||
|
- debug: var=clone_d1_c1_f0
|
||||||
#- name: assert that changes were not made
|
- name: assert that changes were not made
|
||||||
# assert:
|
assert:
|
||||||
# that:
|
that:
|
||||||
# - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
||||||
|
|
||||||
- name: create new VMs with boot_firmware as 'efi'
|
- name: create new VMs with boot_firmware as 'efi'
|
||||||
vmware_guest:
|
vmware_guest:
|
||||||
|
@ -67,9 +67,9 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ 'newvm_efi_' + item|basename }}"
|
name: "{{ 'newvm_efi_' + item.name }}"
|
||||||
guest_id: centos64Guest
|
guest_id: centos64Guest
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
hardware:
|
hardware:
|
||||||
num_cpus: 4
|
num_cpus: 4
|
||||||
boot_firmware: "efi"
|
boot_firmware: "efi"
|
||||||
|
@ -79,8 +79,8 @@
|
||||||
type: thin
|
type: thin
|
||||||
autoselect_datastore: True
|
autoselect_datastore: True
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ item.folder }}"
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: clone_d1_c1_f0
|
register: clone_d1_c1_f0
|
||||||
|
|
||||||
- debug: var=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]"
|
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]"
|
||||||
|
|
||||||
# VCSIM does not recognizes existing VMs boot firmware
|
# VCSIM does not recognizes existing VMs boot firmware
|
||||||
#- name: create new VMs again with boot_firmware as 'efi'
|
- when: vcsim is not defined
|
||||||
# vmware_guest:
|
block:
|
||||||
# validate_certs: False
|
- name: create new VMs again with boot_firmware as 'efi'
|
||||||
# hostname: "{{ vcenter_hostname }}"
|
vmware_guest:
|
||||||
# username: "{{ vcenter_username }}"
|
validate_certs: False
|
||||||
# password: "{{ vcenter_password }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
# name: "{{ 'newvm_efi_' + item|basename }}"
|
username: "{{ vcenter_username }}"
|
||||||
# guest_id: centos64Guest
|
password: "{{ vcenter_password }}"
|
||||||
# datacenter: "{{ (item|basename).split('_')[0] }}"
|
name: "{{ 'newvm_efi_' + item.name }}"
|
||||||
# hardware:
|
guest_id: centos64Guest
|
||||||
# num_cpus: 4
|
datacenter: "{{ dc1 }}"
|
||||||
# boot_firmware: "efi"
|
hardware:
|
||||||
# memory_mb: 512
|
num_cpus: 4
|
||||||
# disk:
|
boot_firmware: "efi"
|
||||||
# - size: 1gb
|
memory_mb: 512
|
||||||
# type: thin
|
disk:
|
||||||
# autoselect_datastore: True
|
- size: 1gb
|
||||||
# state: poweredoff
|
type: thin
|
||||||
# folder: "{{ item|dirname }}"
|
autoselect_datastore: True
|
||||||
# with_items: "{{ vmlist['json'] }}"
|
state: poweredoff
|
||||||
# register: clone_d1_c1_f0
|
folder: "{{ item.folder }}"
|
||||||
|
with_items: "{{ virtual_machines }}"
|
||||||
#- debug: var=clone_d1_c1_f0
|
register: clone_d1_c1_f0
|
||||||
|
- debug: var=clone_d1_c1_f0
|
||||||
#- name: assert that changes were not made
|
- name: assert that changes were not made
|
||||||
# assert:
|
assert:
|
||||||
# that:
|
that:
|
||||||
# - "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
state: "{{ item }}"
|
state: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "check_mode_state.results|map(attribute='changed')|unique|list == [true]"
|
- "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
|
- name: Perform all operation on non-existent VM in check mode
|
||||||
vmware_guest:
|
vmware_guest:
|
||||||
|
|
|
@ -2,51 +2,19 @@
|
||||||
# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
|
# 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)
|
# 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
|
- name: clone vm from template and customize GOS
|
||||||
vmware_guest:
|
vmware_guest:
|
||||||
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 }}"
|
||||||
name: "{{ 'net_customize_' + item|basename }}"
|
name: "{{ 'net_customize_' + item.name }}"
|
||||||
template: "{{ item|basename }}"
|
template: "{{ item.name }}"
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ item.folder }}"
|
||||||
convert: thin
|
convert: thin
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: clone_customize
|
register: clone_customize
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
|
@ -60,16 +28,16 @@
|
||||||
- name: clone vm from template and customize GOS again
|
- name: clone vm from template and customize GOS again
|
||||||
vmware_guest:
|
vmware_guest:
|
||||||
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 }}"
|
||||||
name: "{{ 'net_customize_' + item|basename }}"
|
name: "{{ 'net_customize_' + item.name }}"
|
||||||
template: "{{ item|basename }}"
|
template: "{{ item.name }}"
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ item.folder }}"
|
||||||
convert: thin
|
convert: thin
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: clone_customize_again
|
register: clone_customize_again
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ 'thin_' + item|basename }}"
|
name: "{{ 'thin_' + item.name }}"
|
||||||
template: "{{ item|basename }}"
|
template: "{{ item.name }}"
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ item.folder }}"
|
||||||
convert: thin
|
convert: thin
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: clone_thin
|
register: clone_thin
|
||||||
|
|
||||||
- debug: var=clone_thin
|
- debug: var=clone_thin
|
||||||
|
@ -30,13 +30,13 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ 'thick_' + item|basename }}"
|
name: "{{ 'thick_' + item.name }}"
|
||||||
template: "{{ item|basename }}"
|
template: "{{ item.name }}"
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ item.folder }}"
|
||||||
convert: thick
|
convert: thick
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: clone_thick
|
register: clone_thick
|
||||||
|
|
||||||
- debug: var=clone_thick
|
- debug: var=clone_thick
|
||||||
|
@ -52,13 +52,13 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ 'eagerzeroedthick_' + item|basename }}"
|
name: "{{ 'eagerzeroedthick_' + item.name }}"
|
||||||
template: "{{ item|basename }}"
|
template: "{{ item.name }}"
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ item.folder }}"
|
||||||
convert: eagerzeroedthick
|
convert: eagerzeroedthick
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: clone_eagerzeroedthick
|
register: clone_eagerzeroedthick
|
||||||
|
|
||||||
- debug: var=clone_eagerzeroedthick
|
- debug: var=clone_eagerzeroedthick
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: disk_mode_d1_c1_f0
|
name: disk_mode_d1_c1_f0
|
||||||
guest_id: centos64Guest
|
guest_id: centos64Guest
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
hardware:
|
hardware:
|
||||||
num_cpus: 1
|
num_cpus: 1
|
||||||
memory_mb: 512
|
memory_mb: 512
|
||||||
|
|
|
@ -2,47 +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)
|
||||||
|
|
||||||
- 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
|
- name: create new linked clone without specifying snapshot_src
|
||||||
vmware_guest:
|
vmware_guest:
|
||||||
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 }}"
|
||||||
name: "{{ 'new_vm_' + item|basename }}"
|
name: "{{ 'new_vm_' + item.name }}"
|
||||||
template: "{{ item|basename }}"
|
template: "{{ item.name }}"
|
||||||
guest_id: centos64Guest
|
guest_id: centos64Guest
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ f0 }}"
|
||||||
linked_clone: True
|
linked_clone: True
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: linked_clone_d1_c1_f0
|
register: linked_clone_d1_c1_f0
|
||||||
ignore_errors: True
|
ignore_errors: True
|
||||||
|
|
||||||
|
@ -56,16 +28,15 @@
|
||||||
- name: create new linked clone without specifying linked_clone
|
- name: create new linked clone without specifying linked_clone
|
||||||
vmware_guest:
|
vmware_guest:
|
||||||
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 }}"
|
||||||
name: "{{ 'new_vm_' + item|basename }}"
|
name: "{{ 'new_vm_' + item.name }}"
|
||||||
template: "{{ item|basename }}"
|
|
||||||
guest_id: centos64Guest
|
guest_id: centos64Guest
|
||||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ f0 }}"
|
||||||
snapshot_src: "snap_shot1"
|
snapshot_src: "snap_shot1"
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: linked_clone_d1_c1_f0
|
register: linked_clone_d1_c1_f0
|
||||||
ignore_errors: True
|
ignore_errors: True
|
||||||
|
|
||||||
|
|
|
@ -5,24 +5,44 @@
|
||||||
- import_role:
|
- import_role:
|
||||||
name: prepare_vmware_tests
|
name: prepare_vmware_tests
|
||||||
vars:
|
vars:
|
||||||
|
setup_datacenter: true
|
||||||
setup_attach_host: true
|
setup_attach_host: true
|
||||||
setup_datastore: true
|
setup_datastore: true
|
||||||
setup_virtualmachines: true
|
setup_virtualmachines: true
|
||||||
|
setup_resource_pool: true
|
||||||
|
|
||||||
|
- block:
|
||||||
- include: poweroff_d1_c1_f0.yml
|
- include: poweroff_d1_c1_f0.yml
|
||||||
- include: poweroff_d1_c1_f1.yml
|
- include: poweroff_d1_c1_f1.yml
|
||||||
- include: check_mode.yml
|
- include: check_mode.yml
|
||||||
- include: clone_d1_c1_f0.yml
|
- include: clone_d1_c1_f0.yml
|
||||||
- include: create_d1_c1_f0.yml
|
- include: create_d1_c1_f0.yml
|
||||||
- include: cdrom_d1_c1_f0.yml
|
- include: cdrom_d1_c1_f0.yml
|
||||||
- include: create_rp_d1_c1_f0.yml
|
- include: create_rp_d1_c1_f0.yml
|
||||||
- include: create_guest_invalid_d1_c1_f0.yml
|
- include: create_guest_invalid_d1_c1_f0.yml
|
||||||
- include: mac_address_d1_c1_f0.yml
|
- include: mac_address_d1_c1_f0.yml
|
||||||
- include: disk_type_d1_c1_f0.yml
|
- include: disk_type_d1_c1_f0.yml
|
||||||
- include: create_nw_d1_c1_f0.yml
|
- include: create_nw_d1_c1_f0.yml
|
||||||
- include: delete_vm.yml
|
- include: delete_vm.yml
|
||||||
- include: non_existent_vm_ops.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:
|
- import_role:
|
||||||
name: prepare_vmware_tests
|
name: prepare_vmware_tests
|
||||||
|
@ -31,17 +51,66 @@
|
||||||
setup_datastore: true
|
setup_datastore: true
|
||||||
setup_virtualmachines: true
|
setup_virtualmachines: true
|
||||||
|
|
||||||
- include: network_negative_test.yml
|
- block:
|
||||||
# VCSIM does not return list of portgroups for dvswitch so commenting following TC
|
- include: network_negative_test.yml
|
||||||
#- include: network_with_portgroup.yml
|
# VCSIM does not return list of portgroups for dvswitch so commenting following TC
|
||||||
# Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test
|
#- include: network_with_portgroup.yml
|
||||||
# - include: network_with_dvpg.yml
|
# Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test
|
||||||
#- include: template_d1_c1_f0.yml
|
# - include: network_with_dvpg.yml
|
||||||
- include: vapp_d1_c1_f0.yml
|
#- include: template_d1_c1_f0.yml
|
||||||
- include: disk_size_d1_c1_f0.yml
|
- include: vapp_d1_c1_f0.yml
|
||||||
- include: network_with_device.yml
|
- include: disk_size_d1_c1_f0.yml
|
||||||
- include: disk_mode_d1_c1_f0.yml
|
- include: network_with_device.yml
|
||||||
- include: linked_clone_d1_c1_f0.yml
|
- include: disk_mode_d1_c1_f0.yml
|
||||||
- include: boot_firmware_d1_c1_f0.yml
|
- include: linked_clone_d1_c1_f0.yml
|
||||||
- include: clone_with_convert.yml
|
always:
|
||||||
- include: clone_customize_guest_test.yml
|
- 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 }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ item }}"
|
name: "{{ item.name }}"
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
with_items: "{{ infra.vm_list }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: poweroff_d1_c1_f0
|
register: poweroff_d1_c1_f0
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ item }}"
|
name: "{{ item.name }}"
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
folder: "DC1/C1/F1"
|
folder: "{{ item.folder }}"
|
||||||
with_items: "{{ infra.vm_list }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: poweroff_d1_c1_f1
|
register: poweroff_d1_c1_f1
|
||||||
|
|
||||||
- debug: var=poweroff_d1_c1_f1
|
- debug: var=poweroff_d1_c1_f1
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
hostname: '{{ vcenter_hostname }}'
|
hostname: '{{ vcenter_hostname }}'
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
register: vm1_facts
|
register: vm1_facts
|
||||||
- debug: var=vm1_facts
|
- debug: var=vm1_facts
|
||||||
- name: assert that values are set
|
- name: assert that values are set
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
hostname: '{{ vcenter_hostname }}'
|
hostname: '{{ vcenter_hostname }}'
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: vm1_facts
|
register: vm1_facts
|
||||||
- debug: var=vm1_facts
|
- debug: var=vm1_facts
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
folder: "{{ f0 }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: present
|
state: present
|
||||||
attributes:
|
attributes:
|
||||||
- name: 'sample_1'
|
- name: 'sample_1'
|
||||||
|
@ -42,8 +42,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
folder: "{{ f0 }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: present
|
state: present
|
||||||
attributes:
|
attributes:
|
||||||
- name: 'sample_1'
|
- name: 'sample_1'
|
||||||
|
@ -67,8 +67,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
folder: "{{ f0 }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: absent
|
state: absent
|
||||||
attributes:
|
attributes:
|
||||||
- name: 'sample_1'
|
- name: 'sample_1'
|
||||||
|
@ -94,8 +94,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
folder: "{{ f0 }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: absent
|
state: absent
|
||||||
attributes:
|
attributes:
|
||||||
- name: 'sample_1'
|
- name: 'sample_1'
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
hostname: '{{ vcenter_hostname }}'
|
hostname: '{{ vcenter_hostname }}'
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
datacenter: '{{ dc1 }}'
|
datacenter: '{{ dc1 }}'
|
||||||
register: disk_facts
|
register: disk_facts
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
folder: "{{ f0 }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
register: guest_facts_0001
|
register: guest_facts_0001
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
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_product_uuid'] is defined"
|
||||||
- "guest_facts_0001['instance']['hw_cores_per_socket'] is defined"
|
- "guest_facts_0001['instance']['hw_cores_per_socket'] is defined"
|
||||||
- "guest_facts_0001['instance']['hw_datastores'] is defined"
|
- "guest_facts_0001['instance']['hw_datastores'] is defined"
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
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'] is defined"
|
||||||
- "guest_facts_0002['instance']['hw_product_uuid'] == vm1_uuid"
|
- "guest_facts_0002['instance']['hw_product_uuid'] == vm1_uuid"
|
||||||
- "guest_facts_0002['instance']['hw_cores_per_socket'] is defined"
|
- "guest_facts_0002['instance']['hw_cores_per_socket'] is defined"
|
||||||
|
@ -124,8 +124,8 @@
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
folder: "{{ f0 }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: present
|
state: present
|
||||||
snapshot_name: snap1
|
snapshot_name: snap1
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
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'] is defined"
|
||||||
- "guest_facts_0005['instance']['hw_product_uuid'] == vm1_uuid"
|
- "guest_facts_0005['instance']['hw_product_uuid'] == vm1_uuid"
|
||||||
- "guest_facts_0005['instance']['hw_cores_per_socket'] is defined"
|
- "guest_facts_0005['instance']['hw_cores_per_socket'] is defined"
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ item }}"
|
name: "{{ item.name }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
with_items: "{{ infra.vm_list }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: folders
|
register: folders
|
||||||
|
|
||||||
- debug: var=item
|
- debug: var=item
|
||||||
|
@ -38,8 +38,8 @@
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
folder: "{{ f0 }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
register: guest_facts_0001
|
register: guest_facts_0001
|
||||||
|
|
||||||
- debug: var=guest_facts_0001
|
- debug: var=guest_facts_0001
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
folder_type: vm
|
folder_type: vm
|
||||||
state: present
|
state: present
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
|
register: dest_folder
|
||||||
|
|
||||||
# Testcase 0001: Move vm and get changed status
|
# Testcase 0001: Move vm and get changed status
|
||||||
- name: Move VM (Changed)
|
- name: Move VM (Changed)
|
||||||
|
@ -27,8 +28,9 @@
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
dest_folder: '/F0/DC0/vm/f1'
|
# Depends-On: https://github.com/ansible/ansible/pull/55237
|
||||||
|
dest_folder: "{{ dest_folder.result.path }}"
|
||||||
register: vm_facts_0001
|
register: vm_facts_0001
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,8 +42,8 @@
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
dest_folder: 'F0/DC0/vm/f1'
|
dest_folder: "{{ dest_folder.result.path }}"
|
||||||
register: vm_facts_0002
|
register: vm_facts_0002
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: powered-off
|
state: powered-off
|
||||||
folder: '/dc1/vm/f0'
|
|
||||||
register: poweroff_d1_c1_f0
|
register: poweroff_d1_c1_f0
|
||||||
|
|
||||||
- debug: var=poweroff_d1_c1_f0
|
- debug: var=poweroff_d1_c1_f0
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
name: "{{ item|basename }}"
|
name: "{{ item|basename }}"
|
||||||
state: powered-off
|
state: powered-off
|
||||||
folder: "{{ item|dirname }}"
|
folder: "{{ item|dirname }}"
|
||||||
with_items: "{{ vmlist['json'] }}"
|
with_items: "{{ virtual_machines }}"
|
||||||
register: poweroff_d1_c1_f0
|
register: poweroff_d1_c1_f0
|
||||||
|
|
||||||
- debug: var=poweroff_d1_c1_f0
|
- debug: var=poweroff_d1_c1_f0
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: absent
|
state: absent
|
||||||
snapshot_name: snap_a
|
snapshot_name: snap_a
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: present
|
state: present
|
||||||
snapshot_name: "snap_{{item}}"
|
snapshot_name: "snap_{{item}}"
|
||||||
description: "snap named {{item}}"
|
description: "snap named {{item}}"
|
||||||
|
@ -45,8 +45,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: present
|
state: present
|
||||||
snapshot_name: snap_a
|
snapshot_name: snap_a
|
||||||
new_snapshot_name: snap_c
|
new_snapshot_name: snap_c
|
||||||
|
@ -59,8 +59,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: present
|
state: present
|
||||||
snapshot_name: snap_a
|
snapshot_name: snap_a
|
||||||
description: "snap named a"
|
description: "snap named a"
|
||||||
|
@ -73,8 +73,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: present
|
state: present
|
||||||
snapshot_name: snap_c
|
snapshot_name: snap_c
|
||||||
new_description: "renamed to snap_c from snap_a"
|
new_description: "renamed to snap_c from snap_a"
|
||||||
|
@ -89,8 +89,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: absent
|
state: absent
|
||||||
snapshot_name: snap_b
|
snapshot_name: snap_b
|
||||||
remove_children: True
|
remove_children: True
|
||||||
|
@ -103,8 +103,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: remove_all
|
state: remove_all
|
||||||
|
|
||||||
# Test0008: Create snap_a again and revert to it
|
# Test0008: Create snap_a again and revert to it
|
||||||
|
@ -115,8 +115,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: present
|
state: present
|
||||||
snapshot_name: snap_a
|
snapshot_name: snap_a
|
||||||
description: "snap named a"
|
description: "snap named a"
|
||||||
|
@ -130,8 +130,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: revert
|
state: revert
|
||||||
snapshot_name: snap_a
|
snapshot_name: snap_a
|
||||||
|
|
||||||
|
@ -143,8 +143,8 @@
|
||||||
username: '{{ vcenter_username }}'
|
username: '{{ vcenter_username }}'
|
||||||
password: '{{ vcenter_password }}'
|
password: '{{ vcenter_password }}'
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
state: present
|
state: present
|
||||||
snapshot_name: snap_a
|
snapshot_name: snap_a
|
||||||
description: "snap named a"
|
description: "snap named a"
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
folder: "{{ f0 }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
register: vm_snapshot_facts
|
register: vm_snapshot_facts
|
||||||
|
|
||||||
- debug: var=vm_snapshot_facts
|
- debug: var=vm_snapshot_facts
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "{{ infra.vm_list[0] }}"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
|
folder: "{{ virtual_machines[0].folder }}"
|
||||||
datacenter: "{{ dc1 }}"
|
datacenter: "{{ dc1 }}"
|
||||||
state: poweredon
|
state: poweredon
|
||||||
folder: "{{ f0 }}"
|
|
||||||
|
|
||||||
# FixMe: govcsim does not support VMware tools status reporting
|
# FixMe: govcsim does not support VMware tools status reporting
|
||||||
## Testcase 0001: Wait for VMware tools to become available by name
|
## Testcase 0001: Wait for VMware tools to become available by name
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
# Testcase: Add Host
|
# Testcase: Add Host
|
||||||
- when: vcsim is not defined
|
- when: vcsim is not defined
|
||||||
block:
|
block:
|
||||||
|
- import_role:
|
||||||
|
name: prepare_vmware_tests
|
||||||
|
vars:
|
||||||
|
setup_attach_host: true
|
||||||
|
|
||||||
- name: Add first ESXi Host to vCenter
|
- name: Add first ESXi Host to vCenter
|
||||||
vmware_host:
|
vmware_host:
|
||||||
|
@ -13,8 +17,8 @@
|
||||||
datacenter_name: '{{ dc1 }}'
|
datacenter_name: '{{ dc1 }}'
|
||||||
cluster_name: '{{ ccr1 }}'
|
cluster_name: '{{ ccr1 }}'
|
||||||
esxi_hostname: '{{ esxi1 }}'
|
esxi_hostname: '{{ esxi1 }}'
|
||||||
esxi_username: '{{ hostvars[esxi1].ansible_user }}'
|
esxi_username: '{{ esxi_user }}'
|
||||||
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
|
esxi_password: '{{ esxi_password }}'
|
||||||
state: present
|
state: present
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
register: readd_host_result
|
register: readd_host_result
|
||||||
|
@ -27,8 +31,8 @@
|
||||||
datacenter_name: '{{ dc1 }}'
|
datacenter_name: '{{ dc1 }}'
|
||||||
cluster_name: '{{ ccr1 }}'
|
cluster_name: '{{ ccr1 }}'
|
||||||
esxi_hostname: '{{ esxi1 }}'
|
esxi_hostname: '{{ esxi1 }}'
|
||||||
esxi_username: '{{ hostvars[esxi1].ansible_user }}'
|
esxi_username: '{{ esxi_user }}'
|
||||||
esxi_password: '{{ hostvars[esxi1].ansible_password }}'
|
esxi_password: '{{ esxi_password }}'
|
||||||
state: present
|
state: present
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
register: readd_host_result
|
register: readd_host_result
|
||||||
|
@ -45,11 +49,10 @@
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
esxi_hostname: '{{ esxi2 }}'
|
esxi_hostname: '{{ esxi2 }}'
|
||||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
esxi_username: '{{ esxi_user }}'
|
||||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
esxi_password: '{{ esxi_password }}'
|
||||||
datacenter_name: "{{ dc1 }}"
|
datacenter_name: "{{ dc1 }}"
|
||||||
cluster_name: "{{ ccr1 }}"
|
cluster_name: "{{ ccr1 }}"
|
||||||
fetch_ssl_thumbprint: False
|
|
||||||
state: add_or_reconnect
|
state: add_or_reconnect
|
||||||
register: add_or_reconnect_host_result
|
register: add_or_reconnect_host_result
|
||||||
- name: ensure host system is present
|
- name: ensure host system is present
|
||||||
|
@ -119,8 +122,8 @@
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
esxi_hostname: '{{ esxi2 }}'
|
esxi_hostname: '{{ esxi2 }}'
|
||||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
esxi_username: '{{ esxi_user }}'
|
||||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
esxi_password: '{{ esxi_password }}'
|
||||||
datacenter_name: "{{ dc1 }}"
|
datacenter_name: "{{ dc1 }}"
|
||||||
folder_name: "/{{ dc1 }}/host/Staging"
|
folder_name: "/{{ dc1 }}/host/Staging"
|
||||||
state: present
|
state: present
|
||||||
|
@ -139,8 +142,8 @@
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
esxi_hostname: '{{ esxi2 }}'
|
esxi_hostname: '{{ esxi2 }}'
|
||||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
esxi_username: '{{ esxi_user }}'
|
||||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
esxi_password: '{{ esxi_password }}'
|
||||||
datacenter_name: "{{ dc1 }}"
|
datacenter_name: "{{ dc1 }}"
|
||||||
folder_name: "/{{ dc1 }}/host/Staging"
|
folder_name: "/{{ dc1 }}/host/Staging"
|
||||||
state: present
|
state: present
|
||||||
|
@ -158,8 +161,8 @@
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
esxi_hostname: '{{ esxi2 }}'
|
esxi_hostname: '{{ esxi2 }}'
|
||||||
esxi_username: '{{ hostvars[esxi2].ansible_user }}'
|
esxi_username: '{{ esxi_user }}'
|
||||||
esxi_password: '{{ hostvars[esxi2].ansible_password }}'
|
esxi_password: '{{ esxi_password }}'
|
||||||
datacenter_name: "{{ dc1 }}"
|
datacenter_name: "{{ dc1 }}"
|
||||||
cluster_name: "{{ ccr1 }}"
|
cluster_name: "{{ ccr1 }}"
|
||||||
state: reconnect
|
state: reconnect
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
vmware_host_facts:
|
vmware_host_facts:
|
||||||
validate_certs: False
|
validate_certs: False
|
||||||
hostname: '{{ esxi1 }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
register: facts
|
register: facts
|
||||||
- debug: var=facts
|
- debug: var=facts
|
||||||
- name: verify some data,like ansible_processor
|
- name: verify some data,like ansible_processor
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
- import_role:
|
- import_role:
|
||||||
name: prepare_vmware_tests
|
name: prepare_vmware_tests
|
||||||
vars:
|
vars:
|
||||||
setup_esxi_instance: true
|
setup_attach_host: true
|
||||||
|
|
||||||
- name: Gather firewall facts for a given ESXi
|
- name: Gather firewall facts for a given ESXi
|
||||||
vmware_host_firewall_facts:
|
vmware_host_firewall_facts:
|
||||||
|
|
|
@ -73,5 +73,5 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- not (all_hosts_result is changed)
|
- not (all_hosts_result is changed)
|
||||||
- "all_hosts_result.result['{{ esxi1 }}']current_state == 'balanced'"
|
- "all_hosts_result.result['{{ esxi1 }}'].current_state == 'balanced'"
|
||||||
- "all_hosts_result.result['{{ esxi2 }}']current_state == 'balanced'"
|
- "all_hosts_result.result['{{ esxi2 }}'].current_state == 'balanced'"
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
# SNMP works only with standalone ESXi server
|
# SNMP works only with standalone ESXi server
|
||||||
- name: Enable and configure SNMP community in check mode
|
- name: Enable and configure SNMP community in check mode
|
||||||
vmware_host_snmp:
|
vmware_host_snmp:
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
community: [ test ]
|
community: [ test ]
|
||||||
state: enabled
|
state: enabled
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
|
@ -28,9 +28,9 @@
|
||||||
|
|
||||||
- name: Enable and configure SNMP community
|
- name: Enable and configure SNMP community
|
||||||
vmware_host_snmp:
|
vmware_host_snmp:
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
community: [ test ]
|
community: [ test ]
|
||||||
state: enabled
|
state: enabled
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
|
@ -43,9 +43,9 @@
|
||||||
|
|
||||||
- name: Disable SNMP
|
- name: Disable SNMP
|
||||||
vmware_host_snmp:
|
vmware_host_snmp:
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
state: disabled
|
state: disabled
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
register: snmp_disabled
|
register: snmp_disabled
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
- &user_fact_data
|
- &user_fact_data
|
||||||
name: Gather facts about users
|
name: Gather facts about users
|
||||||
vmware_local_user_facts:
|
vmware_local_user_facts:
|
||||||
hostname: "{{ hostvars[esxi1].ansible_host }}"
|
hostname: "{{ esxi1 }}"
|
||||||
username: "{{ hostvars[esxi1].ansible_user }}"
|
username: "{{ esxi_user }}"
|
||||||
password: "{{ hostvars[esxi1].ansible_password }}"
|
password: "{{ esxi_password }}"
|
||||||
validate_certs: False
|
validate_certs: False
|
||||||
register: all_user_facts
|
register: all_user_facts
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,13 @@
|
||||||
|
|
||||||
- when: vcsim is not defined
|
- when: vcsim is not defined
|
||||||
block:
|
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
|
- name: Create portgroup without Portgroup and vSwitch
|
||||||
vmware_portgroup:
|
vmware_portgroup:
|
||||||
|
|
|
@ -3,14 +3,20 @@
|
||||||
# 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)
|
||||||
|
|
||||||
|
- import_role:
|
||||||
|
name: prepare_vmware_tests
|
||||||
|
vars:
|
||||||
|
setup_datastore: true
|
||||||
|
setup_virtualmachines: true
|
||||||
|
|
||||||
- when: vcsim is not defined
|
- when: vcsim is not defined
|
||||||
block:
|
block:
|
||||||
- name: Get facts from a given ESXi
|
- name: Get facts from a given ESXi
|
||||||
vmware_vm_facts:
|
vmware_vm_facts:
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
hostname: '{{ esxi1 }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
|
|
||||||
- import_role:
|
- import_role:
|
||||||
name: prepare_vmware_tests
|
name: prepare_vmware_tests
|
||||||
|
@ -59,7 +65,7 @@
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
username: "{{ vcenter_username }}"
|
username: "{{ vcenter_username }}"
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
name: "DC0_H0_VM0"
|
name: "{{ virtual_machines[0].name }}"
|
||||||
register: folder_path_info
|
register: folder_path_info
|
||||||
|
|
||||||
- set_fact:
|
- set_fact:
|
||||||
|
@ -75,6 +81,7 @@
|
||||||
folder: "{{ folder_path }}"
|
folder: "{{ folder_path }}"
|
||||||
register: vm_facts
|
register: vm_facts
|
||||||
when: folder_path_info.folders is defined
|
when: folder_path_info.folders is defined
|
||||||
|
- debug: var=vm_facts
|
||||||
|
|
||||||
- name: Check if facts are returned for VM with folder specified
|
- name: Check if facts are returned for VM with folder specified
|
||||||
assert:
|
assert:
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
setup_attach_host: true
|
setup_attach_host: true
|
||||||
setup_datastore: true
|
setup_datastore: true
|
||||||
setup_virtualmachines: true
|
setup_virtualmachines: true
|
||||||
|
|
||||||
- name: Create DRS VM group
|
- name: Create DRS VM group
|
||||||
vmware_drs_group:
|
vmware_drs_group:
|
||||||
hostname: "{{ vcenter_hostname }}"
|
hostname: "{{ vcenter_hostname }}"
|
||||||
|
@ -20,7 +21,7 @@
|
||||||
cluster_name: '{{ ccr1 }}'
|
cluster_name: '{{ ccr1 }}'
|
||||||
datacenter_name: '{{ dc1 }}'
|
datacenter_name: '{{ dc1 }}'
|
||||||
group_name: DC0_C0_VM_GR1
|
group_name: DC0_C0_VM_GR1
|
||||||
vms: '{{ infra.vm_list }}'
|
vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
|
||||||
state: present
|
state: present
|
||||||
register: drs_vm_group_01_results
|
register: drs_vm_group_01_results
|
||||||
- debug: var=drs_vm_group_01_results
|
- debug: var=drs_vm_group_01_results
|
||||||
|
@ -35,9 +36,7 @@
|
||||||
cluster_name: '{{ ccr1 }}'
|
cluster_name: '{{ ccr1 }}'
|
||||||
datacenter_name: '{{ dc1 }}'
|
datacenter_name: '{{ dc1 }}'
|
||||||
group_name: DC0_C0_HOST_GR1
|
group_name: DC0_C0_HOST_GR1
|
||||||
hosts:
|
hosts: '{{ esxi_hosts }}'
|
||||||
- '{{ hostvars[esxi1].ansible_host }}'
|
|
||||||
- '{{ hostvars[esxi2].ansible_host }}'
|
|
||||||
state: present
|
state: present
|
||||||
register: drs_host_group_01_results
|
register: drs_host_group_01_results
|
||||||
- debug: var=drs_host_group_01_results
|
- debug: var=drs_host_group_01_results
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
password: "{{ vcenter_password }}"
|
password: "{{ vcenter_password }}"
|
||||||
drs_rule_name: drs_rule_0001
|
drs_rule_name: drs_rule_0001
|
||||||
cluster_name: "{{ ccr1 }}"
|
cluster_name: "{{ ccr1 }}"
|
||||||
vms: "{{ infra.vm_list }}"
|
vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
|
||||||
enabled: True
|
enabled: True
|
||||||
affinity_rule: True
|
affinity_rule: True
|
||||||
mandatory: True
|
mandatory: True
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
|
|
||||||
- name: Add a nic to a switch
|
- name: Add a nic to a switch
|
||||||
vmware_vswitch:
|
vmware_vswitch:
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
switch: vmswitch_0001
|
switch: vmswitch_0001
|
||||||
nics: vnic_1
|
nics: vnic_1
|
||||||
|
@ -28,9 +28,9 @@
|
||||||
|
|
||||||
- name: Add a nic to a switch again
|
- name: Add a nic to a switch again
|
||||||
vmware_vswitch:
|
vmware_vswitch:
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
switch: vmswitch_0001
|
switch: vmswitch_0001
|
||||||
nics: vnic_1
|
nics: vnic_1
|
||||||
|
@ -42,9 +42,9 @@
|
||||||
|
|
||||||
- name: Remove a switch (check-mode)
|
- name: Remove a switch (check-mode)
|
||||||
vmware_vswitch:
|
vmware_vswitch:
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
switch: vmswitch_0001
|
switch: vmswitch_0001
|
||||||
state: absent
|
state: absent
|
||||||
|
@ -58,9 +58,9 @@
|
||||||
# FIXME: Removing a switch fails
|
# FIXME: Removing a switch fails
|
||||||
- name: Remove a switch
|
- name: Remove a switch
|
||||||
vmware_vswitch:
|
vmware_vswitch:
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
switch: vmswitch_0001
|
switch: vmswitch_0001
|
||||||
state: absent
|
state: absent
|
||||||
|
@ -71,9 +71,9 @@
|
||||||
|
|
||||||
- name: Remove a switch again (check-mode)
|
- name: Remove a switch again (check-mode)
|
||||||
vmware_vswitch:
|
vmware_vswitch:
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
switch: vmswitch_0001
|
switch: vmswitch_0001
|
||||||
state: absent
|
state: absent
|
||||||
|
@ -87,9 +87,9 @@
|
||||||
# FIXME: Removing a switch fails
|
# FIXME: Removing a switch fails
|
||||||
- name: Remove a switch again
|
- name: Remove a switch again
|
||||||
vmware_vswitch:
|
vmware_vswitch:
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
switch: vmswitch_0001
|
switch: vmswitch_0001
|
||||||
state: absent
|
state: absent
|
||||||
|
@ -101,9 +101,9 @@
|
||||||
- name: Add vswitch to a specific host system
|
- name: Add vswitch to a specific host system
|
||||||
vmware_vswitch:
|
vmware_vswitch:
|
||||||
validate_certs: False
|
validate_certs: False
|
||||||
hostname: '{{ hostvars[esxi1].ansible_host }}'
|
hostname: '{{ esxi1 }}'
|
||||||
username: '{{ hostvars[esxi1].ansible_user }}'
|
username: '{{ esxi_user }}'
|
||||||
password: '{{ hostvars[esxi1].ansible_password }}'
|
password: '{{ esxi_password }}'
|
||||||
switch: vmswitch_0002
|
switch: vmswitch_0002
|
||||||
nics: vnic_1
|
nics: vnic_1
|
||||||
esxi_hostname: guest1
|
esxi_hostname: guest1
|
||||||
|
|
Loading…
Reference in a new issue