Skip to content
Snippets Groups Projects
Commit 0b84598e authored by nimrod's avatar nimrod
Browse files

Update playbook improvements.

- Run on the different hosts in parallel, not waiting for other hosts to
finish.
- Handle an error when reboot_needed is not defined if a reboot is not
needed.
- Fix a typo.
parent 56ad0cdb
No related branches found
No related tags found
No related merge requests found
Pipeline #822 passed
---
- name: Group hosts by package manager
- name: Update hosts
strategy: host_pinned
hosts:
- all:!localhost
tasks:
- name: Group hosts by package manager
group_by:
key: pkg_mgr_{{ ansible_pkg_mgr }}
changed_when: false
tags:
- always
- name: Update Debian hosts
hosts:
- pkg_mgr_apt
- update
tasks:
- name: Update Debian-based hosts
when: ansible_pkg_mgr == 'apt'
tags:
- debian
block:
- name: Update packages
apt:
autoclean: true
......@@ -60,36 +57,36 @@
{{ apt_upgrade is changed or
fwupdmgr is changed or
flatpak_update is changed }}
tags:
- debian
- update
- name: Update OpenWRT hosts
hosts:
- pkg_mgr_opkg
tasks:
when: ansible_pkg_mgr == 'opkg'
tags:
- openwrt
block:
- name: Update package list
command: opkg update
changed_when: false
- name: Update packages
# We run through sort so that we don't run 2 instances fo opkg at once.
shell: |-
opkg list-upgradable | awk '{print $1}' | sort | xargs -rn1 opkg upgrade
# We run through sort so that we don't run 2 instances of opkg at
# once.
shell: >-
opkg list-upgradable |
awk '{print $1}' |
sort |
xargs -rn1 opkg upgrade
register: opkg_upgrade
changed_when: opkg_upgrade.stdout_lines|length > 0
- name: Set reboot needed fact
set_fact:
reboot_needed: "{{ opkg_upgrade is changed }}"
tags:
- openwrt
- update
- name: Update OpenBSD hosts
hosts:
- pkg_mgr_openbsd_pkg
tasks:
- name: Update OpenWRT hosts
when: ansible_pkg_mgr == 'openbsd_pkg'
tags:
- openbsd
block:
- name: Apply system patches
command: syspatch
register: syspatch
......@@ -112,16 +109,13 @@
{{ syspatch is changed or
pkg_upgrade is changed or
fw_update is changed }}
tags:
- openbsd
- update
- name: Reboot NS1
hosts:
- ns1
tasks:
- name: Reboot
when: reboot_needed
when: reboot_needed|default(false)
reboot:
tags:
- reboot
......@@ -131,7 +125,7 @@
- ea6350
tasks:
- name: Reboot
when: reboot_needed
when: reboot_needed|default(false)
command: reboot
- name: Wait to re-establish the connection
......@@ -147,7 +141,7 @@
wait_for_connection:
- name: Reboot
when: reboot_needed
when: reboot_needed|default(false)
reboot:
tags:
- reboot
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment