# 001 Debug variables and install 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:

  - display variables

  - install iocage package.

## Requirements

- Role vbotka.freebsd.iocage

- root privilege on the iocage hosts

## 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.

- In this case, debug displays the role defaults.

- By default, iocage installation is enabled ‘freebsd_iocage_install: true’

- By default, debug is disabled ‘freebsd_iocage_debug: false’ .

See also

- Patterns: targeting hosts and groups

- Variable precedence: Where should I put a variable?

## 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

See also

- How to build your inventory

- Connection methods and details

- Understanding privilege escalation: become

## host_vars/iocage_01/iocage.yml

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

## host_vars/iocage_02/iocage.yml

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

See also

Setting the Python interpreter

## Playbook pb-iocage.yml

    - hosts: iocage
      gather_facts: true

      roles:

        - vbotka.freebsd.iocage

See also

Ansible playbooks

## Playbook output - display debug

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

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

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

    TASK [vbotka.freebsd.iocage : Debug iocage freebsd_iocage_debug=true] **********
    ok: [iocage_02] =>
      msg: |-
        freebsd_iocage_role_version: 0.2.5

        ansible_architecture: amd64
        ansible_os_family: FreeBSD
        ansible_distribution: FreeBSD
        ansible_distribution_major_version: 14
        ansible_distribution_version: 14.1
        ansible_distribution_release: 14.1-RELEASE
        ansible_python_version: 3.11.9

        freebsd_install_method: packages
        freebsd_use_packages: True
        freebsd_install_retries: 10
        freebsd_install_delay: 5

        freebsd_iocage_install: True
        freebsd_iocage_packages:
          - sysutils/iocage

        freebsd_iocage_enable: True
        freebsd_iocage_start: False
        freebsd_iocage_restart: False
        freebsd_iocage_stop: False

        freebsd_iocage_backup_conf: False
        freebsd_iocage_assert_quiet: True

        freebsd_iocage_pool: zroot
        freebsd_iocage_pool_mount: /mnt/zroot
        freebsd_iocage_mount: /mnt/zroot/iocage

        freebsd_iocage_activate: False
        freebsd_iocage_activate_fatal: True

        freebsd_iocage_sanity: True
        freebsd_iocage_sanity_service: True
        freebsd_iocage_sanity_env: True
        freebsd_iocage_sanity_fdesc: True
        freebsd_iocage_sanity_kernel: True
        freebsd_iocage_sanity_kernel_sctp: False
        freebsd_iocage_sanity_loader: True
        freebsd_iocage_sanity_injail: True
        freebsd_iocage_sanity_zfs: True
        freebsd_iocage_sanity_zfs_pool_exists: True
        freebsd_iocage_sanity_zfs_pool_active: False

        freebsd_iocage_lang: en_US.UTF-8
        freebsd_iocage_env:
          CRYPTOGRAPHY_OPENSSL_NO_LEGACY: '1'

        freebsd_iocage_sysctl_update:
          {}

        freebsd_iocage_defaults_override_int: False
        freebsd_iocage_defaults_override_bool: False
        freebsd_iocage_defaults_update:
          {}

        freebsd_iocage_data: False
        freebsd_iocage_data_mount_enable: False
        freebsd_iocage_data_fstab: False
        freebsd_iocage_data_root: zroot/iocage-data
        freebsd_iocage_data_mount: /mnt/zroot/iocage-data
        freebsd_iocage_data_dir: mnt
        freebsd_iocage_data_jails:
          {}

        freebsd_iocage_stat: False
        freebsd_iocage_stat_fatal: True

        freebsd_iocage_runner: False
        freebsd_iocage_runner_fatal: True
        freebsd_iocage_runner_env:
          {}

        freebsd_iocage_runner_exec:
        freebsd_iocage_runner_cmd:
          {}

        freebsd_iocage_clean: False
        freebsd_iocage_clean_jails:
          {}

    PLAY RECAP *********************************************************************
    iocage_02: ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

See also

ansible-playbook

## Playbook output - install iocage

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

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

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

    TASK [vbotka.freebsd.iocage : Pkg: Install iocage packages.] *******************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Pkg: Debug Install iocage packages freebsd_iocage_debug=true] ***
    ok: [iocage_02] =>
      result:
        attempts: 1
        changed: false
        failed: false
        msg: package(s) already present
        stderr: ''
        stderr_lines: []
        stdout: |-
          Updating FreeBSD repository catalogue...
          FreeBSD repository is up to date.
          Updating build repository catalogue...
          Fetching meta.conf: . done
          Fetching data.pkg: .......... done
          Processing entries: .......... done
          build repository update completed. 505 packages processed.
          All repositories are up to date.
        stdout_lines:
        - Updating FreeBSD repository catalogue...
        - FreeBSD repository is up to date.
        - Updating build repository catalogue...
        - 'Fetching meta.conf: . done'
        - 'Fetching data.pkg: .......... done'
        - 'Processing entries: .......... done'
        - build repository update completed. 505 packages processed.
        - All repositories are up to date.

    TASK [vbotka.freebsd.iocage : Pkg: Install iocage ports.] **********************
    skipping: [iocage_02] => (item=sysutils/iocage)
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Pkg: Debug install iocage ports freebsd_iocage_debug=true] ***
    skipping: [iocage_02]

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

Note

This debug shows the result of already installed package.