Thursday, July 16, 2015

Puppet Enterprise Console: Programmatically add nodes to a node group.

I spent the last two years working with Chef, and I never felt the need to blog much about what I was doing because everything I needed was always easy to find.  In other words, the documentation for Chef provided by both Opscode and the community is great.  I can't always say the same about Puppet, so a lot of times I find myself having to really dig to find solutions.

In this case I needed a way to script adding a lot of nodes to a Puppet Console node group.  Later versions of Puppet Enterprise have the Node Classifier Endpoints, but in this environment we were running 3.2.3.  You can use the Console Rake API instead.

/opt/puppet/bin/rake -f /opt/puppet/share/puppet-dashboard/Rakefile RAILS_ENV=production node:addgroup['','mygroup']

cat newhosts | xargs -I {}  /opt/puppet/bin/rake -f /opt/puppet/share/puppet-dashboard/Rakefile RAILS_ENV=production node:addgroup['{}','mygroup']

No comments: