criecm.iocage

iocage

iocage 主机安装/配置和监狱安装 在 FreeBSD 上
(在 FreeNAS 上无法直接使用,欢迎补丁;)

使用来自
https://github.com/fractalcells/ansible-iocageiocage ansible 模块
(嵌入在角色的库中)。

将创建的主机添加到清单(add_host),并填充 iocage_host 变量,
包含主机的 inventory_hostnameiojails 组。

角色变量

(在 defaults/main.yml 中)

  • iocage_zpool (zroot)
    iocage 的 ZFS 池

  • iocage_fetch_args ({})
    传递给 iocage fetch 的参数
    示例:"-s ftp.local -d pub/FreeBSD/releases"

  • jail_list ([])
    要在主机上创建的监狱字典列表,见下文

  • myjail ('')
    如果定义,仅运行 jail_list 中的此监狱(如果未找到,则为无)

  • myjails ([])
    与 myjail 相同,但支持多个 :)

  • iocage_components (none) - 列表:
    如果定义,仅安装这些组件

  • iocage_enable_ssh (True)
    在新监狱中启用 SSH

  • iocage_release (uname -r)
    您需要的发行版

  • jail_init_role ()
    用于初始化新监狱的角色

  • iocage_use_pkg (True)
    如果为 True,则从软件包安装 iocage;如果为 False,则从 git 安装。

每个监狱的变量

(在 vars/jail.yml 中)

  • name(无默认,必填):人类标识符,在主机上唯一

  • hostname (''):如果为空则生成 UUID

  • ip4 (''):IPv4 地址,格式与 iocage 相同:[ifaceN|]192.0.2.1[/24][,[ifaceN|]192.0.2.1[/24][,…]]

    • 如果前面有 'iface|',IP 将在监狱启动时添加到该接口
    • 如果未给出掩码,IP 将是 /32
  • ip6 (''):IPv6 … 同上。(但默认掩码是 /128,而不是 /32 ;-P)

  • resolver ('auto'):监狱的 resolv.conf 内容,用 ';' 替代换行符
    (如果为空,iocage 将在监狱启动时复制主机的内容)

  • properties ({}):
    可用的 iocage 监狱属性的字典

  • authkeys (/root/.ssh/authorized_keys)
    复制到监狱中的 /root/.ssh/authorized_keys 文件

resolver=auto 逻辑

resolver 将根据 search_domainsresolvers 变量自动填充
(这里我们在 group_vars/all.yml 中有这些)。这将根据监狱的 IP 地址选择搜索域和解析器。

# 如果 IP 位于 'network' 中,则添加 'domain'
search_domains:
  - { network: '192.0.2.0/24', domain: 'our.example.net' }
  - { network: '198.51.100.0/24', domain: 'ryd.example.org' }
  - { network: '2001:0DB8:fe43::/32', domain: 'ipv6.example.org' }
  - { network: '0.0.0.0/0', domain: 'example.com' }

# 如果 IP 位于 'network' 中,则将 'ip' 添加到解析器中
resolvers:
  - { network: '192.0.2.0/24', ip: 192.0.2.1 }
  - { network: '198.51.100.0/24', ip: 192.0.2.1 }
  - { network: '2001:0DB8:fe43::/56', ip: 2001:0DB8::1 }
  - { network: '0.0.0.0/0', ip: 8.8.8.8 }
  - { network: '::/0', ip: 2620:0:ccc::2 }

示例剧本:

一个监狱主机和两个监狱:

- hosts: realmachine
  roles:
    - criecm.iocage
  vars:
    jail_list:
      - { name: myfirstjail, hostname: myfirstjail.example.org, ip4_addr: 'bge0|198.51.100.0' }
      - { name: mysecjail, hostname: mysecjail.example.org, ip4_addr: 'bge0|198.51.100.8' }

在对监狱进行操作前创建/注册监狱的剧本片段

- hosts: realmachine
  roles:
    - criecm.iocage
  vars:
    # 在 inventory/host_vars/realmachine.yml 中可以包含 jail_list
    myjail: myfirstjail

- hosts: myfirstjail
  roles:
    - criecm.apache
  […]

ansible-iocage 模块

从源更新:

git subtree pull -P roles/criecm.iocage/library/src/iocage https://github.com/criecm/ansible-iocage.git master

关于项目

iocage jail management for FreeBSD

安装
ansible-galaxy install criecm.iocage
许可证
Unknown
下载
187
拥有者
Direction des Systèmes d'Information