Debian Codegraph @

ansible_collections/community/general/docs/docsite/rst/guide_iocage_inventory_dhcp.rst

raw
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_dhcp:
7
8 DHCP
9 ----
10
11 As root at the iocage host, start the jails:
12
13 .. code-block:: console
14
15 shell> iocage start ALL
16 No default gateway found for ipv6.
17 * Starting srv_1
18 + Started OK
19 + Using devfs_ruleset: 1000 (iocage generated default)
20 + Configuring VNET OK
21 + Using IP options: vnet
22 + Starting services OK
23 + Executing poststart OK
24 + DHCP Address: 10.1.0.183/24
25 No default gateway found for ipv6.
26 * Starting srv_2
27 + Started OK
28 + Using devfs_ruleset: 1001 (iocage generated default)
29 + Configuring VNET OK
30 + Using IP options: vnet
31 + Starting services OK
32 + Executing poststart OK
33 + DHCP Address: 10.1.0.204/24
34 No default gateway found for ipv6.
35 * Starting srv_3
36 + Started OK
37 + Using devfs_ruleset: 1002 (iocage generated default)
38 + Configuring VNET OK
39 + Using IP options: vnet
40 + Starting services OK
41 + Executing poststart OK
42 + DHCP Address: 10.1.0.169/24
43 Please convert back to a jail before trying to start ansible_client
44
45 List the jails:
46
47 .. code-block:: console
48
49 shell> iocage list -l
50 +-----+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
51 | JID | NAME | BOOT | STATE | TYPE | RELEASE | IP4 | IP6 | TEMPLATE | BASEJAIL |
52 +=====+=======+======+=======+======+=================+====================+=====+================+==========+
53 | 204 | srv_1 | off | up | jail | 14.2-RELEASE-p3 | epair0b|10.1.0.183 | - | ansible_client | no |
54 +-----+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
55 | 205 | srv_2 | off | up | jail | 14.2-RELEASE-p3 | epair0b|10.1.0.204 | - | ansible_client | no |
56 +-----+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
57 | 206 | srv_3 | off | up | jail | 14.2-RELEASE-p3 | epair0b|10.1.0.169 | - | ansible_client | no |
58 +-----+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
59
60 As admin at the controller, list the jails. The IP4 tab says "... address requires root":
61
62 .. code-block:: console
63
64 shell> ssh [email protected] iocage list -l
65 +-----+-------+------+-------+------+-----------------+-----------------------------------------+-----+----------------+----------+
66 | JID | NAME | BOOT | STATE | TYPE | RELEASE | IP4 | IP6 | TEMPLATE | BASEJAIL |
67 +=====+=======+======+=======+======+=================+=========================================+=====+================+==========+
68 | 204 | srv_1 | off | up | jail | 14.2-RELEASE-p3 | DHCP (running -- address requires root) | - | ansible_client | no |
69 +-----+-------+------+-------+------+-----------------+-----------------------------------------+-----+----------------+----------+
70 | 205 | srv_2 | off | up | jail | 14.2-RELEASE-p3 | DHCP (running -- address requires root) | - | ansible_client | no |
71 +-----+-------+------+-------+------+-----------------+-----------------------------------------+-----+----------------+----------+
72 | 206 | srv_3 | off | up | jail | 14.2-RELEASE-p3 | DHCP (running -- address requires root) | - | ansible_client | no |
73 +-----+-------+------+-------+------+-----------------+-----------------------------------------+-----+----------------+----------+
74
75 Use sudo if enabled:
76
77 .. code-block:: console
78
79 shell> ssh [email protected] sudo iocage list -l
80 +-----+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
81 | JID | NAME | BOOT | STATE | TYPE | RELEASE | IP4 | IP6 | TEMPLATE | BASEJAIL |
82 +=====+=======+======+=======+======+=================+====================+=====+================+==========+
83 | 204 | srv_1 | off | up | jail | 14.2-RELEASE-p3 | epair0b|10.1.0.183 | - | ansible_client | no |
84 +-----+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
85 | 205 | srv_2 | off | up | jail | 14.2-RELEASE-p3 | epair0b|10.1.0.204 | - | ansible_client | no |
86 +-----+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
87 | 206 | srv_3 | off | up | jail | 14.2-RELEASE-p3 | epair0b|10.1.0.169 | - | ansible_client | no |
88 +-----+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
89
90 Create the inventory file ``hosts/02_iocage.yml``. Use the option
91 :ansopt:`community.general.iocage#inventory:sudo`:
92
93 .. code-block:: yaml
94
95 plugin: community.general.iocage
96 host: 10.1.0.73
97 user: admin
98 sudo: true
99
100 Display the inventory:
101
102 .. code-block:: console
103
104 shell> ansible-inventory -i hosts/02_iocage.yml --list --yaml
105 all:
106 children:
107 ungrouped:
108 hosts:
109 srv_1:
110 iocage_basejail: 'no'
111 iocage_boot: 'off'
112 iocage_ip4: 10.1.0.183
113 iocage_ip4_dict:
114 ip4:
115 - ifc: epair0b
116 ip: 10.1.0.183
117 mask: '-'
118 msg: ''
119 iocage_ip6: '-'
120 iocage_jid: '204'
121 iocage_release: 14.2-RELEASE-p3
122 iocage_state: up
123 iocage_template: ansible_client
124 iocage_type: jail
125 srv_2:
126 iocage_basejail: 'no'
127 iocage_boot: 'off'
128 iocage_ip4: 10.1.0.204
129 iocage_ip4_dict:
130 ip4:
131 - ifc: epair0b
132 ip: 10.1.0.204
133 mask: '-'
134 msg: ''
135 iocage_ip6: '-'
136 iocage_jid: '205'
137 iocage_release: 14.2-RELEASE-p3
138 iocage_state: up
139 iocage_template: ansible_client
140 iocage_type: jail
141 srv_3:
142 iocage_basejail: 'no'
143 iocage_boot: 'off'
144 iocage_ip4: 10.1.0.169
145 iocage_ip4_dict:
146 ip4:
147 - ifc: epair0b
148 ip: 10.1.0.169
149 mask: '-'
150 msg: ''
151 iocage_ip6: '-'
152 iocage_jid: '206'
153 iocage_release: 14.2-RELEASE-p3
154 iocage_state: up
155 iocage_template: ansible_client
156 iocage_type: jail
157
158 Note: If the option :ansopt:`community.general.iocage#inventory:env` is used and :ansopt:`community.general.iocage#inventory:sudo` is enabled, enable also :ansopt:`community.general.iocage#inventory:sudo_preserve_env`. For example,
159
160 .. code-block:: yaml
161
162 plugin: community.general.iocage
163 host: 10.1.0.73
164 user: admin
165 env:
166 CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1
167 sudo: true
168 sudo_preserve_env: true
169
170 In this case, make sure the sudo tag ``SETENV`` is used:
171
172 .. code-block:: console
173
174 shell> ssh [email protected] sudo cat /usr/local/etc/sudoers | grep admin
175 admin ALL=(ALL) NOPASSWD:SETENV: ALL