Skip to main content

Posts

Showing posts from January, 2015

Test for undefined fact in puppet with strict_variables

One of my very early frustrations with puppet was that it allows variables to be used when they were undefined. Primarily this bit me by not catching typos in variable names which were often very hard to track down. I was very pleased when Puppetlabs introduced a strict_variables mode which throws an error if a manifest attempts to use an undefined variable. I recently need to check for the existence of a fact. Without strict_variables, this is straight-forward: if $::some_fact {  # do stuff here} If the fact "some_fact" exists, the variable is a non-empty string and evaluates as true in boolean context. If the fact doesn't exist, the variable is an empty string which evaluates as false in boolean context. But, with strict_variables enforced, this throws an error: Error: Undefined variable "::some_fact"; Undefined variable "some_fact" at line ... The solution is to use the getvar function from stdlib : if getvar('::some_fact'...

Google OAuth2 proxy on EL7

The team at bitly  has written an http reverse proxy that provides authentication using Google's OAuth2 API . They write about it in a blog post . The proxy is written in Go  but builds to a single, statically-linked executable, ie. there are no complex run-time dependencies, which is great. I've built an RPM for EL7 which also includes a sample systemd unit file, and sample configuration file. Both source and binary RPMs are available in my yum repo . Additionally, I've create a puppet module that installs the RPM, creates a systemd service, and sets up an nginx front end to the proxy service. The module is available from the Puppetforge , and also on github . I'd be interested in any feedback/comments/bug reports/pull requests.