Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
---
- name: Credentials for vCenter API
hosts:
- workers
- frontweb
gather_facts: no
vars_prompt:
- name: "vcenter_hostname_tmp"
prompt: "Enter vcenter hostname"
default: "vcsa01-rennes.lri.lcl"
- name: "vcenter_user_tmp"
prompt: "Enter vcenter username"
default: "administrator@vsphere.local"
- name: "vcenter_pass_tmp"
prompt: "Enter vcenter password"
private: yes
tasks:
- set_fact:
vcenter_hostname: "{{ vcenter_hostname_tmp }}"
vcenter_user : "{{ vcenter_user_tmp }}"
vcenter_pass : "{{ vcenter_pass_tmp }}"
- hosts: workers
gather_facts: no
connection: local
tasks:
- name: Deploy workers nodes
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
name: "{{ inventory_hostname }}"
datacenter: "{{ datacenter }}"
cluster: "{{ cluster }}"
state: poweredon
template: '{{ template }}'
resource_pool: '{{ respool }}'
folder: "{{ datacenter }}/vm/{{ folder }}"
guest_id: "{{ guest_id }}"
networks:
- name: "{{ network1 }}"
ip: "{{ ip1 }}"
netmask: "{{ netmask }}"
gateway: "{{ gateway }}"
device_type: "vmxnet3"
dns_servers:
- "{{ dns_server }}"
snapshot_src: "{{ snapshot_name }}"
linked_clone: yes
customization:
dns_servers:
- "{{ dns_server }}"
domain: "{{ dns_domain }}"
dns_suffix: "{{ dns_domain }}"
password: "{{ os_password }}"
wait_for_ip_address: yes
- hosts: frontweb
gather_facts: no
connection: local
tasks:
- name: Deploy frontweb nodes
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
name: "{{ inventory_hostname }}"
datacenter: "{{ datacenter }}"
cluster: "{{ cluster }}"
state: poweredon
template: '{{ template }}'
resource_pool: '{{ respool }}'
folder: "{{ datacenter }}/vm/{{ folder }}"
networks:
- name: "pg_frontweb"
ip: "{{ ip1 }}"
netmask: "{{ netmask }}"
gateway: "{{ gateway }}"
dns_servers:
- "{{ dns_server }}"
- name: "{{ network2 }}"
ip: "{{ ip2 }}"
netmask: "{{ netmask }}"
snapshot_src: "{{ snapshot_name }}"
linked_clone: yes
customization:
dns_servers:
- "{{ dns_server }}"
domain: "{{ dns_domain }}"
dns_suffix: "{{ dns_domain }}"
password: "{{ os_password }}"
wait_for_ip_address: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.