diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/network/tasks/main.yml b/ansible/roles/firstboot/files/ansible_payload/roles/network/tasks/main.yml index e69de29..b64a05c 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/network/tasks/main.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/network/tasks/main.yml @@ -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 diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/network/templates/netplan.j2 b/ansible/roles/firstboot/files/ansible_payload/roles/network/templates/netplan.j2 index e69de29..d1a78ac 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/network/templates/netplan.j2 +++ b/ansible/roles/firstboot/files/ansible_payload/roles/network/templates/netplan.j2 @@ -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'] }} diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/vapp/tasks/main.yml b/ansible/roles/firstboot/files/ansible_payload/roles/vapp/tasks/main.yml index cf094bd..23dda88 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/vapp/tasks/main.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/vapp/tasks/main.yml @@ -1,44 +1,20 @@ -- name: Store current vApp configuration +- name: Store current ovfEnvironment ansible.builtin.shell: cmd: vmtoolsd --cmd "info-get guestinfo.ovfEnv" register: ovfenv -- name: DEBUG variable contents - ansible.builtin.debug: - ovfenv -- name: Parse XML into variables +- name: Parse XML for vApp properties community.general.xml: - xmlstring: "{{ ovfEnv }}" + xmlstring: "{{ ovfenv.stdout }}" namespaces: - oe: http://schemas.dmtf.org/ovf/environment/1 - xpath: /Environment/PropertySection/Property - content: oe:key - - -# -# -# -# VMware ESXi -# 7.0.1 -# VMware, Inc. -# en -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# + ns: http://schemas.dmtf.org/ovf/environment/1 + xpath: /ns:Environment/ns:PropertySection/ns:Property + content: attribute + register: ovfenv +- name: Assign vApp properties to dictionary + ansible.builtin.set_fact: + ovfproperties: >- + {{ ovfproperties | default({}) | + combine({((item.values() | list)[0].values() | list)[0]: + ((item.values() | list)[0].values() | list)[1]}) + }} + loop: "{{ ovfenv.matches }}" diff --git a/ansible/roles/firstboot/templates/firstboot.j2 b/ansible/roles/firstboot/templates/firstboot.j2 index e980c89..b4029b9 100644 --- a/ansible/roles/firstboot/templates/firstboot.j2 +++ b/ansible/roles/firstboot/templates/firstboot.j2 @@ -1,3 +1,4 @@ #!/bin/bash -# FOO \ No newline at end of file +# Apply firstboot configuration w/ ansible +ansible-playbook /opt/firstboot/ansible/playbook.yml \ No newline at end of file diff --git a/ansible/roles/os/vars/main.yml b/ansible/roles/os/vars/main.yml index 4dce7e2..3c2c9df 100644 --- a/ansible/roles/os/vars/main.yml +++ b/ansible/roles/os/vars/main.yml @@ -3,9 +3,8 @@ packages: - python3-pip - python3-setuptools - python3-wheel - # (libxml2-utils) Dependency for xmllint - - libxml2-utils pip_packages: - pip - ansible-core + - lxml