Updating IP addresses for new network configs

This commit is contained in:
Annika Merris 2026-04-17 14:23:06 +00:00
parent d9a2345dab
commit ce6b85bc09
3 changed files with 11 additions and 12 deletions

View file

@ -9,13 +9,13 @@
ansible.builtin.apt:
upgrade: dist
update_cache: true
when: ansible_distribution in debian_derivatives
when: ansible_facts['distribution'] in debian_derivatives
# This is equivalent to: apk update && apk upgrade
- name: Update cache and upgrade packages
community.general.apk:
upgrade: true
update_cache: true
when: ansible_distribution == "Alpine"
when: ansible_facts['distribution'] == "Alpine"
- name: Check if a reboot is required.
ansible.builtin.stat:
@ -35,7 +35,7 @@
set -o pipefail
apk list linux-lts --installed | awk '{ print $1 }' | sed 's/linux-lts-//' | sed 's/-r/\n/g' | awk '{printf("%s-",$0)}' | awk '{printf("%slts", $0)}'
changed_when: installed_kernel_version != ""
when: ansible_distribution == "Alpine"
when: ansible_facts['distribution'] == "Alpine"
# Set a variable for the currently *running* linux-lts kernel version. We use
# sed to strip off the arch.
- name: Register running linux-lts kernel version
@ -44,7 +44,7 @@
set -o pipefail
uname -r | sed 's/-ARCH//'
changed_when: running_kernel_version != ""
when: ansible_distribution == "Alpine"
when: ansible_facts['distribution'] == "Alpine"
# This is debugging output to tell us when the installed kernel version doesn't
# match the running kernel version. The real magic happens in the following task.
- name: Check installed_kernel_version != running_kernel_version = ???
@ -52,15 +52,14 @@
msg: "{{ installed_kernel_version.stdout }} !=
{{ running_kernel_version.stdout }} =
{{ installed_kernel_version.stdout != running_kernel_version.stdout }}"
when: ansible_distribution == "Alpine"
when: ansible_facts['distribution'] == "Alpine"
# Now compare installed_kernel_version with running_kernel_version. When they
# don't match, this means that we need to reboot. This is not a very sophisticated
# heuristic, but it works.
- name: Reboot if the running kernel version is not the installed kernel version
ansible.builtin.reboot:
reboot_timeout: 30 # These are very simple Alpine servers. They should boot extremely fast.
when: (ansible_distribution == "Alpine") and (installed_kernel_version.stdout != running_kernel_version.stdout)
when: (ansible_facts['distribution'] == "Alpine") and (installed_kernel_version.stdout != running_kernel_version.stdout)
- name: Reboot the server (if required).
ansible.builtin.reboot:
@ -69,4 +68,4 @@
- name: Remove dependencies that are no longer required.
ansible.builtin.apt:
autoremove: true
when: ansible_distribution in debian_derivatives
when: ansible_facts['distribution'] in debian_derivatives