/ansible.hosts

Ansible role that dynamically creates the hosts file.

Primary LanguageHTMLMIT LicenseMIT

Ansible Role: hosts

license Ansible Role Ansible Role Ansible Quality Score GitHub release (latest SemVer) GitHub Workflow Status (branch)

Description

Ansible role that dynamically creates the hosts file.

Installation

ansible-galaxy install arillso.hosts

Requirements

None

Role Variables

hosts_file

Path to the host file on the target system.

hosts_file: /etc/hosts

hosts_backup

Backup the hosts file before changing it.

hosts_backup: false

hosts_group

Group owner of hosts file.

hosts_group: root

hosts_owner

Owner of hosts file.

hosts_owner: root

hosts_mode

Access permission hosts file.

hosts_mode: 0644

SELinux

Settings for SElinux.

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

Loopback

Creates a 127.0.0.1 entry for the server name.

hosts_hostname_loopback: true

Inventory

Inserts all hosts in the Ansible Inventory file into the Hosts file.

hosts_inventory_to_hosts: false

Optionally, hosts_aliases can be set in the host_vars, then it generates aliases for the hosts.

All Private

If this option and the hosts_inventory_to_hosts is enabled it writes all private ip addresses from the inventory into the hosts

hosts_all_private: true

All Public

If this option and the hosts_inventory_to_hosts is enabled it writes all public ip addresses from the inventory into the hosts.

hosts_all_public: false

IPv6

Ipv6 localhost entries are set automatically. Setting false it can be prevented.

hosts_ipv6: true

IPv4 address

Address that you would like to use as IPv4 address. This could be overriden by what you want.

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

hosts_exludes_interfaces

List of network cards that should not be added to the hosts file.

hosts_exludes_interfaces:
  - 'vet*'
  - 'docker'

Dependencies

None

Example Playbook

- hosts: all
  roles:
    - arillso.hosts

Author

License

This project is under the MIT License. See the LICENSE file for the full license text.

Copyright

(c) 2020, Arillso