ansible/tasks/update_iocage_freebsd.yml

53 lines
1.6 KiB
YAML

---
- name: Check if iocage is available
stat:
path: /usr/local/bin/iocage
tags:
- always
register: iocage_available
- block:
- name: List iocage jails
command:
cmd: /usr/local/bin/iocage list -H
check_mode: false
register: iocage_list_jails
- name: show results of list jails (iocage)
debug:
verbosity: 1
var: iocage_list_jails
- name: set iocage jails
ansible.builtin.set_fact:
iocage_jails: '{{ iocage_list_jails.stdout_lines | map("split") }}'
- name: Install updates (iocage)
command:
cmd: '/usr/local/bin/iocage update {{ item.1 }}'
environment:
PAGER: cat
when: item.2 == 'up' and item.3 == ansible_distribution_version + '-RELEASE'
loop: '{{ iocage_jails }}'
loop_control:
label: 'iocage update {{ item.1 }}'
register: installupdates_iocage
- name: show results of install updates (iocage)
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
when: iocage_available.stat.exists