vbotka.freebsd.iocage module – FreeBSD iocage jail handling
Note
This module is part of the vbotka.freebsd collection (version 0.2.7).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install vbotka.freebsd.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: vbotka.freebsd.iocage.
Synopsis
The vbotka.freebsd.iocage module is wrapper to iocage command.
Requirements
The below requirements are needed on the host that executes this module.
lang/python >= 3.6
sysutils/iocage
Parameters
Parameter |
Comments |
|---|---|
Additional arguments of vbotka.freebsd.iocage applied to the Default: |
|
Update the fetch to the latest patch level when state=fetched. Fetch and install binary updates when Choices:
|
|
Clone the jail |
|
Uses a local file directory for the root directory instead of HTTP to downloads and/or updates releases. |
|
States States |
|
Path to a JSON file containing packages to install. Only applicable when creating a jail. |
|
Specify which plugin to fetch or update. |
|
|
|
State Choices:
|
|
Notes
Note
Supports
check_mode.There is no mandatory option.
The module always creates facts iocage_releases, iocage_templates, and iocage_jails
Returns module_args when debugging is set
ANSIBLE_DEBUG=true
See Also
See also
- iocage - A FreeBSD Jail Manager
iocage 1.2 documentation
- iocage - jail manager using ZFS and VNET
FreeBSD System Manager’s Manual
Examples
- name: Create Ansible facts iocage_*. This is the default state.
vbotka.freebsd.iocage:
state: facts
- name: Display lists of bases, plugins, templates, and jails
debug:
msg: |-
{{ iocage_releases }}
{{ iocage_plugins.keys()|list }}
{{ iocage_templates.keys()|list }}
{{ iocage_jails.keys()|list }}
- name: Fetch the remote host's version of base
vbotka.freebsd.iocage:
state: fetched
- name: Fetch base 13.0-RELEASE
vbotka.freebsd.iocage:
state: fetched
release: 13.0-RELEASE
- name: Fetch only components base.txz and doc.txz of the base 13.0-RELEASE
vbotka.freebsd.iocage:
state: fetched
release: 13.0-RELEASE
components: 'base.txz,doc.txz'
- name: Fetch plugin Tarsnap. Keep jails on failure.
vbotka.freebsd.iocage:
state: fetched
plugin: Tarsnap
args: -k
- name: Update or fetch components base.txz and doc.txz of the remote host's release.
Fetch plugin Tarsnap. Keep jails on failure.
vbotka.freebsd.iocage:
state: fetched
bupdate: true
components: 'base.txz,doc.txz'
plugin: Tarsnap
args: -k
- name: Update the jail. This will start the jail.
vbotka.freebsd.iocage:
state: present
bupdate: true
name: foo
- name: Start jail
vbotka.freebsd.iocage:
state: started
name: foo
- name: Start all jails
vbotka.freebsd.iocage:
state: started
name: ALL
- name: Start all jails with boot=on
vbotka.freebsd.iocage:
state: started
args: '--rc'
- name: Stop jail
vbotka.freebsd.iocage:
state: stopped
name: foo
- name: Stop all jails
vbotka.freebsd.iocage:
state: stopped
name: ALL
- name: Stop all jails with boot=on
vbotka.freebsd.iocage:
state: stopped
args: '--rc'
- name: Restart jail
vbotka.freebsd.iocage:
state: restarted
name: foo
- name: Restart all jails
vbotka.freebsd.iocage:
state: restarted
name: ALL
- name: Set IP address of the jail
vbotka.freebsd.iocage:
state: set
name: foo
properties:
vnet: 'on'
defaultrouter: 10.1.0.10
ip4_addr: 'vnet0|10.1.0.199/24'
- name: Create jail without cloning, install packages, and set properties.
Use release of the remote host.
vbotka.freebsd.iocage:
state: present
name: foo
pkglist: /path/to/pkglist.json
properties:
ip4_addr: 'vnet0|10.1.0.199/24'
boot: true
allow_sysvipc: true
defaultrouter: '10.1.0.1'
- name: Create template, install packages, and set properties.
Use release of the remote host.
vbotka.freebsd.iocage:
state: template
name: tplfoo
pkglist: /path/to/pkglist.json
properties:
ip4_addr: 'lo1|10.1.0.5'
boot: true
allow_sysvipc: true
defaultrouter: '10.1.0.1'
- name: Create a cloned jail. Creates basejail if needed.
vbotka.freebsd.iocage:
state: present
name: foo
clone_from: tplfoo
pkglist: /path/to/pkglist.json
properties:
ip4_addr: 'lo1|10.1.0.5'
boot: true
allow_sysvipc: true
defaultrouter: '10.1.0.1'
- name: Create a cloned jail. Name is automatically generated.
vbotka.freebsd.iocage:
state: present
clone_from: tplfoo
register: result
- name: Set variable contains the name of the created jail.
set_fact:
jname: "{{ result.uuid_short }}"
- name: Execute command in running jail
vbotka.freebsd.iocage:
state: exec
name: foo
cmd: service sshd start
- name: Execute pkg command in running jail
vbotka.freebsd.iocage:
state: pkg
name: foo
cmd: info
- name: Destroy jail
vbotka.freebsd.iocage:
state: absent
name: foo
Returned Facts
Facts returned by this module are added/updated in the hostvars host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.
Key |
Description |
|---|---|
Dictionary of all jails. Returned: always Sample: |
|
Dictionary of all plugins. Returned: always Sample: |
|
List of all bases. Returned: always Sample: |
|
Dictionary of all templates. Returned: always Sample: |
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Information on how the module was invoked. Returned: debug |
|
Automatically generated unique ID of a jail. Returned: States present, cloned, template, basejail, thickjail if name is |
|
First 8 characters of uuid. Set as a name of the jail. Returned: States present, cloned, template, basejail, thickjail if name is |