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.ini
└── pb-iocage.yml

Synopsis

Requirements

Notes

  • Put -l iocage_02 into the run-strings to run the play on the managed node iocage_02

  • Remove the limits -l iocage_0* to run the play on all managed nodes.

  • By default, iocage activation is disabled freebsd_iocage_activate: false

See also

ansible.cfg

[defaults]
gathering = explicit
callback_result_format = yaml
display_skipped_hosts = false

[connection]
pipelining = true

Inventory iocage.ini

iocage_02 ansible_host=10.1.0.73
iocage_04 ansible_host=10.1.0.29

[iocage]
iocage_02
iocage_04

[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

Note

  • The activation will be skipped if the directory freebsd_iocage_mount exists.

  • The variable freebsd_iocage_mount is declared in defaults/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 pb-iocage.yml -i iocage.ini -l iocage_04 \
                                       -t freebsd_iocage_activate \
                                       -e freebsd_iocage_activate=true \
                                       -e freebsd_iocage_debug=true
PLAY [iocage] ******************************************************************

TASK [Gathering Facts] *********************************************************
ok: [iocage_04]

TASK [vbotka.freebsd.iocage : Activate: Activate iocage pool iocage] ***********
ok: [iocage_04]

TASK [vbotka.freebsd.iocage : Activate: Debug result freebsd_iocage_debug=true] ***
ok: [iocage_04] => 
    result:
        changed: false
        cmd:
        - iocage
        - activate
        - iocage
        delta: null
        end: null
        failed: false
        msg: Did not run command since '/iocage/iocage' exists
        rc: 0
        start: null
        stderr: ''
        stderr_lines: []
        stdout: skipped, since /iocage/iocage exists
        stdout_lines:
        - skipped, since /iocage/iocage exists

PLAY RECAP *********************************************************************
iocage_04                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Note

This debug shows the result of already activated iocage.