011 Display variables iocage_*¶
Extending example 010.
Use case¶
Display all variables iocage_* created by the inventory plugin vbotka.freebsd.iocage plugin.
Tree¶
shell> tree .
.
├── ansible.cfg
├── iocage.yml
└── pb-vars-all.yml
Synopsis¶
In a selected jail, display all variables iocage_* created by the inventory plugin in 010 Clone basejails and create inventory (plugins).
Requirements¶
Configuration ansible.cfg¶
[defaults]
gathering = explicit
callback_result_format = yaml
[connection]
pipelining = true
Inventory iocage.yml¶
plugin: vbotka.freebsd.iocage
host: 10.1.0.73
user: admin
env:
CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1
get_properties: False
cache: False
strict: True
compose:
ansible_host: iocage_ip4
release: iocage_release | split('-') | first
release_major: iocage_release | split('-') | first | split('.') | first
release_minor: iocage_release | split('-') | first | split('.') | last
groups:
test: inventory_hostname.startswith('test')
keyed_groups:
- prefix: distro
key: iocage_release
- prefix: state
key: iocage_state
Playbook pb-vars-all.yml¶
- hosts: all
tasks:
- debug:
msg: |
inventory_hostname: {{ inventory_hostname }}
ansible_host: {{ ansible_host }}
{% for var in q('varnames', 'iocage_*') %}
{{ var }}: {{ lookup('vars', var) }}
{% endfor %}
Playbook output¶
(env) > ansible-playbook pb-vars-all.yml -i iocage.yml -l test_113
PLAY [all] *********************************************************************
TASK [debug] *******************************************************************
ok: [test_113] =>
msg: |-
inventory_hostname: test_113
ansible_host: 10.1.0.113
iocage_jid: 60
iocage_boot: off
iocage_state: up
iocage_type: jail
iocage_release: 14.1-RELEASE-p6
iocage_ip4_dict: {'ip4': [{'ifc': 'em0', 'ip': '10.1.0.113', 'mask': '24'}], 'msg': ''}
iocage_ip4: 10.1.0.113
iocage_ip6: -
iocage_template: ansible_client
iocage_basejail: yes
PLAY RECAP *********************************************************************
test_113: ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0