arillso.hosts

Ansible 角色: hosts

license Ansible 角色 Ansible 角色 Ansible 质量评分 GitHub 最新发布 GitHub 工作流状态

描述

Ansible 角色可以动态创建 hosts 文件。

安装

ansible-galaxy install arillso.hosts

需求

角色变量

hosts_file

目标系统上 hosts 文件的路径。

hosts_file: /etc/hosts

hosts_backup

在更改之前备份 hosts 文件。

hosts_backup: false

hosts_group

hosts 文件的组所有者。

hosts_group: root

hosts_owner

hosts 文件的拥有者。

hosts_owner: root

hosts_mode

hosts 文件的访问权限。

hosts_mode: 0644

SELinux

SELinux 的设置。

hosts_serole: object_r
hosts_setype: net_conf_t
hosts_seuser: system_u
hosts_selevel: s0

Loopback

为服务器名称创建一个 127.0.0.1 条目。

hosts_hostname_loopback: true

Inventory

将所有主机插入到 Ansible Inventory 文件中的 Hosts 文件。

hosts_inventory_to_hosts: false

另外,hosts_aliases 可以在 host_vars 中设置,然后为主机生成别名。

All Private

如果启用此选项和 hosts_inventory_to_hosts,则将从 inventory 中写入所有私有 IP 地址到 hosts 文件。

hosts_all_private: true

All Public

如果启用此选项和 hosts_inventory_to_hosts,则将从 inventory 中写入所有公共 IP 地址到 hosts 文件。

hosts_all_public: false

IPv6

IPv6 本地主机条目会自动设置。设置为 false 可以防止。

hosts_ipv6: true

IPv4 地址

要使用的 IPv4 地址。可以根据需求覆盖。

hosts_ipv4_address: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"

hosts_exludes_interfaces

不应添加到 hosts 文件的网络接口列表。

hosts_exludes_interfaces:
  - 'vet*'
  - 'docker'

依赖

示例 Playbook

- hosts: all
  roles:
    - arillso.hosts

作者

许可证

该项目采用 MIT 许可证。有关完整许可证文本,请参见 LICENSE 文件。

版权所有

(c) 2020, Arillso

关于项目

Ansible role that dynamically creates the hosts file.

安装
ansible-galaxy install arillso.hosts
许可证
mit
下载
801.7k
拥有者