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.localdomainandlocalhost.hosts_default_ipv4_hosts: An entry for the default inventory IPv4 address. By default, it uses
inventory_hostnameandinventory_hostname_shortfrom 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.
Manages /etc/hosts and /etc/hostname with templates.
ansible-galaxy install ajsalminen.hosts