Add ansible payload draft
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Danny Bessems 2021-06-09 10:39:00 +02:00
parent 998f5ef381
commit fcdc7d07ad
7 changed files with 65 additions and 6 deletions

View File

@ -0,0 +1,8 @@
---
- hosts: 127.0.0.1
connection: local
gather_facts: false
# become: true
roles:
- vapp
- network

View File

@ -0,0 +1,41 @@
- name: Store current vApp configuration
ansible.builtin.shell:
cmd: vmtoolsd --cmd "info-get guestinfo.ovfEnv"
register: ovfEnv
- name: Parse XML into variables
community.general.xml:
xmlstring: "{{ ovfEnv }}"
namespaces:
oe: http://schemas.dmtf.org/ovf/environment/1
xpath: /Environment/PropertySection/Property
content: oe:key
# <?xml version="1.0" encoding="UTF-8"?>
# <Environment
# xmlns="http://schemas.dmtf.org/ovf/environment/1"
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
# xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
# xmlns:ve="http://www.vmware.com/schema/ovfenv"
# oe:id=""
# ve:vCenterId="vm-1171">
# <PlatformSection>
# <Kind>VMware ESXi</Kind>
# <Version>7.0.1</Version>
# <Vendor>VMware, Inc.</Vendor>
# <Locale>en</Locale>
# </PlatformSection>
# <PropertySection>
# <Property oe:key="deployment.type" oe:value="ubuntu-small"/>
# <Property oe:key="guestinfo.dnsserver" oe:value="1.1.1.1"/>
# <Property oe:key="guestinfo.gateway" oe:value="10.0.0.1"/>
# <Property oe:key="guestinfo.hostname" oe:value="SRV01"/>
# <Property oe:key="guestinfo.ipaddress" oe:value="10.0.0.84"/>
# <Property oe:key="guestinfo.ntpserver" oe:value="0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org"/>
# <Property oe:key="guestinfo.prefixlength" oe:value="24"/>
# <Property oe:key="guestinfo.rootpw" oe:value=""/>
# </PropertySection>
# <ve:EthernetAdapterSection>
# <ve:Adapter ve:mac="00:50:56:8a:09:08" ve:network="Staging" ve:unitNumber="7"/>
# </ve:EthernetAdapterSection>
# </Environment>

View File

@ -1,7 +1,7 @@
- name: Copy firstboot script file - name: Create firstboot script file
ansible.builtin.copy: ansible.builtin.template:
src: firstboot.sh src: firstboot.j2
dest: /opt/firstboot.sh dest: /opt/firstboot/firstboot.sh
owner: root owner: root
group: root group: root
mode: o+x mode: o+x
@ -9,4 +9,14 @@
ansible.builtin.cron: ansible.builtin.cron:
name: "firstboot" name: "firstboot"
special_time: reboot special_time: reboot
job: "/opt/firstboot.sh" job: "/opt/firstboot/firstboot.sh"
- name: Copy payload folder
ansible.builtin.copy:
src: ansible_payload/
dest: /opt/firstboot/ansible/
owner: root
group: root
mode: '0644'
- name: Install ansible-galaxy collection
ansible.builtin.shell:
cmd: ansible-galaxy collection install community.general

View File

@ -88,7 +88,7 @@ build {
" -ManifestFileName '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.mf'", " -ManifestFileName '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.mf'",
"ovftool --acceptAllEulas --allowExtraConfig --overwrite \\", "ovftool --acceptAllEulas --allowExtraConfig --overwrite \\",
" '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\", " '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\",
" /output/UbuntuServer20.04.ova" " /output/Ubuntu-Server-20.04.ova"
] ]
} }
} }