Giter Club home page Giter Club logo

puppet-hosts's Introduction

hosts

A template-based module to manage /etc/hosts. The main goal for this module is to add entries for localhost and primary address based on existing ip-adresses on existing interfaces. Tested by me on Gentoo, SLES, RedHat, and OS X. But it should work or any Linux and Unix-like OS.

This module unconditionally overwrites your hosts file. You have been warned! There are two reasons that this is template-based.

  1. Currently the default host type don't allow multiple IP for a hostname (not even a IPv4 and a IPv6).

  2. I prefer to manage files with puppet exclusively, or not at all.

Usage

class { 'hosts': }

Parameters

file

The file to add host entries to.

  • Default: '/etc/hosts'

lo_ipv4

List of IPv4 addresses for localhost. Empty list means no entry.

  • Default: [ IPv4 loopback addresses ]

lo_ipv6

List of IPv6 addresses for localhost. Empty list means no entry.

  • Default: [ IPv6 loopback addresses ]

lo_names

List of names for localhost.

  • Default: [ 'localhost' ]

primary_ipv4

List of IPv4 addresses. Empty list means no entry.

  • Default: [ IPv4 addresses (not loopback or multicast) ]

primary_ipv6

List of IPv6 addresses. Empty list means no entry.

  • Default: [ IPv6 addresses (not loopback, multicast, or linklocal) ]

primary_names

List of names for primary addresses.

  • Default: [ $::fqdn, $::hostname ]

one_primary_ipv4

If true, only use the first address from primary_ipv4

  • Default: true

one_primary_ipv6

If true, only use the first address from primary_ipv6

  • Default: true

enable_ipv4

If false, don't add IPv4 loopback or primary addresses. (IPv4 addresses from hosts::entries is still added)

  • Default: true

enable_ipv6

If false, don't add IPv6 loopback or primary addresses. (IPv6 addresses from hosts::entries is still added)

  • Default: true

entries

A hash with additional host entries to add. Entries in this hash overrides automatic hostentries for IP's on local interfaces. The content can be either comment => { ip => [ names ], ... } or just ip => [ names ].

  • Default: {}

Example

class { 'hosts':
    one_primary_ipv4 => false, 
    one_primary_ipv6 => false,
    entries => { '192.168.2.1' => [ 'foo.example.org', 'foo' ] }
}

Hiera example

hosts::one_primary_ipv4: false
hosts::one_primary_ipv6: false
hosts::entries:
  '::2':
    - 'localhost2'
  'Foocluster nodes':
    '2001:db8:abba::1':
      - 'node1.example.org'
      - 'node1'
    '2001:db8:abba::2':
      - 'node2.example.org'
      - 'node2'

puppet-hosts's People

Contributors

chrekh avatar fraenki avatar tuningyourcode avatar yuri2801 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.