<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rémi Ferrand on Medium]]></title>
        <description><![CDATA[Stories by Rémi Ferrand on Medium]]></description>
        <link>https://medium.com/@remi.ferrand?source=rss-dc687843bb4b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yz9omF4KPyWVeowM</url>
            <title>Stories by Rémi Ferrand on Medium</title>
            <link>https://medium.com/@remi.ferrand?source=rss-dc687843bb4b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 02:02:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@remi.ferrand/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Puppet modules dependencies helpers]]></title>
            <link>https://medium.com/@remi.ferrand/puppet-modules-dependencies-helpers-b00f92e4b414?source=rss-dc687843bb4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b00f92e4b414</guid>
            <category><![CDATA[dependencies]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[puppet]]></category>
            <category><![CDATA[workflow]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Rémi Ferrand]]></dc:creator>
            <pubDate>Wed, 04 Dec 2019 15:50:50 GMT</pubDate>
            <atom:updated>2019-12-04T15:50:50.886Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*wNYi8itPzUUytmxMqXygfw.png" /><figcaption>Puppet modules dependencies</figcaption></figure><p><em>Thanks, to </em><a href="https://github.com/pyfontan"><em>Pierre-Yves Fontaniere</em></a><em> for reading a draft of this post and offering some suggestions.</em></p><blockquote><strong>Author note</strong>: As usual, my posts are based on my personal experience in my day-to-day work life. I do not pretend to present the perfect solutions and I do not pretend to be always right. If you find something that’s missing or a mistake that I’ve made, I’ll be glad to edit and improve them based on your feedback. Thanks</blockquote><h3>Synopsis</h3><p><a href="https://cc.in2p3.fr/en/">CC-IN2P3</a> relies heavily on <a href="https://puppet.com/"><em>Puppet</em></a> to deliver software and manage its infrastructure. At the time I’m writing this post, our <em>production environment</em> does rely on <strong>250 puppet modules</strong> (site specific + external ones).<br>This may not seem a really big number, but this is way enough to fall in the <a href="https://en.wikipedia.org/wiki/Dependency_hell"><em>dependency of hell problem</em></a> when you’re asked to update a module used by many others.</p><p>As we’re beginning a massive “<em>Puppet modules upgrade campaign</em>”, this post will present a simple tool we’ve developed to help in the process.</p><h3>Puppet modules and dependencies</h3><h4>Puppet modules you said ? 📦</h4><p>For the ones not very familiar with Puppet, I should explain what Puppet modules are.</p><p>As stated in the <a href="https://puppet.com/docs/puppet/latest/modules_fundamentals.html">official Puppet documentation</a>:</p><blockquote>Modules serve as the basic building blocks of Puppet and are reusable and shareable.</blockquote><p>You should see Puppet modules as a way to group in one place all the deployment logic for a given technical stack.</p><p>The example I always use to explain it to beginners is the <a href="https://github.com/puppetlabs/puppetlabs-apache"><em>apache (httpd) module</em></a>. The apache module actually <strong>contains a lot</strong>.</p><p>Like with most modules, you can simply use</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22c71f7da411c13198926a923d0fa019/href">https://medium.com/media/22c71f7da411c13198926a923d0fa019/href</a></iframe><p>and obtain a functionnal Apache HTTP server using <em>Puppet module</em> default values.</p><p>The apache module also provides a convenient way to create an Apache Virtual Host:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09c24ab8512264b942090fa81bbb38fe/href">https://medium.com/media/09c24ab8512264b942090fa81bbb38fe/href</a></iframe><p>The most important thing here is that the Apache module <strong>abstracts away the deployment logic</strong> and thus allows you to <strong>focus on the real functionality you aim to build</strong>.</p><p>Another important thing with modules is that by <strong>hiding all the plumbing </strong>in <strong>the module</strong> (<em>file</em>, <em>package</em>, <em>service</em>, … resources) required to achieve a particular something you also greatly help others to understand what you’re trying to achieve. Remember, <a href="https://puppet.com/blog/puppet-executable-documentation"><strong>Puppet manifests should be seen as executable documentation</strong></a> !</p><p>So now that I’ve exposed briefly what Puppet modules are, what about Puppet modules dependencies ?</p><h4>Puppet module dependencies 🕸️</h4><p>Like many programming language, Puppet makes no exception and allow / encourage programmers to reuse logic / resources present in other modules.<br>Like previously exposed, this allows Puppet programmers to focus on what they want to achieve instead of how to do it.</p><p>If we again consider the Apache module, we can see resources such as apache::listen :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2838dd6223eed73f22910293fc8d3e4d/href">https://medium.com/media/2838dd6223eed73f22910293fc8d3e4d/href</a></iframe><p>We can see that the apache module is using resources from another module, <a href="https://forge.puppet.com/puppetlabs/concat">concat</a>. For those unfamiliar with the concat module, it <em>allows you to construct files from multiple ordered fragments of text</em>.</p><p>This, again, has allowed the apache module authors to focus on <a href="https://effectivesoftwaredesign.com/2012/02/05/separation-of-concerns/">their concern</a> which is to manage and deploy the Apache software.<br>On the other end, by doing so, this now means that the apache module is relying on the concat module to be functional. In other words, the apache module <strong><em>depends on</em></strong> the concat module.</p><h4>Expressing Puppet module dependencies ✍️</h4><p>Each programming languages have their own way to keep track of software dependencies.<br>In the same manner as <strong><em>GO</em></strong> relies on <a href="https://blog.golang.org/using-go-modules">go.mod</a> to track code dependencies, Puppet relies on a <a href="https://puppet.com/docs/puppet/latest/modules_metadata.html">module metadatas</a> expressed in a metadata.json file to express dependencies and versions requirements.</p><p>Again, if we look at the apache modules <a href="https://github.com/puppetlabs/puppetlabs-apache/blob/master/metadata.json">metadata.json</a> file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26b6d246644d6e2230fcf4ddc6830bb9/href">https://medium.com/media/26b6d246644d6e2230fcf4ddc6830bb9/href</a></iframe><p>we can see here that its dependency on the concat is expressed.</p><p>It says that the apache module in the current version 5.2.0 is compatible with the concat module in a <em>minimum version</em> of 2.2.1 and a version <em>lower but not equal</em> to 7.0.0 .</p><p>This concat dependency example has not been picked up randomly.<br>concat is indeed one of the many <em>base modules</em> heavily used by module authors. This makes it tricky to update since it can potentially break a lot of other modules.</p><h3>Puppet Modules and Environments at IN2P3-CC 🤞</h3><h4>Modules upgrade️ procedure 0.1.0+fingers.crossed</h4><p>Till now, to be fair, our Puppet module update procedure is quite … nonexistent. We usually update already present modules based on the following criteria:</p><ul><li>we were lacking a new feature not present in the version we were using</li><li>we were running into a bug that has been fixed in a more recent release</li><li>we were introducing a new module whose dependencies were not satisfied with the modules versions we were using this far</li></ul><p>Beside those three scenario, we’re currently avoiding module update and not really keeping track of module updates (<em>even if the module deployment tool we’re using is able to warn us if a newer module version is available on the </em><a href="https://forge.puppet.com/"><em>Puppet Forge</em></a>).</p><p>The reasons behind this are multiple:</p><ul><li>stability in deployments (<em>what works … works ! why change it ?!</em>)</li><li>difficulty to really tests all the implications a given <em>module update</em> could have in our whole infrastructure</li><li>lack of time to really track module updates, and current lack of tools to easily test impact (see my previous point)</li></ul><h4>Current environment based development workflow</h4><p>The development workflow we’re currently using for modules development is quite simple and follows <a href="https://puppet.com/docs/puppet/latest/environments_about.html#temporary-test-environments">Puppetlabs Temporary test environments</a> description.</p><p>Here is the set of tools we’re currently using in our Puppet infrastructure:</p><ul><li><a href="https://gitolite.com/gitolite/"><em>gitolite</em></a> to manage environments git repository (ACLs are <strong>very</strong> flexible)</li><li>self hosted gitlab instance for modules repositories</li><li><a href="https://github.com/puppetlabs/r10k"><em>r10k</em></a> to deploy production environment</li><li><em>site specific tool</em> to deploy testing environments (<em>symlink oriented tool</em> that creates a new test environment in less than 10 seconds with 250 modules)</li></ul><p>The development workflow for a module called mymodule is quite simple:</p><ol><li>Creates a new branch called feature/awesomein the module.</li><li>Creates a new branch in the environment repository. Let’s call it mymodule-awesome-feature.</li><li>Edit the Puppetfile file in the mymodule-awesome-feature branch of the environment repository and declare that module mymodule deployment should now use branch feature/awesome .</li><li>Push the new branch of the module and then the new branch of you environment repository.</li><li>Spawn a new VM in our private cloud and then run puppet agent --test --environment=mymodule-awesome-feature .</li><li>Observe changes and keep an eye on monitoring.</li><li>If everything looks good, then merge module branch and merge environment to production branch.</li></ol><p>This works well for quick development but is not enough to ensure that nothing breaks <strong><em>anywhere else</em></strong> in the infrastructure.<br>This is why in a near future, we’ll need to modify our workflow and use long lived test environment like a preproduction environment. A small set of carefully chosen hosts from multiple services would have to stick in this environment. Almost like <a href="https://dev.to/mostlyjason/intro-to-deployment-strategies-blue-green-canary-and-more-3a3"><em>canaries</em></a> in software development, they would hopefully allow us to detect problems before going to production and before taking down the whole infrastructure.</p><h3>Puppet environment leak 🌊</h3><h4>Problem</h4><p>A problem with such long lived environment is <a href="https://puppet.com/docs/puppet/latest/environments_about.html#plugins-can-leak-between-environments"><em>environments plugins leak</em></a>. Here is what the doc says:</p><blockquote>Environment leakage occurs when different versions of Ruby files, such as resource types, exist in multiple environments. When these files are loaded on the master, the first version loaded is treated as global. Subsequent requests in other environments get that first loaded version.</blockquote><p>In practice, when:</p><ul><li>your masters do handle multiple long lived Puppet environments</li><li>your environments do have different versions of the same module</li><li>those different module versions do have different custom types interfaces</li></ul><p>If you’ve checked all the criteria above, then <strong>it’s pretty likely you will face pretty weird Puppet behaviors</strong>.<br><em>Catalog compilation</em> could fail, complaining that “<em>your custom type does not have an attribute or such thing</em>”. If you launch the Puppet agent multiple times, if you’re lucky, things could get to work. Anyway, <strong>retrying is not a long term solution</strong>.</p><h4>Puppet generate types</h4><p>The solution from Puppetlabs is to use <a href="https://puppet.com/docs/puppet/latest/man/generate.html">puppet generate types</a>.</p><blockquote>Types defined in Puppet code can be used to isolate custom type definitions between different environments.</blockquote><p>Here is an example of how to use it:</p><pre>$ puppet generate types --environment=preproduction</pre><p>This will create a $codedir/environments/preproduction/.resource_types directory. This directory contains multiple .pp files, each describing the parameters your custom types are expecting.</p><h4>IN2P3-CC problem with generate types</h4><p>As stated before, at IN2P3-CC, some of the Puppet modules we’re using are pretty old. Some of those old modules seem to lead to some of the following errors when running puppet generate types :</p><pre>Error: /etc/puppetlabs/code/environments/preproduction/modules/openldap/lib/puppet/type/openldap_access.rb: title patterns that use procs are not supported.</pre><p>This particular problem was solved more than one year ago by <a href="https://github.com/camptocamp/puppet-openldap/commit/cf3163786c0429b36ea608a808804ad16da4ce55#diff-750b22881abfb2373fc527eb7b32dd92"><em>this commit</em></a> in the openldap module we’re using.</p><p>This is one of many examples of the problems we’re currently facing with the fact that we’re currently using very old modules that were never updated.</p><h3>Future at IN2P3-CC 🤖</h3><p>As demonstrated above, sticking with (very) old Puppet modules can lead to various problems. At IN2P3-CC, we’re about to start a massive “<em>Puppet modules upgrade campaign”</em> to at least quickly take advantage of the environment isolation that is currently hurting us.</p><p>The problem we’re facing is quite simple: <em>for each module, is the new module version compatible with our module stack or will it break a dependency</em> ?</p><h4>Quick and easy to go solution</h4><p>Like explained before, Puppet modules authors should express their module dependencies in their module metadata.json file.</p><p>We’ve developed a simple and stupid program that parses all the metadata.json files of all the modules and statically evaluates if a module version upgrade is likely to break something.<br>Here’s how we use it:</p><pre>$ metadata-json-dependencies-checker \<br>--module AUTHOR-MODULE_NAME \<br>--version NEXT_MODULE_VERSION</pre><p>For instance, the latest version of puppetlabs-stdlib is version 6.1.0 .<br>The current version we’re using in production is version 4.25.1 .<br>With our current module stack, let’s simulate what such an upgrade would affect:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aeb1617d51f44c11865ca7fb8906c6b3/href">https://medium.com/media/aeb1617d51f44c11865ca7fb8906c6b3/href</a></iframe><p>This gives us quite a useful hint about what modules are likely to require more consideration than others on particular upgrades.</p><h4>Known limitations</h4><p>This tool was designed to be one of the many helpers we’ll use to evaluates potential module upgrades. It is, by design, very simple and only checks if a <em>given version</em> is within a <a href="https://semver.org/"><em>SemVer</em></a> range.</p><p>In a perfect world, this should be enough to check. SemVer should provide enough garanties for you to rely on it.<br>But because we’re humans, there’s always <em>side effects</em>, misinterpretations, misunderstandings or we simply forget. And that’s those little things that may kill your production on an upgrade ☠️.</p><p>So yes, this tool by itself is not enough to blindly upgrade our Puppet modules. We still need to rely on a long-lived preproductionenvironment that will allows us to test new modules versions with a well identified and limited impact if / when something breaks.</p><h4>Future integrations</h4><p>As stated above, IN2P3-CC relies on <a href="https://gitolite.com/gitolite/index.html"><em>gitolite</em></a> to manage environments git repository. We’re using site specific <em>git pre-receive hook</em> to:</p><ul><li>enforce fine grained ACLs</li><li>lint</li></ul><p>On a module upgrade, this <em>pre-receive hook</em> has already access to:</p><ul><li>the name of module that is updated</li><li>the new version the module should be in</li></ul><p>Those are the exacts arguments that our tool, metadata-json-dependencies-checker needs to perform its check.</p><p>What we would need is to write a quick glue allowing the <em>pre-receive</em> hook to call an API that performs the same checks metadata-json-dependencies-checker does.<br>This would bring us more confidence about module upgrades. Indeed, whenever a module is upgraded in our Puppet infrastructure, the metadata.json files dependencies informations would then be considered and respected.</p><h3>Conclusion</h3><p>This tools has already proven to be really handy when inspecting impact of a particular Puppet module.</p><p>This is currently in self-service to any of our Puppet developers and will soon be integrated in our automated validation tools like the <em>environment git pre-receive hook</em> I’ve mentioned earlier.</p><p>I will open source this (really deadly simple) tool in a near future and be glad to discuss about this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b00f92e4b414" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nagios / Livestatus problems with dynamic reload]]></title>
            <link>https://medium.com/@remi.ferrand/nagios-livestatus-problems-with-dynamic-reload-574b45b417d2?source=rss-dc687843bb4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/574b45b417d2</guid>
            <category><![CDATA[puppet]]></category>
            <category><![CDATA[network-monitoring]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[monitoring]]></category>
            <dc:creator><![CDATA[Rémi Ferrand]]></dc:creator>
            <pubDate>Sun, 23 Dec 2018 19:48:37 GMT</pubDate>
            <atom:updated>2018-12-23T19:48:37.569Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*nNVLBLYUhTdNGJWIueKH0w.png" /></figure><blockquote><strong>TL;DR</strong>: When Puppet triggers an automatic <em>Nagios reload</em>, the <em>Livestatus API</em> becomes temporarily unreachable and this (may) have a lot of consequences.</blockquote><h3>Presentations — Vocabulary</h3><h4>Nagios</h4><p>I guess that everyone has already heard about <em>Nagios</em> so I’ll be quick. <em>Nagios</em> is a venerable (and old) monitoring solution designed to schedule checks (“<em>is my LDAP still alive ?</em>”), send out notifications and report service status through an “old school Web UI”.</p><p>The true power of <em>Nagios</em> comes from its simple design (no external dependency at all in a basic but functional configuration), it’s stability and the possibility to easily extend it using broker modules.</p><p>Where <em>Nagios</em> sucks is when you need to interact with it using third party software. That’s why tools such as <strong><em>Livestatus</em></strong> has been created.</p><h4>(MK) Livestatus</h4><p><em>Livestatus</em> is a <em>Nagios event broker module</em> extension that presents a <em>Unix Socket</em> interface. It allows real-time access to all <em>Nagios</em> services and hosts status and also allows to submit <em>Nagios</em> commands like “<em>acknowledge the LDAP server problem</em>”.<br>Livestatus does also have a very rich query langage, the <a href="https://mathias-kettner.com/cms_livestatus.html#The%20Livestatus%20Query%20Language%20(LQL)">Livestatus Query Langage</a>.<br>This makes Livestatus a very good choice for querying hosts and services states or sending command to <em>Nagios</em>, including submitting passive checks results.</p><h4>Naemon</h4><p><em>Naemon</em> is a <em>Nagios</em> fork we’re using at <a href="https://cc.in2p3.fr/en/">IN2P3 Computing Centre</a>. In this article, everything said about <em>Nagios</em> also applies to <em>Naemon</em>.</p><h4>Thruk</h4><p><a href="http://www.thruk.org/">Thruk</a> is a Web UI (and more) that supports multiple “<em>Nagios like</em>” monitoring solutions and leverage on Livestatus API to interact with Nagios (or equivalent).<br>In its latest version, Thruk also introduces a ready to use <a href="https://www.thruk.org/documentation/rest.html"><strong>REST-API</strong></a> to interact with Nagios.</p><h3>Nagios dynamic configuration</h3><p>By default, <em>Nagios</em> (<em>/ Naemon</em>) configuration is extracted from plain files.<br>Out of the box <em>Nagios</em> supports the inclusion of configuration files from a <em>conf.d</em> style directory (/etc/naemon/conf.d for instance).<br>This makes it quite easy to manage Nagios configurations files with Puppet and easy to add (some sort of) dynamism in the Nagios world.</p><h4>Nagios &amp; Puppet</h4><p>Till <em>Puppet v5</em>, <em>core Puppet</em> was coming with native nagios_ types such as nagios_host , nagios_service , etc… Those types have been removed from <em>core Puppet</em> in <em>Puppet v6.</em></p><p>You can already find plenty of articles on the Internet about:</p><ul><li>how to model your Nagios configuration into Puppet code</li><li>how to use Puppet exported resources to make hosts / services automatically register some checks to the Nagios server</li></ul><p>so I’m not gonna detail how to do so.</p><h3>Nagios and Puppet at IN2P3-CC</h3><p>At IN2P3-CC, we’re using <em>Naemon</em> to monitor:</p><ul><li>1800+ hosts</li><li>6300+ services</li></ul><p>Our <em>Naemon</em> infrastructure is managed by Puppet.</p><p>Here is what we’ve learned after <em>6+ months</em> of managing <em>Naemon</em> with Puppet.</p><h4><strong>Do not use Puppet </strong><strong>nagios_ native types at all on the Nagios server !</strong></h4><p>Using those types may seem a good idea in the first place. After all they are here, so why not use them. <br>The problem with those types is that the configuration parsing they are doing on the Nagios server is <strong>very, very slow !</strong></p><p>With something like <em>6300 services</em> defined using those types, the simple command puppet resource nagios_service use to take <strong>1mn30</strong> at least to evaluate and parse the <em>Nagios</em> services configuration file.<br>Months ago, with more than <em>1800 hosts</em> and more than <em>3000 services</em> defined in <em>Nagios</em>, Puppet used to apply its configuration in more than <strong>15 minutes</strong>.</p><p>The solution we’re now using is based on puppetdb_query() and Puppet templates to replace the nagios_ resources collectors. This solution makes the Puppet agent run duration drop to <strong>1 minute</strong> with the same amount of <em>Nagios</em> resources stated above and almost no modification in the <em>Puppet model</em> used to export Nagios resources.</p><h4><strong>Nagios requires a reload to see a new configuration</strong></h4><p>This may seems obvious, but <em>Nagios</em> <strong>do</strong> require at least a reload to see a new configuration dropped by Puppet. This mean that <strong>every time Puppet runs</strong> on your Nagios server, <strong>it may reload the <em>Nagios</em> service</strong>.</p><p>This may seem quite innocent in the first place, but it is absolutely <strong>not</strong>.</p><p>Every time a Nagios reload is triggered, the broker modules are re-initialized. This, for instance, makes the Livestatus <em>Unix Socket API</em> unavailable <strong>till the reload is over</strong>.</p><p>Very fast, this can become a big problem since Livestatus can be used by almost anything that interacts with Nagios (Thruk, submitting passive services checks, etc…).</p><p>This may lead to:</p><ul><li>Thruk Web UI users experiencing a quick “<em>Livestatus: no backend available</em>” error message during the configuration reload</li><li>Passive services or hosts checks results submitted through Livestatus while Nagios is reloading can simply be lost if no extra care is taken</li><li>Commands using the <em>Thruk REST-API</em> may simply fail during a <em>Nagios reload</em> since Thruk relies on Livestatus to interact with <em>Nagios</em></li></ul><p>Depending on the rate of your Nagios configuration modifications by Puppet, you may not experience any of the behavior I’ve described above. Or maybe you will, no one can tell.<br>What is sure is that at <em>IN2P3-CC</em>, it’s very common during work hours to see a <em>Nagios configuration reload triggered by Puppet</em> <strong>every thirty minutes or every hour</strong>. At IN2P3-CC, we also have:</p><ul><li>many Nagios probes relying on Livestatus to submit passive checks results</li><li>many internal software relying on Livestatus to extract Nagios services or hosts states</li><li>users or robots relying on the <em>Thruk REST-API</em> to submit Nagios commands (<em>downtimes</em>, etc…)</li></ul><p>With a (possible) <em>Nagios reload</em> every <em>thirty minutes</em> and a pseudo random command submission / external query pattern distribution, it did not took long for us to encounter this problem in production.</p><p>A simple workaround we implemented was to do <em>client-side retry</em> if the command / query submission fails.<br>This solution was inelegant but ok for code we do control and maintain at <em>IN2P3-CC</em>.<br>This however <strong>is not possible</strong> for software like <em>Thruk</em> or any other third party software we’re not developing.</p><p>That’s why we needed to find another way to work around the fact that <em>Livestatus</em> can, sometimes, not answer temporarily.</p><h3>Livestatus resilient proxy</h3><p>The solution we’ve developed is currently called “<em>livestatus resilient proxy</em>”. It was designed to:</p><ul><li>be very simple and lightweight</li><li>not have any understanding of the <em>Livestatus protocol</em> at all.</li></ul><p>This is basically a <em>stateful proxy</em> that sits in between the <em>Livestatus clients</em> and the <em>Livestatus Unix Socket</em>.</p><p>This solution currently serves <em>IN2P3-CC </em>production traffic for a month now and seem to behave properly. Since this proxy has been started, none of the problems I’ve listed above have been reported.</p><p>I’m currently running out of time to develop this solution in this post.<br>I’ll write another post in the next two or three weeks detailing how it works and giving some examples.</p><p>By then, I’m very curious about how other <em>Nagios / Livestatus users</em> may have handle this problem. Has anyone else also experienced such problems at all, in an environment where <em>Nagios automatic reload</em> can be quite frequent.</p><p>Feel free to:</p><ul><li>contact me on Twitter (<a href="https://twitter.com/remiferrand">@remiferrand</a>)</li><li>post a comment</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=574b45b417d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Puppet’s away, the sysadmin will play — part 1]]></title>
            <link>https://medium.com/@remi.ferrand/when-puppets-away-the-sysadmin-will-play-part-1-567f0dae36af?source=rss-dc687843bb4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/567f0dae36af</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[puppet]]></category>
            <dc:creator><![CDATA[Rémi Ferrand]]></dc:creator>
            <pubDate>Mon, 03 Sep 2018 11:27:33 GMT</pubDate>
            <atom:updated>2018-09-03T11:27:33.535Z</atom:updated>
            <content:encoded><![CDATA[<h3>When Puppet’s away, the sysadmin will play — part 1</h3><p><em>Thanks, to </em><a href="https://twitter.com/faxm0dem"><em>Fabien Wernli</em></a><em> for reading a draft of this post and offering some suggestions.</em></p><blockquote><strong>Author note</strong>: As usual, my posts are based on my personal experience in my day-to-day work life. I do not pretend to present the perfect solutions in my posts and I do not pretend to be always right. If you find something that’s missing or a mistake that I’ve made, I’ll be glad to fix my posts based on your feedback. Thanks</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*JW_j34vpmgAX1M3u8gWoyA.png" /><figcaption>How to disable your Puppet Agent properly</figcaption></figure><h3>Context</h3><p>You connect to the node hosting your service <em>&lt;insert service name here&gt;</em> to try a simple manual modification for the next software upgrade.</p><p>You know that Puppet is running and managing the host and your service. You have some experience with Puppet and those one shot manual modifications, so the first thing you do is <strong>you stop the puppet daemon</strong>.</p><p>This morning, at the coffee break, you told your coworker Billy <strong>not to start Puppet on this very host</strong>. Perfect, you’re now ready to go and you can modify any service configuration file you want, nothing will waste your time and stand in your way.</p><p>OK, you’ve been working on your configuration for <em>&lt;insert huge time interval&gt;</em> and everything is working as you expect. Last thing you need to do is port those modifications to your Puppet code and you can go home. But before that, you really need a coffee and you really deserve it after all you’ve done.</p><p>You’ve left your desk for only <em>&lt;insert tiny time interval&gt;</em> and you’re back to your workstation with a good coffee, ready to write some Puppet code. You just check the modifications one last time to prepare your Puppet code.</p><p>Wait … WHAT ! Everything you’ve done in the last hours have reverted to what they were before you stopped Puppet. You just check and indeed, the <em>Puppet Agent</em> is running again on the host you were working on. How is that even possible !?</p><p>Ah-ha ! You can see that Billy, your coworker, is connected to this node.</p><p><em>“Hey Billy, did you restart Puppet on the host I was working on ? I told you not to this morning !”</em> you ask</p><p><em>“Whoops, forgot that sorry ! The node wasn’t reporting to Puppet-DB for more than three hours and an alert was raised. Why ? Did I break something ?”</em> your coworker answers</p><p><em>“You just destroyed my last three hours of work dude…” </em>you said</p><p>Sure, the story above is a little exaggerated (and some would say that the <em>client filebucket</em> exists). But I’m sure almost everyone that has worked with <em>Puppet Agent</em> has lived a similar experience.</p><p>They are <strong>many reasons</strong> (good and bad ones) why <strong>you sometimes want to temporarily disable the <em>Puppet Agent</em> from running</strong> (troubleshooting, testing brand new configurations settings, …)</p><p>There are also many reasons why simply executing a systemd stop puppet on your system is not enough:</p><ul><li>a coworker restarts the <em>Puppet Agent</em> (“<em>Damn you Billy !”</em>)</li><li>the monitoring system automatically restarts the <em>Puppet Agent</em></li><li>the host reboots but you forgot to disablethe Puppet service. At startup, Puppet agent will start and erase all your modifications.</li><li>name your reason here</li></ul><p>It would be way better if your <em>Puppet Agent</em> <strong>could be aware that no modifications should be made</strong> to your systems.</p><h3>Puppetlabs’ solution to disable Puppet runs</h3><p>Once again, <em>Puppetlabs</em> has done such an awesome work in the <em>Puppet Agent</em>.</p><p>The Agent includes this functionality right out of the box.</p><p>Like Puppet official documentation says:</p><blockquote>Whether you’re troubleshooting errors, working in a maintenance window, or developing in a sandbox environment, you may need to temporarily disable the Puppet agent from running.</blockquote><h4>Disable the Agent</h4><pre>$ sudo puppet agent --disable &quot;Rémi: working on the next killer feature manually&quot;</pre><p>A message is logged</p><pre>Sep 01 17:45:40 dev-host puppet-agent[760]: Disabling Puppet.</pre><p>Behind the seen, this command creates a file /var/lib/puppet/state/agent_disabled.lock (or some similar path depending on your configuration)</p><pre>$ jq &lt; /var/lib/puppet/state/agent_disabled.lock</pre><pre>{<br> “disabled_message”: “Rémi: Working on the next killer feature”<br>}</pre><p>When you (or someone / something) tries to run the Puppet Agent, here’s what shows up:</p><pre># puppet agent --test<br>Notice: Skipping run of Puppet configuration client; administratively disabled (Reason: &#39;Rémi: Working on the next killer feature&#39;);<br>Use &#39;puppet agent --enable&#39; to re-enable.</pre><h4>Enable the Agent</h4><pre>$ sudo puppet agent --enable</pre><p>and you’re good to go, the <strong>lock file is removed</strong> and the Agent will run as before.</p><h4>Caveats</h4><p>This feature is nice but does have a vicious behavior.</p><p>Let’s say you stop <em>Puppet Agent</em> but you have a 2pm deadline for the tests to be ready.</p><pre># puppet agent --disable “Puppet agent can be safely <br>restarted at 2PM”</pre><pre># puppet agent --test<br>Notice: Skipping run of Puppet configuration client; administratively disabled (Reason: &#39;Puppet agent can be restarted at 2PM&#39;);<br>Use &#39;puppet agent --enable&#39; to re-enable.</pre><p>As usual, at 2pm you realize that you need more time to work on your feature, 5pm will be enough time for you to finish. So you just extend the deadline and update the message you set earlier:</p><pre># puppet agent --disable &quot;Puppet agent can be restarted at 5PM&quot;</pre><pre># puppet agent --test<br>Notice: Skipping run of Puppet configuration client; administratively disabled (Reason: &#39;Puppet agent can be restarted at 2PM&#39;);<br>Use &#39;puppet agent --enable&#39; to re-enable.</pre><p>Wait ! … the message has not been updated.</p><p>Some would say that’s a bug, maybe that’s expected behavior.</p><h4>What about the Puppet-DB facts / reports</h4><p>When the Puppet Agent is disabled on a host, the Puppet-DB does not seem to hear about that node reportsor factsanymore.</p><p>A quick way to check that behavior is:</p><ol><li>List your node facts</li></ol><pre>$ puppet-query &#39;facts { certname = &quot;dev-host.example.org&quot; }&#39; | wc -l<br>1481</pre><p>2. Delete your node facts directly from Puppet-DB</p><pre>$ psql -c &quot;delete from factsets where certname=&#39;dev-host.example.org&#39;&quot;<br>$ psql -c &quot;delete from catalogs where certname=&#39;dev-host.example.org&#39;&quot;</pre><p>3. Check that the Puppet-DB does not hold any fact for your host</p><pre>$ puppet-query &#39;facts { certname = &quot;dev-host.example.org&quot; }&#39; | wc -l<br>0</pre><p>4. Try to run the Puppet Agent on the node where the Agent has been disabled and check your Puppet-DB’s facts again</p><pre>$ puppet-query &#39;facts { certname = &quot;dev-host.example.org&quot; }&#39; | wc -l<br>0</pre><p>This seems normal as the Puppet Agent does not run and just dies after printing out the message we’ve seen earlier.</p><p>This can however be a problem in some environments where <strong>hosts can’t just disappear from Puppet-DB for whatever reasons</strong>.</p><p>For instance, at <em>IN2P3 Computing Centre</em>, our CMDB relies on the Puppet-DB to display some information (facts, …) and this mechanism has already raised alerts if a host just disappear from the Puppet-DB.</p><p>This is why we had to develop our own solution that allows us to:</p><ul><li>disable <em>Puppet Agent</em> run on a node</li><li>allow <em>Puppet Agent</em> run in <em>white-listed</em> Puppet environments</li><li>keep Puppet-DB data updated</li><li>list in a simple manner all the nodes where <em>Puppet Agent</em> has been disabled</li></ul><p>I will discuss how we implemented this solution in a next post.</p><h4>Digging into the Puppet Agent code</h4><p>For those who are curious about where all that resides in the Puppet Agent code, you can find it here:</p><ul><li><a href="https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/json_lockfile.rb">https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/json_lockfile.rb</a></li><li><a href="https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/lockfile.rb">https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/lockfile.rb</a></li></ul><h3>Conclusion</h3><p>Temporarily disable the Puppet Agent is a very nice feature to have in your Puppet toolkit. It can save you some precious time in emergency situations when you just need to <em>fix it </em>anyway you can.</p><p>As stated above, we’re not using this Puppet Agent feature at <em>IN2P3 Computing Centre</em>. We have developed our own solution to achieve the same goal and keep our Puppet-DB data up-to-date.</p><p><strong>This solution will be developed soon in another post so stay tuned for more !</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=567f0dae36af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Trigger a Puppet catalog build in one-line]]></title>
            <link>https://medium.com/@remi.ferrand/trigger-a-puppet-catalog-build-in-one-line-c76f02d8d266?source=rss-dc687843bb4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c76f02d8d266</guid>
            <category><![CDATA[puppet]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Rémi Ferrand]]></dc:creator>
            <pubDate>Mon, 13 Aug 2018 21:45:00 GMT</pubDate>
            <atom:updated>2018-08-13T21:52:53.180Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dAbOaUO_x8cGM6DYLXWhiA.png" /></figure><p><strong>Author note</strong>: This is my first article, consider this my hello world to learn how to use this publication platform.</p><p>In day to day puppet administration it sometimes can be really useful to trigger a catalog build from a puppet agent.</p><p>I use it for <em>debugging</em> purpose or simply for <em>monitoring</em> that my puppet masters are just behaving like they should.</p><p>Here is a simple but very useful command line that can save you precious time:</p><pre>$ curl -v --cert /etc/puppetlabs/ssl/certs/$(hostname -f).pem \<br>--key /etc/puppetlabs/ssl/private_keys/$(hostname -f).pem \<br>--cacert /etc/puppetlabs/ssl/certs/ca.pem \<br>-X POST \<br>-d &quot;environment=production&amp;transaction_uuid=$(uuidgen -t)&amp;facts_format=pson&amp;facts=$(puppet facts --render-as pson)&quot; \<br>https://your-server.com:8140/puppet/v3/catalog/$(hostname -f)</pre><p><strong>Important</strong>: It may require little adjustments to adapt to your infrastructure</p><p>If you also have some quick and easy puppet commands like the one above, please share !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c76f02d8d266" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>