Spec-Zone.ru › Ansible

Основы

На хосте iocage от имени root создайте три VNET-джейла с интерфейсом DHCP из шаблона 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!

См.: Настройка VNET.

На контроллере от имени администратора выведите список джейлов:

shell> ssh admin@10.1.0.73 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       |
+------+-------+------+-------+------+-----------------+--------------------+-----+----------------+----------+

Создайте файл инвентаризации hosts/02_iocage.yml

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

Выведите инвентаризацию:

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

При необходимости создайте джейлы с общим IP-адресом:

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

См.: Настройка джейла с общим IP-адресом

Если iocage требуются переменные среды, используйте параметр env. Например,

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

© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/projects/ansible/latest/collections/community/general/docsite/guide_iocage_inventory_basics.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API