Ask Your Question

Alternatives to node-name based configuration and manifests

asked 2015-06-23 13:25:30 -0600

Naftuli Tzvi Kay gravatar image

I just recently read an interesting article on provisioning an autoscaling infrastructure using Ansible. I think I'm largely behind the times on the newest developments with Puppet, I haven't began using Hiera or any of the new tools with Puppet 3 other than the new resource ordering syntax (->, ~>, etc.).

I know that Puppet Enterprise ships with MCollective or something like it to make it easy to query hosts based on Facter facts and optionally apply classes based on those facts. I'm also aware that I can do the same thing manually by setting up MCollective on all of my instances, managing a AMPQ message queue somewhere as well.

Is there a way that I can provision hosts without defining their names in node definitions? I'd like a way to write definitions based on facts instead of based on host name and retain the ability to do manual Puppet apply operations in addition to the ability to use a master.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-06-25 03:56:36 -0600

My solution to this was to write a small Facter script (ruby) that goes to all agent nodes. It's put in a common module under (module)/lib/facter, so puppet ensures all agents get it.

The script parses the host name, and sets a noderole Facter fact accordingly (e.g. web, database, gw, compute, loadbalancer). Out host naming convention is designed for this.

On the puppet master I use Hiera with this hierarchy:

  - hosts/%{fqdn}              # Config for specific hosts only
  - domain/%{domain}           # Config for a whole domain (e.g. tsdev3.lan)
  - noderole/%{noderole}       # Node role config (e.g. computing node)
  - osfamily/%{osfamily}       # OS wide config (e.g. Linux or Windows)
  - common                     # For all nodes

Under (hiera datadir)/noderole/ I have a set of yaml files which include the class assignments that are relevant to each noderole. I use this feature for assigning classes through Hiera.

This scheme does not depend on neither PE nor Foreman, and since all is in text files, I can keep everything I do strictly managed in git.

edit flag offensive delete link more


This is a really good answer. My constraints require me to keep things in Git and not use PE, so this is a great solution.

Naftuli Tzvi Kay gravatar imageNaftuli Tzvi Kay ( 2015-06-25 14:20:15 -0600 )edit

answered 2015-06-24 00:18:26 -0600

GregLarkin gravatar image

updated 2015-06-24 19:38:56 -0600

Absolutely, you'll want to have a look at the new node classifier that was introduced in PE 3.7. You can now create node groups that are dynamically populated based on a set of rules that you define. There is plenty of documentation here:

You'll probably be interested in this page, too:

Hiera is great for pulling configuration data and other changeable bits of information and storing them in a central place. Then you can write your code to load data from Hiera and generate some resources dynamically. Ideally, you'll have code that changes infrequently, and once you've got things set up correctly, you can add more resources to your catalogs by simply updating your Hiera data files.

If you install PE 3.7+, you can also enable the new future parser and start coding with constructs that will become enabled by default in PE 4.0:


You mentioned PE in your question, so I assumed you were using it. If you are using open-source, you have many options including the Foreman web app and writing your own ENC. You can also write some Hiera data files using an external process that you come up with, then call hiera_include() to apply those classes to nodes.

Some more links for you:

edit flag offensive delete link more


All of these solutions require Puppet Enterprise.

Naftuli Tzvi Kay gravatar imageNaftuli Tzvi Kay ( 2015-06-24 15:42:46 -0600 )edit

Thanks for updating with docs on how to do this without breaking the bank ;)

Naftuli Tzvi Kay gravatar imageNaftuli Tzvi Kay ( 2015-06-24 19:57:06 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-06-23 13:25:30 -0600

Seen: 921 times

Last updated: Jun 25 '15