Exported resources

20 views
Skip to first unread message

Toky

unread,
May 13, 2014, 11:16:16 PM5/13/14
to puppet...@googlegroups.com

Hello all,

I have the following code I use to populate /etc/hosts :

# This module will gather hostnames and IPs in order to populate hosts files

class hosts {

  host  { 'localhost.localdomain':
  ensure        =>  present, 
  ip            =>  '127.0.0.1',
  host_aliases  =>  [ 'localhost' ],
  }

  @@host  { $fqdn:
  ensure        =>  present,
  ip            =>  $ipaddress_eth0,
  host_aliases  =>  [ $hostname, $tag_name ],

  }

# Here we ensure we are capturing all exported nodes

Host <<| |>>
}

I would like to send the exported resources to another file too (/usr/local/etc/ec2-hosts)

How can I get the exported resources above (hostname and ip) in to such file?

A sym-link from /etc/hosts will not work for what I need. 

Cheers, 

jcbollinger

unread,
May 14, 2014, 9:04:29 AM5/14/14
to puppet...@googlegroups.com

That doesn't make any sense.  I mean, I understand what you are trying to accomplish, but Host resources simply don't fit into it.  You are thinking of Hosts as if they represented a line of text with a certain structure, but that's altogether the wrong view.

A Host resource represents a hostname-to-net-address mapping known by the target node.  The target either knows this mapping or doesn't; it doesn't make sense to ask for the target to know it in two places.  Moreover, the local manifestation of "knowing" a Host mapping is not part of the mapping itself.  On many types of systems it will manifest as an entry in /etc/hosts, but there are other alternatives (the docs call out OS X systems as ones where the manifestation is different).

 

A sym-link from /etc/hosts will not work for what I need. 


You need a separate set of resources to manage your other file.  Have a look at the Concat module -- it may get you where you need to go.


John

Reply all
Reply to author
Forward
0 new messages