Difference between revisions of "Erstellen VM"
(Created page with "--- - hosts: all gather_facts: false connection: local user: remote vars: vcenter_hostname: 'IP' vcenter_user: 'administrator@testlab.lan' vcenter_pass: '...") |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | <pre> | ||
--- | --- | ||
- hosts: all | - hosts: all | ||
Line 98: | Line 99: | ||
sudo: yes | sudo: yes | ||
tags: mac | tags: mac | ||
+ | </pre> |
Latest revision as of 08:56, 23 October 2019
--- - hosts: all gather_facts: false connection: local user: remote vars: vcenter_hostname: 'IP' vcenter_user: 'administrator@testlab.lan' vcenter_pass: 'PASSWORD' datacenter: 'testlab' esxi_host: 'IP' notes: 'Created by Ansible' tasks: - vsphere_guest: validate_certs: False vcenter_hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" guest: "{{ inventory_hostname }}" state: present vm_extra_config: notes: "{{ notes }}" vm_disk: disk1: size_gb: "{{ disk }}" type: thin datastore: "{{ datastore }}" vm_nic: nic1: type: vmxnet3 network: "{{ network }}" network_type: standard vm_hardware: memory_mb: "{{ memory }}" num_cpus: "{{ cpucount }}" osid: "{{ osid }}" scsi: paravirtual esxi: datacenter: "{{ datacenter }}" hostname: "{{ esxi_host }}" - name: Gather VM facts vsphere_guest: vcenter_hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" guest: "{{ inventory_hostname }}" validate_certs: False vmware_guest_facts: yes register: newvm tags: mac - name: create forward lookup entry DNS" nsupdate: key_name: "testlab.lan" key_secret: "U93nnwyHGYr20Ro6YNTDng==" server: "172.16.0.1" zone: "testlab.lan." record: "{{ inventory_hostname }}" value: "{{ip}}" - name: create reverse lookup entry DNS" nsupdate: key_name: "testlab.lan" key_secret: "U93nnwyHGYr20Ro6YNTDng==" server: "172.16.0.1" zone: "16.172.in-addr.arpa" type: PTR record: "{{ rip }}" value: "{{ inventory_hostname }}.testlab.lan." - name: Prepare for PXE install file: > path=/tftpboot/pxelinux.cfg/01-{{ newvm.ansible_facts.hw_eth0.macaddress_dash }} src=/tftpboot/pxelinux.cfg/centos70 state=hard sudo: yes tags: mac - name: Power on VMs vsphere_guest: vcenter_hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" guest: "{{ inventory_hostname }}" validate_certs: False state: powered_on force: yes - pause: seconds: 15 - name: Remove kickstart link file: > path=/tftpboot/pxelinux.cfg/01-{{ newvm.ansible_facts.hw_eth0.macaddress_dash }} src=/tftpboot/pxelinux.cfg/centos70 state=absent sudo: yes tags: mac