The original words of Phanes, tirelessly carved into a slab of "No'".

Puppet, Segment VII.

I’ve been busy playing with vagrant for my work laptop.

I got one of those super fancy apple laptops with OSX on it.  I wish I could say I were happy with it, but Apple’s gone back to its old ways of trying to prevent customization and thinking they’re smarter than everyone who uses their product– and know anything we’ll ever want.

What I want is a damned Linux desktop environment so I can be 100% functional on this thing.

Without the option to deliver it to their UI architect’s desk in a firey rage about why I can’t replace the desktop shell, I needed to improvise.

With XQuartz out of the picture since they no longer allow you to replace OSX’s cocao/aqua scheme with X11/gtk|qt, I installed vagrant with brew, and then used vagrant to install ubuntu xenial in a vm.  From there I set up vncserver with xrdp, port forwarding, NAT, and I’m good to go.

Well, almost.  GLX is broken with vncserver/xrdp and I’m not sure what the issue is.  Plus, virtualbox is kind of weird– and vagrant, among other things, is a big wrapper for virtualbox.

So, the last missing pieces, everpad and hipchat, won’t be usable until I fix this, since they depend on GLX due to refusing to use GTK or QT.  Pidgin has XMPP support for hipchat but it’s woefully inadequate.  They need a fullblown plugin which I don’t have time to write right now.

After that, I need to research car insurance since Ohio is a compulsory-purchase-of-private-goods-and-services-in-a-capitalist-market state and Tennessee was not.  Time limit.

After that I need to send an email about that thing I said I’d send an email about.

After that I need to do laundry.

After that I need to get the numbers to pay the lights tomorrow since I lost them.

So pretty easy week.  Things slowed down a bit, thankfully.

But, I’m here to talk about Puppet while I wait for my chicken wings to be delivered.

Fire up the VM in Virtualbox.

So, I was in the “modules” section and accompanying quest, and had performed a tree dump of the production environment’s modules directory.

root:brace.tyro@$VM_IP_ADDRESS

quest begin modules

So, now that we’re caught up to where I was at last in segment VI of this article series, I’m going to start creating a new module.  In this case we’re going to create a module that manages the settings for vim.

cd /etc/puppetlabs/code/environments/productions/modules

Top-level directory’s name is the module’s name:

mkdir vimrc

create 3 subdirectories, manifests, examples, files:

# mkdir vimrc/{manifests,examples,files}
# tree vimrc
vimrc
├── examples
├── files
└── manifests

I’ve turned on line numbering in my .vimrc with the line set number so I can quickly tell if it’s been updated.

cp ~/.vimrc vimrc/files/vimrc

Oh, they want to use the same test.  So I removed the set number line from my active vimrc, and will know the file got updated later if I see line numbers later.

Now we create the manifest init.pp.

Skipping a bunch of repetitive, redundant stuff about how the file you just copied and know is at /root/.vimrc is at /root/.vimrc and the directives that are painfully obvious for what they are that will be in the class in this manifest, they give you some information finally.  A puppet file server URI is structured as follows:

puppet://{hostname(optional)}/{mount_point}/{path}

uhm.

puppet://[host]/path/to/resource

uhm.  It’s just a URI, this is an external standard.  Just use a protocol specifier in the URI of puppet.  Jesus.

puppet://[host]/some/path/to/file

Just like you would with file:/// in most browsers.  That unnecessarily complex description out of the way, back to the class definition we were working on for the manifest (flow!  flow!):

Ok, more on URI’s.  modules is a special word in URIs that reference the root modules directory for the environment.

source => ‘puppet:///modules/vimrc/vimrc’,

And I’ve saved your eyes from multiple paragraphs that I promise you don’t care about.

Or, if you want to skip almost all of the content, you can just look at this and have every single bit of that be very obvious and not needing an explanation:

class vimrc {
  file { '/root/.vimrc':
    ensure => file,
    source => 'puppet:///modules/vimrc/vimrc',
  }
}

But hey, short manuals don’t justify cost.

Run the parser:

puppet parser validate vimrc/manifests/init.pp

So far so good.

Add include vimrc to vimrc/examples/init.pp (you know how to edit a file by this point, and if you don’t, you shouldn’t be using this).

We’re skipping the dry run with the –noop flag because I know what it does, it’s only one class.

puppet apply.  You know the drill by now.  It worked.

It’s midnight and I no longer give a shit about this.  Segment 8 is coming.  Then when all this is done, a streamlined version of all of it that covers the content just as well, I’m thinking I can fit it into about 4 pages that don’t require a vm by this point.

 

Next Post

Previous Post

Leave a Reply

© 2021 Phanes' Canon

The Personal Blog of Chris Punches