Add vApp xml parse logic
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b33280b443
commit
c0953acefe
@ -0,0 +1,7 @@
|
|||||||
|
- name: Create netplan configuration file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: netplan.j2
|
||||||
|
dest: /etc/netplan/00-installer-config.yaml
|
||||||
|
- name: Apply netplan configuration
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: netplan apply
|
@ -0,0 +1,10 @@
|
|||||||
|
network:
|
||||||
|
version: 2
|
||||||
|
ethernets:
|
||||||
|
ens192:
|
||||||
|
addresses:
|
||||||
|
- {{ ovfproperties['guestinfo.ipaddress'] }}/{{ ovfproperties['guestinfo.prefixlength']}}
|
||||||
|
gateway4: {{ ovfproperties['guestinfo.gateway'] }}
|
||||||
|
nameservers:
|
||||||
|
addresses:
|
||||||
|
- {{ ovfproperties['guestinfo.dnsserver'] }}
|
@ -1,44 +1,20 @@
|
|||||||
- name: Store current vApp configuration
|
- name: Store current ovfEnvironment
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: vmtoolsd --cmd "info-get guestinfo.ovfEnv"
|
cmd: vmtoolsd --cmd "info-get guestinfo.ovfEnv"
|
||||||
register: ovfenv
|
register: ovfenv
|
||||||
- name: DEBUG variable contents
|
- name: Parse XML for vApp properties
|
||||||
ansible.builtin.debug:
|
|
||||||
ovfenv
|
|
||||||
- name: Parse XML into variables
|
|
||||||
community.general.xml:
|
community.general.xml:
|
||||||
xmlstring: "{{ ovfEnv }}"
|
xmlstring: "{{ ovfenv.stdout }}"
|
||||||
namespaces:
|
namespaces:
|
||||||
oe: http://schemas.dmtf.org/ovf/environment/1
|
ns: http://schemas.dmtf.org/ovf/environment/1
|
||||||
xpath: /Environment/PropertySection/Property
|
xpath: /ns:Environment/ns:PropertySection/ns:Property
|
||||||
content: oe:key
|
content: attribute
|
||||||
|
register: ovfenv
|
||||||
|
- name: Assign vApp properties to dictionary
|
||||||
# <?xml version="1.0" encoding="UTF-8"?>
|
ansible.builtin.set_fact:
|
||||||
# <Environment
|
ovfproperties: >-
|
||||||
# xmlns="http://schemas.dmtf.org/ovf/environment/1"
|
{{ ovfproperties | default({}) |
|
||||||
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
combine({((item.values() | list)[0].values() | list)[0]:
|
||||||
# xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
|
((item.values() | list)[0].values() | list)[1]})
|
||||||
# xmlns:ve="http://www.vmware.com/schema/ovfenv"
|
}}
|
||||||
# oe:id=""
|
loop: "{{ ovfenv.matches }}"
|
||||||
# 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>
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# FOO
|
# Apply firstboot configuration w/ ansible
|
||||||
|
ansible-playbook /opt/firstboot/ansible/playbook.yml
|
@ -3,9 +3,8 @@ packages:
|
|||||||
- python3-pip
|
- python3-pip
|
||||||
- python3-setuptools
|
- python3-setuptools
|
||||||
- python3-wheel
|
- python3-wheel
|
||||||
# (libxml2-utils) Dependency for xmllint
|
|
||||||
- libxml2-utils
|
|
||||||
|
|
||||||
pip_packages:
|
pip_packages:
|
||||||
- pip
|
- pip
|
||||||
- ansible-core
|
- ansible-core
|
||||||
|
- lxml
|
||||||
|
Loading…
Reference in New Issue
Block a user