Kapisi/playbooks/patching.yml

51 lines
1.3 KiB
YAML
Raw Normal View History

2020-10-08 16:33:19 -05:00
---
# patching.yml
#
2021-12-19 21:32:19 -06:00
# This playbook can be used to patch all the servers in an inventory to the latest software available.
# Because we typically encrypt our disk storage, we don't wait for the connection to become available again.
2020-10-08 16:33:19 -05:00
# Variables:
2021-12-19 21:32:19 -06:00
# - target: the host grouper in the inventory -- default: all
2020-10-08 16:33:19 -05:00
#
# Patch then restart a node
2021-12-19 21:32:19 -06:00
- hosts: "{{ target | default('all') }}"
2020-10-08 16:33:19 -05:00
order: sorted
ignore_unreachable: true
serial: 1
vars:
ansible_become: yes
ansible_become_user: root
ansible_become_method: sudo
vars_files:
2021-12-19 21:32:19 -06:00
- "{{ lookup('env', 'ANSIBLE_VAULT_FILE') }}"
2020-10-08 16:33:19 -05:00
tasks:
- name: Check /var free percentage
command: /bin/bash -c "df -m /var | tail -n 1 | awk '{ print $5; }' | sed 's/%//' "
become: no
register: df_output
- name: Verify /var space
assert:
that:
- 90 > {{ df_output.stdout }}
fail_msg: "Not enough free space"
2021-12-19 21:32:19 -06:00
- name: Patching all packages (ArchLinux)
2020-10-08 16:33:19 -05:00
ignore_errors: yes
2021-12-19 21:32:19 -06:00
when: ansible_os_family == "Archlinux"
pacman:
upgrade: yes
2020-10-08 16:33:19 -05:00
update_cache: yes
2021-12-19 21:32:19 -06:00
- name: Patching all packages (Debian)
ignore_errors: yes
when: ansible_os_family == "Debian"
apt:
upgrade: yes
update_cache: yes
2020-10-08 16:33:19 -05:00
- name: Reboot
2021-12-19 21:32:19 -06:00
ignore_errors: yes
2020-10-08 16:33:19 -05:00
reboot:
2021-12-19 21:32:19 -06:00
reboot_timeout: 2