diff --git a/ansible/roles/firstboot/files/ansible_payload/playbook.yml b/ansible/roles/firstboot/files/ansible_payload/playbook.yml new file mode 100644 index 0000000..fc4822f --- /dev/null +++ b/ansible/roles/firstboot/files/ansible_payload/playbook.yml @@ -0,0 +1,8 @@ +--- +- hosts: 127.0.0.1 + connection: local + gather_facts: false + # become: true + roles: + - vapp + - network 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 new file mode 100644 index 0000000..e69de29 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 new file mode 100644 index 0000000..e69de29 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 new file mode 100644 index 0000000..fcaca2d --- /dev/null +++ b/ansible/roles/firstboot/files/ansible_payload/roles/vapp/tasks/main.yml @@ -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 + + +# +# +# +# VMware ESXi +# 7.0.1 +# VMware, Inc. +# en +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# diff --git a/ansible/roles/firstboot/tasks/main.yml b/ansible/roles/firstboot/tasks/main.yml index 46ba7d9..0484599 100644 --- a/ansible/roles/firstboot/tasks/main.yml +++ b/ansible/roles/firstboot/tasks/main.yml @@ -1,7 +1,7 @@ -- name: Copy firstboot script file - ansible.builtin.copy: - src: firstboot.sh - dest: /opt/firstboot.sh +- name: Create firstboot script file + ansible.builtin.template: + src: firstboot.j2 + dest: /opt/firstboot/firstboot.sh owner: root group: root mode: o+x @@ -9,4 +9,14 @@ ansible.builtin.cron: name: "firstboot" 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 \ No newline at end of file diff --git a/ansible/roles/firstboot/files/firstboot.sh b/ansible/roles/firstboot/templates/firstboot.j2 similarity index 100% rename from ansible/roles/firstboot/files/firstboot.sh rename to ansible/roles/firstboot/templates/firstboot.j2 diff --git a/packer/ubuntuserver20.04.pkr.hcl b/packer/ubuntuserver20.04.pkr.hcl index 84764c9..3966ca5 100644 --- a/packer/ubuntuserver20.04.pkr.hcl +++ b/packer/ubuntuserver20.04.pkr.hcl @@ -88,7 +88,7 @@ build { " -ManifestFileName '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.mf'", "ovftool --acceptAllEulas --allowExtraConfig --overwrite \\", " '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\", - " /output/UbuntuServer20.04.ova" + " /output/Ubuntu-Server-20.04.ova" ] } } \ No newline at end of file