| 1 |
.. |
| 2 |
Copyright (c) Ansible Project |
| 3 |
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
|
| 6 |
.. _ansible_collections.community.general.docsite.guide_iocage.guide_iocage_inventory.guide_iocage_inventory_basics: |
| 7 |
|
| 8 |
Basics |
| 9 |
------ |
| 10 |
|
| 11 |
As root at the iocage host, create three VNET jails with a DHCP interface from the template |
| 12 |
*ansible_client*: |
| 13 |
|
| 14 |
.. code-block:: console |
| 15 |
|
| 16 |
shell> iocage create --template ansible_client --name srv_1 bpf=1 dhcp=1 vnet=1 |
| 17 |
srv_1 successfully created! |
| 18 |
shell> iocage create --template ansible_client --name srv_2 bpf=1 dhcp=1 vnet=1 |
| 19 |
srv_2 successfully created! |
| 20 |
shell> iocage create --template ansible_client --name srv_3 bpf=1 dhcp=1 vnet=1 |
| 21 |
srv_3 successfully created! |
| 22 |
|
| 23 |
See: `Configuring VNET <https://freebsd.github.io/iocage/networking.html#vimage-vnet>`_. |
| 24 |
|
| 25 |
As admin at the controller, list the jails: |
| 26 |
|
| 27 |
.. code-block:: console |
| 28 |
|
| 29 |
shell> ssh [email protected] iocage list -l |
| 30 |
+------+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+ |
| 31 |
| JID | NAME | BOOT | STATE | TYPE | RELEASE | IP4 | IP6 | TEMPLATE | BASEJAIL | |
| 32 |
+======+=======+======+=======+======+=================+====================+=====+================+==========+ |
| 33 |
| None | srv_1 | off | down | jail | 14.2-RELEASE-p3 | DHCP (not running) | - | ansible_client | no | |
| 34 |
+------+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+ |
| 35 |
| None | srv_2 | off | down | jail | 14.2-RELEASE-p3 | DHCP (not running) | - | ansible_client | no | |
| 36 |
+------+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+ |
| 37 |
| None | srv_3 | off | down | jail | 14.2-RELEASE-p3 | DHCP (not running) | - | ansible_client | no | |
| 38 |
+------+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+ |
| 39 |
|
| 40 |
Create the inventory file ``hosts/02_iocage.yml`` |
| 41 |
|
| 42 |
.. code-block:: yaml |
| 43 |
|
| 44 |
plugin: community.general.iocage |
| 45 |
host: 10.1.0.73 |
| 46 |
user: admin |
| 47 |
|
| 48 |
Display the inventory: |
| 49 |
|
| 50 |
.. code-block:: console |
| 51 |
|
| 52 |
shell> ansible-inventory -i hosts/02_iocage.yml --list --yaml |
| 53 |
all: |
| 54 |
children: |
| 55 |
ungrouped: |
| 56 |
hosts: |
| 57 |
srv_1: |
| 58 |
iocage_basejail: 'no' |
| 59 |
iocage_boot: 'off' |
| 60 |
iocage_ip4: '-' |
| 61 |
iocage_ip4_dict: |
| 62 |
ip4: [] |
| 63 |
msg: DHCP (not running) |
| 64 |
iocage_ip6: '-' |
| 65 |
iocage_jid: None |
| 66 |
iocage_release: 14.2-RELEASE-p3 |
| 67 |
iocage_state: down |
| 68 |
iocage_template: ansible_client |
| 69 |
iocage_type: jail |
| 70 |
srv_2: |
| 71 |
iocage_basejail: 'no' |
| 72 |
iocage_boot: 'off' |
| 73 |
iocage_ip4: '-' |
| 74 |
iocage_ip4_dict: |
| 75 |
ip4: [] |
| 76 |
msg: DHCP (not running) |
| 77 |
iocage_ip6: '-' |
| 78 |
iocage_jid: None |
| 79 |
iocage_release: 14.2-RELEASE-p3 |
| 80 |
iocage_state: down |
| 81 |
iocage_template: ansible_client |
| 82 |
iocage_type: jail |
| 83 |
srv_3: |
| 84 |
iocage_basejail: 'no' |
| 85 |
iocage_boot: 'off' |
| 86 |
iocage_ip4: '-' |
| 87 |
iocage_ip4_dict: |
| 88 |
ip4: [] |
| 89 |
msg: DHCP (not running) |
| 90 |
iocage_ip6: '-' |
| 91 |
iocage_jid: None |
| 92 |
iocage_release: 14.2-RELEASE-p3 |
| 93 |
iocage_state: down |
| 94 |
iocage_template: ansible_client |
| 95 |
iocage_type: jail |
| 96 |
|
| 97 |
Optionally, create shared IP jails: |
| 98 |
|
| 99 |
.. code-block:: console |
| 100 |
|
| 101 |
shell> iocage create --template ansible_client --name srv_1 ip4_addr="em0|10.1.0.101/24" |
| 102 |
srv_1 successfully created! |
| 103 |
shell> iocage create --template ansible_client --name srv_2 ip4_addr="em0|10.1.0.102/24" |
| 104 |
srv_2 successfully created! |
| 105 |
shell> iocage create --template ansible_client --name srv_3 ip4_addr="em0|10.1.0.103/24" |
| 106 |
srv_3 successfully created! |
| 107 |
shell> iocage list -l |
| 108 |
+------+-------+------+-------+------+-----------------+-------------------+-----+----------------+----------+ |
| 109 |
| JID | NAME | BOOT | STATE | TYPE | RELEASE | IP4 | IP6 | TEMPLATE | BASEJAIL | |
| 110 |
+======+=======+======+=======+======+=================+===================+=====+================+==========+ |
| 111 |
| None | srv_1 | off | down | jail | 14.2-RELEASE-p3 | em0|10.1.0.101/24 | - | ansible_client | no | |
| 112 |
+------+-------+------+-------+------+-----------------+-------------------+-----+----------------+----------+ |
| 113 |
| None | srv_2 | off | down | jail | 14.2-RELEASE-p3 | em0|10.1.0.102/24 | - | ansible_client | no | |
| 114 |
+------+-------+------+-------+------+-----------------+-------------------+-----+----------------+----------+ |
| 115 |
| None | srv_3 | off | down | jail | 14.2-RELEASE-p3 | em0|10.1.0.103/24 | - | ansible_client | no | |
| 116 |
+------+-------+------+-------+------+-----------------+-------------------+-----+----------------+----------+ |
| 117 |
|
| 118 |
See: `Configuring a Shared IP Jail <https://freebsd.github.io/iocage/networking.html#shared-ip>`_ |
| 119 |
|
| 120 |
If iocage needs environment variable(s), use the option :ansopt:`community.general.iocage#inventory:env`. For example, |
| 121 |
|
| 122 |
.. code-block:: yaml |
| 123 |
|
| 124 |
plugin: community.general.iocage |
| 125 |
host: 10.1.0.73 |
| 126 |
user: admin |
| 127 |
env: |
| 128 |
CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1 |