ansible-homelab/freebsd-update.yml

62 lines
1.6 KiB
YAML

---
- hosts: freebsdservers
gather_facts: true
become: true
vars:
jails:
- aa-torrenting
tasks:
- name: Update all installed packages
community.general.pkgng:
name: "*"
state: latest
- name: Update all installed packages in jails
community.general.pkgng:
name: "*"
state: latest
jail: "{{ item }}"
with_items: "{{ jails }}"
- name: Run freebsd-update fetch
ansible.builtin.command: freebsd-update fetch
- name: Check if updates are ready
ansible.builtin.command: freebsd-update updatesready
register: updatesready
- name: Upgrade the system
ansible.builtin.command: freebsd-update install
register: upgraded
when:
- updatesready.rc == 0
- name: Reboot may be necessary
ansible.builtin.debug:
msg: "A system reboot may be necessary."
when:
- upgraded.rc == 0
- name: Run freebsd-update fetch on jails
ansible.builtin.command: "freebsd-update fetch -j {{ item }}"
with_items: "{{ jails }}"
- name: Check if updates are ready in jails
ansible.builtin.command: "freebsd-update updatesready -j {{ item }}"
register: updatesready_jails
with_items: "{{ jails }}"
- name: Upgrade the jails
ansible.builtin.command: "freebsd-update install -j {{ item }}"
register: upgraded_jails
with_items: "{{ jails }}"
when:
- updatesready_jails.rc == 0
- name: Reboot of jail may be necessary
ansible.builtin.debug:
msg: "A system reboot may be necessary for this jail."
when:
- upgraded_jails.rc == 0