mirror of https://github.com/ansible/ansible.git
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/55237pull/56888/head
parent
4adb7cfb5f
commit
6bb21c3db0
@ -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
|
||||
|
@ -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
|
@ -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 }}'
|
@ -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 }}'
|
Loading…
Reference in New Issue