Last active
March 9, 2018 14:43
-
-
Save lrivallain/a2fc8443ef4433623d0add3601ab7115 to your computer and use it in GitHub Desktop.
Resources for blog post : https://vuptime.io/2018/02/07/ansible-vmware_modules_-_first_steps/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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