--- - 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: | Results of {{ item.cmd | join(' ') }} {{ item.stdout | default(item.msg | default('No message')) }} loop: '{{ installupdates_iocage.results }}' loop_control: label: '{{ item.cmd | join(" ") }}' when: installupdates_iocage when: iocage_available.stat.exists