From 990534618b9bde498e46c67e26267f04141cc913 Mon Sep 17 00:00:00 2001 From: djpbessems Date: Wed, 9 Jun 2021 22:49:14 +0200 Subject: [PATCH] Housekeeping;Disable crontab w/ reboot-followup --- ansible/roles/firstboot/files/ansible_payload/playbook.yml | 1 + .../files/ansible_payload/roles/cleanup/tasks/main.yml | 6 ++++++ .../files/ansible_payload/roles/network/tasks/main.yml | 3 +++ .../ansible_payload/roles/network/templates/netplan.j2 | 2 +- .../files/ansible_payload/roles/vapp/tasks/main.yml | 1 + ansible/roles/firstboot/tasks/main.yml | 2 +- 6 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 ansible/roles/firstboot/files/ansible_payload/roles/cleanup/tasks/main.yml diff --git a/ansible/roles/firstboot/files/ansible_payload/playbook.yml b/ansible/roles/firstboot/files/ansible_payload/playbook.yml index 2650368..ffa17f7 100644 --- a/ansible/roles/firstboot/files/ansible_payload/playbook.yml +++ b/ansible/roles/firstboot/files/ansible_payload/playbook.yml @@ -6,3 +6,4 @@ roles: - vapp - network + - cleanup diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/cleanup/tasks/main.yml b/ansible/roles/firstboot/files/ansible_payload/roles/cleanup/tasks/main.yml new file mode 100644 index 0000000..78f1e72 --- /dev/null +++ b/ansible/roles/firstboot/files/ansible_payload/roles/cleanup/tasks/main.yml @@ -0,0 +1,6 @@ +- name: Disable crontab job + ansible.builtin.cron: + name: firstboot + state: absent +- name: Reboot host + reboot: 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 b64a05c..9701ac6 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 @@ -1,3 +1,6 @@ +- name: Set hostname + ansible.builtin.hostname: + name: "{{ ovfproperties['guestinfo.hostname'] }}" - name: Create netplan configuration file ansible.builtin.template: src: netplan.j2 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 d1a78ac..fd8bfe5 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 @@ -3,7 +3,7 @@ network: ethernets: ens192: addresses: - - {{ ovfproperties['guestinfo.ipaddress'] }}/{{ ovfproperties['guestinfo.prefixlength']}} + - {{ ovfproperties['guestinfo.ipaddress'] }}/{{ ovfproperties['guestinfo.prefixlength'] }} gateway4: {{ ovfproperties['guestinfo.gateway'] }} nameservers: addresses: 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 23dda88..4b0b72c 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 @@ -18,3 +18,4 @@ ((item.values() | list)[0].values() | list)[1]}) }} loop: "{{ ovfenv.matches }}" + no_log: true diff --git a/ansible/roles/firstboot/tasks/main.yml b/ansible/roles/firstboot/tasks/main.yml index 4035591..bc584b0 100644 --- a/ansible/roles/firstboot/tasks/main.yml +++ b/ansible/roles/firstboot/tasks/main.yml @@ -11,7 +11,7 @@ mode: o+x - name: Create @reboot crontab job ansible.builtin.cron: - name: "firstboot" + name: firstboot special_time: reboot job: "/opt/firstboot/firstboot.sh" - name: Copy payload folder