ajsalminen.hosts

Hosts Role Overview

This role is responsible for managing the files /etc/hosts and /etc/hostname. It uses a template to do this.

Role Variables

Each entry in this role is defined using a dictionary. The key "address" contains the IP address, and the key "hosts" holds a list of hostnames. The hostnames are added in the order they are listed, with the first one being the main hostname.

Here’s a summary of the variables you can set:

  • hosts_ipv4_loopback_hosts: An entry for the IPv4 loopback address. By default, it sets the hostnames to localhost.localdomain and localhost.

  • hosts_default_ipv4_hosts: An entry for the default inventory IPv4 address. By default, it uses inventory_hostname and inventory_hostname_short from Ansible.

  • hosts_default_hosts: A list of default entries that come with the role, including the previous two entries.

  • hosts_additional_hosts: A list for any extra entries you want to add to the hosts file. This list is empty by default.

  • hosts_all_hosts: A combined list of all host entries, merging the default hosts and any additional hosts you specify.

Example Playbook

Here is an example of how to use this role, including how to pass variables:

- hosts: servers
  roles:
     - role: hosts
       hosts_additional_hosts:
           - address: 192.168.0.1
             hostnames:
                 - server.example.com
                 - server

License

This role is available under the MIT/Simplified BSD license.

Author Information

The role was created by Antti J. Salminen in 2014.

Informazioni sul progetto

Manages /etc/hosts and /etc/hostname with templates.

Installa
ansible-galaxy install ajsalminen.hosts
Licenza
Unknown
Download
6.9M
Proprietario