210 Test empty iocage notes
Use case
Test empty iocage notes. Create iocage_tags. The result should be an empty
dictionary.
Tree
shell> tree .
.
├── ansible.cfg
├── hosts
│ └── 06_iocage.yml
├── iocage.ini
├── pb-iocage.yml
└── pb-test.yml
Synopsis
On a managed node:
In the playbook
pb-iocage.yml, run the commandiocage get notes test-210and display the result.In the playbook
pb-test.yml, use the inventory vbotka.freebsd.iocage to create and displayiocage_tags.
Requirements
Notes
TBD
See also
ansible.cfg
[defaults]
callback_result_format = yaml
deprecation_warnings = False
display_skipped_hosts = False
gathering = explicit
interpreter_python = auto_silent
log_path = /var/log/ansible.log
[connection]
pipelining = true
Inventory iocage.ini
iocage_06
[iocage]
iocage_06
[iocage:vars]
ansible_user=admin
ansible_python_interpreter=auto_silent
hosts
hosts/06_iocage.yml
plugin: vbotka.freebsd.iocage
host: iocage_06
user: admin
get_properties: true
compose:
iocage_tags: dict(iocage_properties.notes | regex_findall('(\w+)=([\w\-]+)'))
Jails
[iocage_06]# iocage list -l
+------+---------------+------+-------+------+-----------------+-----------------------+-----+------------------+----------+
| JID | NAME | BOOT | STATE | TYPE | RELEASE | IP4 | IP6 | TEMPLATE | BASEJAIL |
+======+===============+======+=======+======+=================+=======================+=====+==================+==========+
| 1 | log-server-01 | on | up | jail | 15.1-RELEASE-p1 | vnet0|172.16.99.10/24 | - | ansible-init | no |
+------+---------------+------+-------+------+-----------------+-----------------------+-----+------------------+----------+
| 2 | pkg-repo | on | up | jail | 15.1-RELEASE-p1 | vnet0|172.16.99.23/24 | - | ansible-pkg-repo | no |
+------+---------------+------+-------+------+-----------------+-----------------------+-----+------------------+----------+
| 3 | repos | on | up | jail | 15.1-RELEASE-p1 | vnet0|172.16.99.21/24 | - | ansible-repos | no |
+------+---------------+------+-------+------+-----------------+-----------------------+-----+------------------+----------+
| 4 | repos-devel | on | up | jail | 15.1-RELEASE-p1 | vnet0|172.16.99.22/24 | - | ansible-repos | no |
+------+---------------+------+-------+------+-----------------+-----------------------+-----+------------------+----------+
| None | test-210 | off | down | jail | 15.1-RELEASE-p1 | - | - | - | no |
+------+---------------+------+-------+------+-----------------+-----------------------+-----+------------------+----------+
Playbook pb-iocage.yml
- name: Test empty iocage notes.
hosts: iocage_06
tasks:
- command: iocage get notes test-210
register: out
- debug:
msg: |
out.stdout: {{ out.stdout }}
out.stdout type: {{ out.stdout | type_debug }}
Playbook output - Display empty notes
(env) > ansible-playbook -i iocage.ini pb-iocage.yml
PLAY [Test empty iocage notes.] ************************************************
TASK [command] *****************************************************************
changed: [iocage_06]
TASK [debug] *******************************************************************
ok: [iocage_06] =>
msg: |-
out.stdout: none
out.stdout type: str
PLAY RECAP *********************************************************************
iocage_06 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Playbook pb-test.yml
- name: Test empty iocage notes.
hosts: test-210
tasks:
- debug:
msg: |
iocage_properties.notes: {{ iocage_properties.notes }}
iocage_properties.notes type: {{ iocage_properties.notes | type_debug }}
- debug:
var: iocage_tags