002 Activate iocage
Use case
Use the role vbotka.freebsd.iocage to activate iocage.
Tree
shell> tree
.
├── ansible.cfg
├── host_vars
│ ├── iocage_02
│ │ └── iocage.yml
│ ├── iocage_04
│ │ └── iocage.yml
│ └── iocage_06
│ └── iocage.yml
├── iocage.ini
└── pb-iocage.yml
Synopsis
On a managed node, use the playbook
pb-iocage.ymland the role vbotka.freebsd.iocage to:Activate iocage
Requirements
Root privileges on the managed nodes
The iocage binary
Notes
Pass
-l iocage_0Xon the command line to run the play on the managed nodeiocage_0X.Remove the limit
-l iocage_0*to run the play on all managed nodes.By default,
iocageactivation is disabled:freebsd_iocage_activate: false.
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_02 ansible_host=10.1.0.73
iocage_04 ansible_host=10.1.0.29
iocage_06
[iocage]
iocage_02
iocage_04
iocage_06
[iocage:vars]
ansible_user=admin
ansible_become=true
ansible_python_interpreter=auto_silent
host_vars
host_vars/iocage_02/iocage.yml
freebsd_iocage_pool: zroot
freebsd_iocage_pool_mount: /zroot
host_vars/iocage_04/iocage.yml
freebsd_iocage_pool: iocage
freebsd_iocage_pool_mount: /iocage
host_vars/iocage_06/iocage.yml
freebsd_iocage_pool: zroot
freebsd_iocage_pool_mount: /zroot
Note
Activation is skipped if the directory
freebsd_iocage_mountexists.The variable
freebsd_iocage_mountis declared indefaults/main/main.yml:freebsd_iocage_mount: "{{ freebsd_iocage_pool_mount }}/iocage"
Playbook pb-iocage.yml
- hosts: iocage
gather_facts: true
roles:
- vbotka.freebsd.iocage
Playbook output - Activate iocage
(env) > ansible-playbook -i iocage.ini -l iocage_06 \
-t freebsd_iocage_activate \
-e freebsd_iocage_activate=true \
-e freebsd_iocage_debug=true \
pb-iocage.yml
PLAY [iocage] ******************************************************************
TASK [Gathering Facts] *********************************************************
ok: [iocage_06]
TASK [vbotka.freebsd.iocage : Activate: Activate iocage pool zroot] ************
ok: [iocage_06]
TASK [vbotka.freebsd.iocage : Activate: Debug result freebsd_iocage_debug=true] ***
ok: [iocage_06] =>
result:
changed: false
cmd:
- iocage
- activate
- zroot
delta: null
end: null
failed: false
msg: Did not run command since '/zroot/iocage' exists
rc: 0
start: null
stderr: ''
stderr_lines: []
stdout: skipped, since /zroot/iocage exists
stdout_lines:
- skipped, since /zroot/iocage exists
PLAY RECAP *********************************************************************
iocage_06 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Note
This debug output shows the result of an already activated iocage.