002 Activate iocage

Tree

shell> tree
.
├── ansible.cfg
├── host_vars
│   ├── iocage_01
│   │   └── iocage.yml
│   └── iocage_02
│       └── iocage.yml
├── iocage-hosts.ini
└── pb-iocage.yml

Synopsis

  • On the iocage host iocage_02

    In the playbook pb-iocage.yml, use the role vbotka.freebsd.iocage to:

    • activate iocage

Requirements

Notes

  • Put -l iocage_01 into the run-strings to run the play on the iocage host iocage_01

  • Remove the limits -l iocage_0* to run the play on both iocage hosts.

  • By default, iocage activation is disabled freebsd_iocage_activate: false

See also

Configuration ansible.cfg

[defaults]
gathering = explicit
callback_result_format = 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

host_vars/iocage_01/iocage.yml

ansible_python_interpreter: /usr/local/bin/python3.9

freebsd_iocage_pool: pool2
freebsd_iocage_pool_mount: /mnt/pool2

host_vars/iocage_02/iocage.yml

ansible_python_interpreter: /usr/local/bin/python3.11

freebsd_iocage_pool: zroot
freebsd_iocage_pool_mount: /zroot

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 - display debug

(env) > ansible-playbook pb-iocage.yml -i iocage-hosts.ini \
                                       -l iocage_02 \
				       -t freebsd_iocage_activate \
				       -e freebsd_iocage_activate=true \
				       -e freebsd_iocage_debug=true

PLAY [iocage] ******************************************************************

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

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

TASK [vbotka.freebsd.iocage : Activate: Debug result freebsd_iocage_debug=true] ***
ok: [iocage_02] => 
  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_02: ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Note

This debug shows the result of already activated iocage.