Copy #Ins Hauptverzeichnis von Ansible navigieren
cd /etc/ansible
Copy #deploy_lnx_vm-YML-File erstellen [/etc/ansible/tasks]
touch deploy_lnx_vm.yml
Copy ---
###################################
### File: deploy_lnx_vm.yml ###
### Autor: Gian Bucher ###
### Date: 25.05.2021 ###
###################################
#File: deploy_lnx_vm.yml
- hosts : all
gather_facts : false
tasks :
- name : Create a virtual machine
vmware_guest :
hostname : vmh94520.css.ch
username : root
password : Root123+
validate_certs : no
folder : /ha-datacenter/vm/
name : "{{ inventory_hostname }}"
state : poweredon
guest_id : "{{ os_type | default('ubuntu64Guest') }}"
esxi_hostname : vmh94520.css.ch
disk :
- size_gb : "{{ disk_size | default('50') }}"
type : thin
datastore : "{{ datastore | default('IBM-Storage-01') }}"
hardware :
memory_mb : "{{ memory | default('8192') }}"
num_cpus : "{{ vcores | default('2') }}"
scsi : paravirtual
cdrom :
type : iso
iso_path : "{{ iso }}"
networks :
- name : "{{ network | default('Zentrale_Dienste') }}"
mac : aa:bb:dd:aa:00:14
ip : 10.100.1.230
netmask : 255.255.255.0
device_type : vmxnet3
wait_for_ip_address : yes
delegate_to : localhost
register : deploy_vm
...
Copy ---
#File: inventory.yml
all:
hosts:
lnx55200:
ansible_host: 10.100.1.186
vcores: 4
lnx55410:
#Select guest OS (https://code.vmware.com/apis/358/doc/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html)
os_type: 'ubuntu64Guest'
#Select storage (IBM-Storage-01, IBM-Storage-02, IBM-Storage-03)
datastore: 'IBM-Storage-02'
#Customize settings
vcores: '4'
memory: '8192'
disk_size: '50'
network: 'Zentrale_Dienste'
iso: '[IBM-Storage-01] ISO/ubuntu-20.04.2-live-server-amd64.iso'
Copy #Playbook anschliessend ausfĂĽhren [/etc/ansible/tasks]
ansible-playbook -i /etc/ansible/inventories/inventory.yml
--limit lnx55410 deploy_lnx_vm.yml