Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Initial setup of the Loadbalancer.org appliance using vSphere API and Ansible
---
- name: Initial setup of the Loadbalancer.org appliance
hosts: localhost
connection: local
gather_facts: false
vars:
# Variables below are needed by the VMWare module
vcenter_hostname:
vcenter_username:
vcenter_password:
datacenter_name:
vm_name:
# Variables below are used to configure your loadbalancer
ip:
cidr:
gateway:
dns1:
dns2:
password:
tasks:
- name: Login
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
string_send: "setup"
- name: ENTER
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- name: Password
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
string_send: "setup"
- name: ENTER
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- name: Configure Management IP => Yes
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- name: Available Interfaces => OK
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- name: Do you need to create a bonded interface? => No
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- name: Would you like to configure a VLAN? => No
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- name: Select interface => eth0
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- TAB
- ENTER
- name: Static IP address
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
string_send: "{{ ip }}"
- name: Next Field
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- TAB
- name: CIDR prefix
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
string_send: "{{ cidr }}"
- name: Done
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- TAB
- ENTER
- name: Configure Default Gateway
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
string_send: "{{ gateway }}"
- name: Done
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- TAB
- ENTER
- name: Primary DNS
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
string_send: "{{ dns1 }}"
- name: Next field
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- TAB
- name: Secondary DNS
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
string_send: "{{ dns2 }}"
- name: Done
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- TAB
- ENTER
- name: Summary
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- ENTER
- name: Set Password
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- ENTER
- name: Password
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
string_send: "{{ password }}"
- name: Next field
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- TAB
- name: Password again
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
string_send: "{{ password }}"
- name: Done
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- TAB
- ENTER
- name: WUI and console password set succesfully
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- name: Peer Recovery => No
community.vmware.vmware_guest_sendkey:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
sleep_time: 1
keys_send:
- ENTER
- ENTER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment