From b8cce2adcb3a9b726d415fef246c084fd9b81ab9 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Thu, 19 Sep 2024 11:57:39 +0200 Subject: [PATCH] cloud-init kernels do not have batman-adv installed we need to switch to a non cloud-init kernel when installing batman-adv from compiled packages --- .../roles/ff.mesh_batman/handlers/main.yml | 11 ++++++ .../ff.mesh_batman/tasks/batctl_from_repo.yml | 34 +++++++++++++++++++ playbooks/roles/ff.mesh_batman/tasks/main.yml | 14 +++++--- 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 playbooks/roles/ff.mesh_batman/handlers/main.yml create mode 100644 playbooks/roles/ff.mesh_batman/tasks/batctl_from_repo.yml diff --git a/playbooks/roles/ff.mesh_batman/handlers/main.yml b/playbooks/roles/ff.mesh_batman/handlers/main.yml new file mode 100644 index 0000000..8b84bfa --- /dev/null +++ b/playbooks/roles/ff.mesh_batman/handlers/main.yml @@ -0,0 +1,11 @@ +--- + +- name: update_initramfs + command: update-initramfs -u + +- name: update_grub + command: update-grub + +- name: post_reboot_tasks + debug: + msg: "System has rebooted successfully after kernel changes." \ No newline at end of file diff --git a/playbooks/roles/ff.mesh_batman/tasks/batctl_from_repo.yml b/playbooks/roles/ff.mesh_batman/tasks/batctl_from_repo.yml new file mode 100644 index 0000000..ca116c0 --- /dev/null +++ b/playbooks/roles/ff.mesh_batman/tasks/batctl_from_repo.yml @@ -0,0 +1,34 @@ +--- + +- name: Check if a cloud-init variant kernel is installed + shell: | + uname -r | grep -q "cloud" + register: cloud_kernel_installed + failed_when: false + +- name: Install regular linux-image-amd64 kernel if cloud-init variant is installed + apt: + name: linux-image-amd64 + state: present + when: cloud_kernel_installed.rc == 0 + notify: + - update_initramfs + - update_grub + +- name: Purge all cloud-init variant kernels if installed + apt: + name: "linux-image-*-cloud-amd64" + state: absent + purge: yes + when: cloud_kernel_installed.rc == 0 + +- name: Reboot the server if kernel changes have been made + reboot: + msg: "Rebooting to apply new kernel" + pre_reboot_delay: 10 + when: cloud_kernel_installed.rc == 0 + notify: + - post_reboot_tasks + +- name: Install batctl from repo + apt: name=batctl \ No newline at end of file diff --git a/playbooks/roles/ff.mesh_batman/tasks/main.yml b/playbooks/roles/ff.mesh_batman/tasks/main.yml index 986f2de..a4ffa98 100644 --- a/playbooks/roles/ff.mesh_batman/tasks/main.yml +++ b/playbooks/roles/ff.mesh_batman/tasks/main.yml @@ -1,15 +1,21 @@ --- - - name: Include 'Build from source' include_tasks: build_from_source.yml when: batman_build_from_source -- name: Install batctl - apt: name=batctl +- name: Install batctl from repo - switch kernel if needed + include_tasks: build_from_repo.yml when: not batman_build_from_source - name: Install autostart batman_adv on boot lineinfile: dest=/etc/modules line=batman-adv - name: Load batman_adv module - modprobe: name=batman_adv state=present \ No newline at end of file + modprobe: name=batman_adv state=present + + +### uninstall cloud-init and install real image: +#sudo apt install linux-image-amd64 +#sudo apt purge linux-image-*-cloud-amd64 +# update-initramfs -u +# update-grub \ No newline at end of file