(WIP) 031 Display iocage lists and dictionaries.¶
Tree¶
shell> tree .
.
├── ansible.cfg
├── iocage-hosts.ini
└── pb-iocage-display-lists.yml
Synopsis¶
On two iocage hosts:
iocage_01
iocage_02
In the playbook pb-iocage-display-lists.yml, use the module vbotka.freebsd.iocage to:
create and display iocage lists and dictionaries.
Notes¶
Quoting from man iocage:
list List the specified dataset type. By default, all jails are
listed.
Options:
[--http] Changes [-R | --remote] to use HTTP.
[-H | -h | --header] Used in scripting. Use tabs for sepa-
rators.
[-P | --plugins] Shows plugins installed on the system.
[-PRO] Lists official plugins available for
download.
[-R | --remote] Shows available RELEASE options for re-
mote.
[-b | -r | --base | --release | dataset_type]
List all bases.
[-l | --long] Shows JID, NAME, BOOT, STATE, TYPE, RE-
LEASE, IP4, IP6, and TEMPLATE informa-
tion.
[-q | --quick] Lists all jails with less processing
and fields.
[-s | --sort TEXT] Sorts the list by the given type.
[-t | --template | dataset_type]
Lists all templates.
Configuration ansible.cfg¶
[defaults]
gathering = explicit
stdout_callback = yaml
[connection]
pipelining = true
Inventory iocage-hosts.ini¶
iocage_01 ansible_host=10.1.0.18
iocage_02 ansible_host=10.1.0.73
[iocage]
iocage_01
iocage_02
[iocage:vars]
ansible_user=admin
ansible_become=true
ansible_python_interpreter=auto_silent
Playbook pb-iocage-display-lists.yml¶
- name: Display iocage lists and dictionaries.
hosts: iocage
environment:
CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1
vars:
ansible_become_password: admin
tasks:
- name: Set iocage lists and dictionaries.
vbotka.freebsd.iocage:
- name: Display iocage lists and dictionaries (omit properties).
vars:
keys: "{{ iocage_jails.keys() }}"
vals: "{{ iocage_jails.values()
| list
| community.general.remove_keys(target=['properties']) }}"
ansible.builtin.debug:
msg: |
iocage_releases: {{ iocage_releases }}
iocage_plugins:
{{ iocage_plugins | to_nice_yaml(indent=2) | indent(2) }}
iocage_templates:
{{ iocage_templates | to_nice_yaml(indent=2) | indent(2) }}
iocage_jails:
{{ dict(keys|zip(vals)) | to_nice_yaml(indent=2) | indent(2) }}
- name: "Display iocage jails properties={{ properties | d(false) }}"
when: properties | d(false) | bool
ansible.builtin.debug:
msg: |
iocage_jails:
{{ iocage_jails | to_nice_yaml(indent=2) | indent(2) }}
Playbook output¶
(env) > ansible-playbook pb-iocage-display-lists.yml -i iocage-hosts.ini