Forge Home

hosts

Manage the /etc/hosts file

12,280 downloads

12,280 latest version

2.3 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.0.1 (latest)
released Dec 5th 2012

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'lsit-hosts', '0.0.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add lsit-hosts
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install lsit-hosts --version 0.0.1

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download
Tags: hosts, hiera

Documentation

lsit/hosts — version 0.0.1 Dec 5th 2012

hosts

Manage the /etc/hosts file. Allows for a site-wide host and node-specific list of host entries. Data is stored in hiera.

License

Distributed under the New BSD License

Contact

Jose Guevarra jguevarra@lsit.ucsb.edu

Support

This module was tested on puppet 2.7.0, hiera 1.0.0

Installation

  1. Install lsit-hosts module

    Install the module by normal means. You will also need to have puppet setup to work with hiera as a data store.

    By default, the hosts module will write to /etc/hosts and use its own template.

  1. Add site-wide host entries

    Site-wide values are stored in "hosts::site_hosts_hsh". Add site-wide hosts entries to your common.yaml file or which ever file you use to store site-wide heira values. Entries are organized into sections; "Web Servers", by example below. You must have at least one section. See example below.

hosts vars

hosts::site_hosts_hsh: 'Web Servers':

- '10.0.16.10     yoda-priv.example.com yoda-priv'
- '10.0.16.11     chewbacca.example.com www.example.com chewbacca'
- '10.0.16.13     solo.example.com www2.example.com solo'

'Log Servers':

- '192.168.2.134     loghost1.example.com'
- '192.168.2.167     loghost2.example.com'

= Result =

Site-Wide Host Entries

Web Servers

10.0.16.10 yoda-priv.example.com yoda-priv 10.0.16.11 chewbacca.example.com www.example.com chewbacca 10.0.16.13 solo.example.com www2.example.com solo

Log Servers

192.168.2.134 loghost1.example.com 192.168.2.167 loghost2.example.com

  1. Node-specific hosts entries Node-specific value ware stored in "hosts::node_hosts_hsh". You can add hosts entries that are specific to a particular node by configuring hiera to lookup node-specific values first. Adding the section "nodes/%{fqdn}" tells hiera took look for values in nodes yaml file(e.g. nodes/lea.example.com.yaml) before it searches the site-wide values.

= example hiera.yaml =

:backends: - yaml

:logger: console

:hierarchy: - nodes/%{fqdn}

        - common

:yaml: :datadir: /etc/puppet/hieradata

  1. Overriding template and hosts file path The template and hosts file path variables are stored in "hosts::hosts_tmpl" and "hosts::hosts_path", respectively. You can override these values by setting them in either the site-wide or the node-specific data store.

    Note: When overriding the "hosts::hosts_tmpl", puppet will search with respect to the default template directory.

  1. Set "puppetheader" variable(optional) In general, it is a good idea to have a header on puppet-managed files. The hosts module expects a variable named "puppetheader" to hold the puppet header string. By default, it uses "Managed By Puppet". Override this by adding the "puppetheader" value in your heira data store.