ansible/tasks/update_iocage_freebsd.yml

57 lines
1.8 KiB
YAML
Raw Normal View History

2024-06-12 14:47:43 +02:00
# vim:ts=2:sw=2:et:filetype=ansible
---
- name: Check if iocage is available
2024-06-12 14:47:43 +02:00
ansible.builtin.stat:
path: /usr/local/bin/iocage
tags:
- always
register: iocage_available
2024-06-12 14:47:43 +02:00
- name: Perform iocage updates when iocage is available
when: iocage_available.stat.exists
block:
- name: List iocage jails
2024-06-12 14:47:43 +02:00
ansible.builtin.command:
cmd: /usr/local/bin/iocage list -H
2024-06-12 14:47:43 +02:00
changed_when: false
check_mode: false
register: iocage_list_jails
2024-06-12 14:47:43 +02:00
- name: Show results of list jails (iocage)
ansible.builtin.debug:
verbosity: 1
var: iocage_list_jails
2024-06-12 14:47:43 +02:00
- name: Set iocage jails
ansible.builtin.set_fact:
iocage_jails: '{{ iocage_list_jails.stdout_lines | map("split") }}'
- name: Install updates (iocage)
2024-06-12 14:47:43 +02:00
ansible.builtin.command:
cmd: '/usr/local/bin/iocage update {{ item.1 }}'
environment:
PAGER: cat
2024-06-12 14:47:43 +02:00
changed_when: true
when: item.2 == 'up' and item.3 == ansible_distribution_version + '-RELEASE'
loop: '{{ iocage_jails }}'
loop_control:
label: 'iocage update {{ item.1 }}'
register: installupdates_iocage
2024-06-12 14:47:43 +02:00
- name: Show results of install updates (iocage)
ansible.builtin.debug:
verbosity: 1
msg: |
{% if item.false_condition is not defined -%}
Results of {{ item.cmd | join(' ') }}
{{ item.stdout | default(item.msg | default('No message')) }}
{% else %}
Update of {{ item.item.1 }} skipped due to the following conditional(s) being false
* {{ item.item.2 }} == 'up'
* {{ item.item.3 }} == {{ ansible_distribution_version }}-RELEASE
{% endif -%}
loop: '{{ installupdates_iocage.results }}'
loop_control:
label: 'Update of {{ item.item.1 }}'
when: installupdates_iocage