# 003 Audit iocage host

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

  - Audit iocage

## Requirements

- Role vbotka.freebsd.iocage

- root privilege on the iocage hosts

- Binary iocage

## 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 sanity is enabled ‘freebsd_iocage_sanity: true’

See also

- See the tasks roles/iocage/tasks/sanity.yml

- See the default variables roles/iocage/main/sanity.yml

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

    freebsd_iocage_sanity_zfs_pool_active: true

## host_vars/iocage_02/iocage.yml

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

    freebsd_iocage_pool: zroot
    freebsd_iocage_pool_mount: /zroot

    freebsd_iocage_sanity_zfs_pool_active: true

Note

By default, the activation testing is disabled ‘freebsd_iocage_sanity_zfs_pool_active: false’

## Playbook pb-iocage.yml

    - hosts: iocage
      gather_facts: true

      roles:

        - vbotka.freebsd.iocage

## Playbook output - test sanity

    (env) > ansible-playbook pb-iocage.yml -i iocage-hosts.ini \
                                           -l iocage_02 \
    				       -t freebsd_iocage_sanity

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

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

    TASK [vbotka.freebsd.iocage : Sanity: Debug service start, restart, and stop freebsd_iocage_debug=False] ***
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Service start, restart, and stop are mutually exclusive] ***
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Get environment.] ************************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Debug mounts freebsd_iocage_debug=False] ***
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Environment LANG = en_US.UTF-8] **********
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Environment LC_COLLATE = C] **************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Get mounts] ******************************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Debug mounts freebsd_iocage_debug=False] ***
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: /dev/fd mounted to fdescfs] **************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Get sysctl kern.conftxt] *****************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Debug result freebsd_iocage_debug=False] ***
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Mandatory kernel options VIMAGE, RACCT, and RCTL.] ***
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Kernel nooptions SCTP.] ******************
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Read /boot/loader.conf] ******************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Debug loader_dict freebsd_iocage_debug=False] ***
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: kern.racct.enable = 1] *******************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Get sysctl security.jail.jailed] *********
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Debug result freebsd_iocage_debug=False] ***
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Not in jail.] ****************************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Get ZFS pools.] **************************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Debug result freebsd_iocage_debug=False] ***
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: ZFS pool exists.] ************************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Get ZFS datasets.] ***********************
    ok: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: Debug result freebsd_iocage_debug=False] ***
    skipping: [iocage_02]

    TASK [vbotka.freebsd.iocage : Sanity: ZFS pool activated.] *********************
    ok: [iocage_02]

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

## Playbook output - test sanity quietly

    (env) > ANSIBLE_DISPLAY_OK_HOSTS=false \
            ANSIBLE_DISPLAY_SKIPPED_HOSTS=false \
    	ansible-playbook pb-iocage.yml -i iocage-hosts.ini \
    	                               -l iocage_02 \
    				       -t freebsd_iocage_sanity

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

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

See also

- ANSIBLE_DISPLAY_OK_HOSTS

- ANSIBLE_DISPLAY_SKIPPED_HOSTS