1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/prepare_vmware_tests/tasks/main.yml
Gonéri Le Bouder 6d645c127f vmware: import prepare_vmware_tests
The vmware test roles do a lot of similar operation to prepare
the environment. This role will be used to reduce the amount of
duplicated code.

The role can prepare an environment on a baremetal environment, this
in addition to vcsim.

Original PR: https://github.com/ansible/ansible/pull/54882
2019-04-25 09:58:59 -04:00

66 lines
1.8 KiB
YAML

---
- 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
- 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 }}'
ansible_host: '{{ item | basename }}'
ansible_user: 'root'
ansible_password: 'pass'
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"