Basics

As root at the iocage host, create three VNET jails with a DHCP interface from the template ansible_client:

shell> iocage create --template ansible_client --name srv_1 bpf=1 dhcp=1 vnet=1
srv_1 successfully created!
shell> iocage create --template ansible_client --name srv_2 bpf=1 dhcp=1 vnet=1
srv_2 successfully created!
shell> iocage create --template ansible_client --name srv_3 bpf=1 dhcp=1 vnet=1
srv_3 successfully created!

See: Configuring a VNET Jail.

As admin at the controller, list the jails:

shell> ssh [email protected] iocage list -l
+------+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| JID  | NAME  | BOOT | STATE | TYPE |     RELEASE     |        IP4         | IP6 |    TEMPLATE    | BASEJAIL |
+======+=======+======+=======+======+=================+====================+=====+================+==========+
| None | srv_1 | off  | down  | jail | 14.2-RELEASE-p3 | DHCP (not running) | -   | ansible_client | no       |
+------+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| None | srv_2 | off  | down  | jail | 14.2-RELEASE-p3 | DHCP (not running) | -   | ansible_client | no       |
+------+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| None | srv_3 | off  | down  | jail | 14.2-RELEASE-p3 | DHCP (not running) | -   | ansible_client | no       |
+------+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+

Create the inventory file hosts/02_iocage.yml

plugin: community.general.iocage
host: 10.1.0.73
user: admin

Display the inventory:

shell> ansible-inventory -i hosts/02_iocage.yml --list --yaml
all:
  children:
    ungrouped:
      hosts:
        srv_1:
          iocage_basejail: 'no'
          iocage_boot: 'off'
          iocage_ip4: '-'
          iocage_ip4_dict:
            ip4: []
            msg: DHCP (not running)
          iocage_ip6: '-'
          iocage_jid: None
          iocage_release: 14.2-RELEASE-p3
          iocage_state: down
          iocage_template: ansible_client
          iocage_type: jail
        srv_2:
          iocage_basejail: 'no'
          iocage_boot: 'off'
          iocage_ip4: '-'
          iocage_ip4_dict:
            ip4: []
            msg: DHCP (not running)
          iocage_ip6: '-'
          iocage_jid: None
          iocage_release: 14.2-RELEASE-p3
          iocage_state: down
          iocage_template: ansible_client
          iocage_type: jail
        srv_3:
          iocage_basejail: 'no'
          iocage_boot: 'off'
          iocage_ip4: '-'
          iocage_ip4_dict:
            ip4: []
            msg: DHCP (not running)
          iocage_ip6: '-'
          iocage_jid: None
          iocage_release: 14.2-RELEASE-p3
          iocage_state: down
          iocage_template: ansible_client
          iocage_type: jail

Optionally, create shared IP jails:

shell> iocage create --template ansible_client --name srv_1 ip4_addr="em0|10.1.0.101/24"
srv_1 successfully created!
shell> iocage create --template ansible_client --name srv_2 ip4_addr="em0|10.1.0.102/24"
srv_2 successfully created!
shell> iocage create --template ansible_client --name srv_3 ip4_addr="em0|10.1.0.103/24"
srv_3 successfully created!
shell> iocage list -l
+------+-------+------+-------+------+-----------------+-------------------+-----+----------------+----------+
| JID  | NAME  | BOOT | STATE | TYPE |     RELEASE     |        IP4        | IP6 |    TEMPLATE    | BASEJAIL |
+======+=======+======+=======+======+=================+===================+=====+================+==========+
| None | srv_1 | off  | down  | jail | 14.2-RELEASE-p3 | em0|10.1.0.101/24 | -   | ansible_client | no       |
+------+-------+------+-------+------+-----------------+-------------------+-----+----------------+----------+
| None | srv_2 | off  | down  | jail | 14.2-RELEASE-p3 | em0|10.1.0.102/24 | -   | ansible_client | no       |
+------+-------+------+-------+------+-----------------+-------------------+-----+----------------+----------+
| None | srv_3 | off  | down  | jail | 14.2-RELEASE-p3 | em0|10.1.0.103/24 | -   | ansible_client | no       |
+------+-------+------+-------+------+-----------------+-------------------+-----+----------------+----------+

See: Configuring a Shared IP Jail

If iocage needs environment variable(s), use the option env. For example,

plugin: community.general.iocage
host: 10.1.0.73
user: admin
env:
  CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1