A collection of task oriented solutions in Puppet


Add a host entry


You want to add an entry to your local systems equivalent to /etc/hosts


class host_entries {

  # create a simple hostname and ip host entry
  host { 'syslog':
    ip => '',

  # create a fully qualified full host entry with an alias
  host { 'ntpserver.example.com':
    ip           => '',
    host_aliases => 'timeserver',

  # host entry with multiple aliases
  host { 'dashboard':
    ip           => '',
    host_aliases => [ 'nagios', 'munin' ],



The simplest use of the host type requires just a name (fully qualified or relative as needed) and the ip address it should resolve to. On the next puppet run in addition to your new host entry you'll also see the following Puppet warning banner, indicating that parts of this file are now under puppet management.

# HEADER: This file was autogenerated at Sun Jan 02 17:46:16 +0000 2011
# HEADER: by puppet.  While it can still be managed manually, it
# HEADER: is definitely not recommended.

The next two examples follow the same basic pattern, requiring that a host and ip address be specified, and write the same records, just with additional host aliases. In the third example you can see that in order to pass more than a single host_alias to a host entry you'll need to supply them as an array.

See also