#puppetdbquery
Explore tagged Tumblr posts
mattdevuk · 11 years ago
Text
July 21st-23rd Update? :D
Okay so I've been a bit behind with these updates. It's hard to do so when I don't have my apartment to live in with decent internet :(
Luckily there's not too much to update, mostly been focusing on setting up the PuppetDBQuery module and working out how best to use it in our scenario. That seems to be done and working now. One thing I did notice, which I believe to be an issue with PuppetDB, was that overnight our Puppetmaster process increased it's RAM usage consistently until bu the morning it was high enough to stop itself from successfully updating it's own catalogue. After stopping the process and letting it release it's resources it seemed to keep itself under control again and right up until now, 10PM the following night, it seems to be working fine so maybe it was just a one-off glitch but will have to keep it in mind in the next few weeks.
Not related to either of the above points, but one issue had to deal with lately was the particular syntax for selecting an array item with Puppet.
If it is being used in an ERB template the correct format is <%= @array_name [0] %> The important part being the space between the array name and the index. If this space does not exist, then the parser will not be able to read the variable and will leave it blank.
If the variable is being used via string interpolation, the correct format is $variable="${arrayname[0]}". The important part being the lack of the space between the array name and the index. I found, especially when using Puppet's host resource, that if you put a space, it will fail to read the variable properly and leave it empty, throwing an error if used as the ip property.
The final scenario I came across, was if you were using string interpolation to generate another array. this one sounds a bit complicated so I'll show an example.
$array1=["a","b","c","d","e"] $array2=["${array1[0]}","${array1[2]}","${array1[4]}"]
Is this situation, it doesn't matter if there is a space or not between the array name and the index.
These aren't complicated things to remember but if you don't know about them and suddenly after an update everything's going crazy and you're staring at one of them going "but it looks perfectly fine" you'll kick yourself if it comes down to a simple space in the wrong place!
I don't think there's anything more to update you guys on.
I will say, that tomorrow (Thursday 24th) there is a webinar conducted by PuppetLabs to explain and explore the new features in Puppet Enterprise 3.3 - Link
There is also a webinar by Atlassian tomorrow too, about using Git for Continuous Integration - Link
1 note · View note
zoojar · 10 years ago
Text
PUPPET: DYNAMIC FILEBUCKET SERVERS USING DALEN-PUPPETDBQUERY!
What if you could make a quick db query to see what the puppetmaster’s fqdn is?!.... 
Ok, so site.pp has some static crap in it about your puppet master and where your agent should stuff its files...
#/etc/puppetlabs/code/environments/production/manifests/site.pp # Define filebucket 'main': filebucket { 'main':  server => "puppetmaster.local", # <-- static server name :(  path   => false, }
When the agent runs and fails to find it’s filebucket (usually set to your puppet master) you get an error like this:
Error: /Stage[main]/Puppet_enterprise::Mcollective::Server/File[/etc/puppetlabs/mcollective/server.cfg]/content: change from {md5}73e68cfd79153a49de6f5721ab60657b to {md5}4a934b6c050e5196eaf71d87c81899a6 failed: Could not back up /etc/puppetlabs/mcollective/server.cfg: getaddrinfo: Name or service not known
Puppetlabs kindly documented this error here.
But what if you could make a quick db query to see what the puppetmaster’s fqdn is?! - This would be great because your site.pp would’t need to be updated per site!
So I grab the amazing dalen-puppetdbquery module from the forge and use it to locate the master, and now my site.pp becomes...
#/etc/puppetlabs/code/environments/production/manifests/site.pp # Define filebucket 'main': $puppetmaster = query_nodes('Class["puppet_enterprise::profile::master"]’)[0] filebucket { 'main':   server => "${puppetmaster}",   path   => false, }
The first element in the array is at least sure to be your puppet master (a node that got assigned the “puppet_enterprise::profile::master” class).
If you’re scaling masters then perhaps tag one?
0 notes