arillso.hosts

Ansible Role: hosts

Description

This Ansible role helps to automatically create and manage the hosts file on your system.

Installation

To install this role, use the following command:

ansible-galaxy install arillso.hosts

Requirements

No special requirements needed.

Role Variables

hosts_file

Specify the location of the hosts file on the system.

hosts_file: /etc/hosts

hosts_backup

Turn on to create a backup of the hosts file before making changes.

hosts_backup: false

hosts_group

Define the group that owns the hosts file.

hosts_group: root

hosts_owner

Define the owner of the hosts file.

hosts_owner: root

hosts_mode

Set the access permissions for the hosts file.

hosts_mode: 0644

SELinux Settings

Configure SELinux settings if applicable.

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

Loopback Entry

Choose to create an entry for the server name pointing to 127.0.0.1.

hosts_hostname_loopback: true

Inventory Integration

If enabled, adds all hosts in the Ansible Inventory file to the hosts file.

hosts_inventory_to_hosts: false

You can also set hosts_aliases in the host_vars to generate aliases for the hosts.

Include All Private IPs

When enabled, includes all private IP addresses from the inventory in the hosts file.

hosts_all_private: true

Include All Public IPs

When enabled, includes all public IP addresses from the inventory in the hosts file.

hosts_all_public: false

IPv6 Configuration

Automatically adds IPv6 localhost entries. Set to false to disable.

hosts_ipv6: true

IPv4 Address

This defines the IPv4 address to use, which can be customized.

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

Exclude Interfaces

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

hosts_exludes_interfaces:
  - 'vet*'
  - 'docker'

Dependencies

No dependencies required.

Example Playbook

Here is an example of how to use this role in a playbook:

- hosts: all
  roles:
    - arillso.hosts

Author

License

This project is licensed under the MIT License. For details, see the LICENSE file.

(c) 2020, Arillso

Informazioni sul progetto

Ansible role that dynamically creates the hosts file.

Installa
ansible-galaxy install arillso.hosts
Licenza
mit
Download
801.7k
Proprietario