FAQ
Hi All,

I am using Puppet 3.2.4 and I'd like Puppet to manage /etc/hosts for me and
add "neighbouring hosts" only to /etc/hosts. These hosts are determined to
be neighbours based on where they are (city/country).

For example ($::city and $::country are custom facts):

@@host { $::fqdn:
    ip => $::ipaddress,
    host_aliases => [ $::hostname ],
    tag => [ $::city, $::country ],
}

Host <<| tag == $::city and tag == $::country |>>

As I have never used exported resources before, I gave this a try and
realised there is more to them than the above config. It looks like I need
to install PuppetDB to make it work, which looks challenging given that the
puppet master is on SLES 11.

Apart from using exported resources, does anyone have any ideas on how to
achieve this?

One nasty way of doing it was to create a Puppet function that looks at
/var/lib/puppet/yaml/node/*.yaml and matches filenames based on a regex
passed in as an argument, then parses each yaml file and returns
'ipaddress', 'fqdn' and 'hostname' from them to update /etc/hosts, but it's
way too hacky for my liking.

- Gonzalo

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • JuanBrein at Oct 14, 2013 at 11:45 am
    Hi Gonzalo,

    First of all you don't need puppetdb to use exported resources. A simple
    mysql database will do it, even sqlite works, not recommended though.
    Specifically what you need is "stored configs" configured in your puppet
    master. The problem with exported resources is that sometimes they can be
    slow... depends obviously on the amount of nodes, resources, etc.

    Regarding your question if it can be done in a different way... I would
    definitely use DNS if possible... if not exported resources if very easy to
    implement. The function idea I don't think is "that" bad... I would prefer
    to query a database rather than parsing files.

    Another way I can think about is to use a custom ENC to export those
    parameter. The ENC would take the information from some type of database
    that you have to update as well. That would be definitely faster and a more
    elegant solution

    Depending on the size of your infrastructure and performance I would go for
    exported resources and if that is too slow I would consider some of the
    other options

    Cheers

    Juan
    On Monday, October 14, 2013 7:19:56 AM UTC+1, Gonzalo wrote:

    Hi All,

    I am using Puppet 3.2.4 and I'd like Puppet to manage /etc/hosts for me
    and add "neighbouring hosts" only to /etc/hosts. These hosts are determined
    to be neighbours based on where they are (city/country).

    For example ($::city and $::country are custom facts):

    @@host { $::fqdn:
    ip => $::ipaddress,
    host_aliases => [ $::hostname ],
    tag => [ $::city, $::country ],
    }

    Host <<| tag == $::city and tag == $::country |>>

    As I have never used exported resources before, I gave this a try and
    realised there is more to them than the above config. It looks like I need
    to install PuppetDB to make it work, which looks challenging given that the
    puppet master is on SLES 11.

    Apart from using exported resources, does anyone have any ideas on how to
    achieve this?

    One nasty way of doing it was to create a Puppet function that looks at
    /var/lib/puppet/yaml/node/*.yaml and matches filenames based on a regex
    passed in as an argument, then parses each yaml file and returns
    'ipaddress', 'fqdn' and 'hostname' from them to update /etc/hosts, but it's
    way too hacky for my liking.

    - Gonzalo
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • R.I.Pienaar at Oct 14, 2013 at 11:46 am

    ----- Original Message -----
    From: "JuanBrein" <juan.brein@gmail.com>
    To: puppet-users@googlegroups.com
    Sent: Monday, October 14, 2013 12:45:05 PM
    Subject: [Puppet Users] Re: Managing /etc/hosts without using exported resources

    Hi Gonzalo,

    First of all you don't need puppetdb to use exported resources. A simple
    mysql database will do it, even sqlite works, not recommended though.
    Specifically what you need is "stored configs" configured in your puppet
    master. The problem with exported resources is that sometimes they can be
    slow... depends obviously on the amount of nodes, resources, etc.
    note the old stored configs are deprecated and will be removed real soon,
    would not recommend you head down that route at this point.

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Gonzalo Servat at Oct 14, 2013 at 10:25 pm
    Hi Juan,

    Thanks for your reply. I was going to look into using stored configs with
    MySQL as per your suggestion, until I saw R.I.Pienaar's email :(

    Yes, I would certainly use DNS if I could, but unfortunately DNS is not an
    option in this setup.

    I think I will have to either parse files (eek) or maybe look into that ENC
    suggestion.

    - Gonzalo

    On Mon, Oct 14, 2013 at 10:45 PM, JuanBrein wrote:

    Hi Gonzalo,

    First of all you don't need puppetdb to use exported resources. A simple
    mysql database will do it, even sqlite works, not recommended though.
    Specifically what you need is "stored configs" configured in your puppet
    master. The problem with exported resources is that sometimes they can be
    slow... depends obviously on the amount of nodes, resources, etc.

    Regarding your question if it can be done in a different way... I would
    definitely use DNS if possible... if not exported resources if very easy to
    implement. The function idea I don't think is "that" bad... I would prefer
    to query a database rather than parsing files.

    Another way I can think about is to use a custom ENC to export those
    parameter. The ENC would take the information from some type of database
    that you have to update as well. That would be definitely faster and a more
    elegant solution

    Depending on the size of your infrastructure and performance I would go
    for exported resources and if that is too slow I would consider some of the
    other options

    Cheers

    Juan

    On Monday, October 14, 2013 7:19:56 AM UTC+1, Gonzalo wrote:

    Hi All,

    I am using Puppet 3.2.4 and I'd like Puppet to manage /etc/hosts for me
    and add "neighbouring hosts" only to /etc/hosts. These hosts are determined
    to be neighbours based on where they are (city/country).

    For example ($::city and $::country are custom facts):

    @@host { $::fqdn:
    ip => $::ipaddress,
    host_aliases => [ $::hostname ],
    tag => [ $::city, $::country ],
    }

    Host <<| tag == $::city and tag == $::country |>>

    As I have never used exported resources before, I gave this a try and
    realised there is more to them than the above config. It looks like I need
    to install PuppetDB to make it work, which looks challenging given that the
    puppet master is on SLES 11.

    Apart from using exported resources, does anyone have any ideas on how to
    achieve this?

    One nasty way of doing it was to create a Puppet function that looks at
    /var/lib/puppet/yaml/node/*.**yaml and matches filenames based on a
    regex passed in as an argument, then parses each yaml file and returns
    'ipaddress', 'fqdn' and 'hostname' from them to update /etc/hosts, but it's
    way too hacky for my liking.

    - Gonzalo
    --
    You received this message because you are subscribed to the Google Groups
    "Puppet Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedOct 14, '13 at 6:20a
activeOct 14, '13 at 10:25p
posts4
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase