Ansible deployment of DNS zone files.

January 8th, 2016 § 0 comments § permalink

Ansible

I’ve recently started to refactor my server configuration. It’s always been built with Ansible but it was one of the first things I ever did using that and I was fairly certain that every way I could have been doing it wrong I was.

One of the things I’d wanted to do was rationalise what was in my playbooks. They should ideally be all code and no configuration but I was using a lot of templates for various system files and they were mostly configuration for content, not services – the chief culprits being dns zone and nginx/apache vhost files. When you refer to a template from with a playbook it expects that the files are inside the playbook itself. This just doesn’t seem right to me. You can specify absolute locations though and so with a bit of finagling I was able to get the files where I wanted. The magic is to do something like

{{ inventory_dir }}/../templates/zones/*.j2

inventory_dir is the absolute path to your main inventory file and so we can use this to point at a global templates folder with a bit of path manipulation. As you can see I’m stepping up out of the hosts folder and then down into templates.

This works really well but there was another thing I wanted to do. I was configuring the zones that I had to populate on the system using normal vars files (a simple list object with domain names in), and then using that to grab the templates to put on the system. This struck me as wasteful. The addition of a new domain meant that I had to add the file and then amend an array just to inform Ansible to read the file. There had to be a better way. Sure enough with_fileglob came to the rescue. This allows Ansible to parse a path for files and then gives us the tools necessary to feed our provisioning. With a bit of Jinja2 manipulation magic I ended up with this

- name: Install zone files
  template:
  src: "{{ item }}"
  dest: /etc/bind/zones/{{ item | basename | regex_replace("\.j2$","") }}
  owner: root
  group: root
  mode: 0644
  register: zone_files
  with_fileglob:
    - "{{ inventory_dir }}/../templates/zones/*.j2"
  notify:
    - reload bind9

The final piece of this puzzle was to make sure that each of these zone files were referred to in the Bind configuration. I scratched my head over this for a bit and then it occurred I could register the results of the above action as a variable and use it in the template for that file. So I registered zone_files and set about concocting a template loop

{% for zone in zone_files.results %}
zone "{{ zone.item | basename | regex_replace("\.db\.j2$","") }}" {
   type master;
   file "/etc/bind/zones/{{ zone.item | basename | regex_replace("\.j2$","") }}";
   allow-transfer { slaves; };
};
{% endfor %}

It didn’t turn out too complicated in the end – certainly very readable but the end result is a much nicer playbook with all configuration being both more succinct and living in appropriate places.

Why do my sockets keep disappearing?

May 14th, 2015 § 0 comments § permalink

I’m working on getting my froxlor instance setup with PHP5-FPM and Nginx and was encountering an issue whereupon reboot the PHP functionality would be broken. Looking in syslog would give me about 30 lines of PHP5-FPM failing to start and then giving up. Looking in /var/log/php5-fpm.log would tell me nothing useful other then the configtest passed.

I eventually found a helpful message in the /var/log/upstart/php5-fpm.log file:

[14-May-2015 09:21:54] ERROR: unable to bind listening socket for 
address '/var/run/nginx/username-domain.com-php-fpm.socket': No 
such file or directory (2)

True enough the /var/run/nginx folder did not exist. I could not figure out where it was going.

After hair pulling research I found that the /var/run mount point is run as tmpfs and so is deleted on reboot. In order to fix this I had to ensure the directory was recreated before PHP5-FPM started. It turns out this if fairly easy with upstart. I added this stanza:

pre-start
    ... other stuff ...
    [ -d /var/run/nginx ] || mkdir -p /var/run/nginx
end script

to the /etc/init/nginx.conf file to have the folder created on boot.

Problem solved.

Space. Where things are dangerous. I’m not elite.

January 29th, 2015 § 0 comments § permalink

Trevithick Station. LHS 3447.

So I load into the game and this is what I see. I’m in a loaned Sidewinder and have 1000 credits to my name.

This game is gorgeous. The sound design is fantastic – an incredibly immersive spaceship soundscape surrounds you. It creaks, hums and clicks with every control input you make. When you hear an out of place sound you know something is amiss with your ship.

Up next I’ve ordered the components to make myself an EdTracker and I’ve been told a joystick is on its way. At some point I think an Oculus Rift will be necessary. Then a gaming chair… I can see myself getting lost in this universe.

» Read the rest of this entry «

Achievement Get!

July 16th, 2014 § 0 comments § permalink

Grrr Rawr

This expansion has ended on a high note for me thanks to my awesome girlfriend and Openraid. I’ve managed to get my ‘Ahead of the Curve‘ as well as the meta and the challenge mode silver rewards. This is all awesome and to me at least feels like a great place to be going into Warlords.

Diablo. Thou hast become fun again.

March 14th, 2014 § 0 comments § permalink

Die Maghda die

With the changes Blizzard have implemented in the pre-expansion patch I’ve re-found Diablo. Loot drops – lots of them, quick leveling and a configurable difficulty that means I can be punished for my mistakes and not walk around like I’m some sort demi-god which realistically gets boring very quickly.

I was indifferent to Reaper of Souls but now I’m definitely looking forward to playing it.

 

I don’t want to know. Unless it’s really, really something I’ll want to know.

February 28th, 2014 § 0 comments § permalink

River Song of Dr. Who fame uses her catchphrase.

Apologies for the GIF but it is rather appropriate. I’m itching to know of all the gameplay adjustments and tweaks made for Warlords of Draenor but I can’t bring myself to look at sites such as mmochampion – I know in amongst all these nuggets of useful knowledge there are going to be some horrendous gameplay spoilers. I was a part of the Cataclysm beta and although it was a hoot it did significantly diminish the fun I had when running through the content for a second time. I was about as spoiled as you can get.

» Read the rest of this entry «

Hammer Time

January 10th, 2013 § 0 comments § permalink

U can't touch this

Thanks to the efforts of Elsen, the members of Jane Doe and the denizens of Open Raid I now make awesome awesome bubbles.

My Christmas Project – Part Deux

January 6th, 2013 § 1 comment § permalink

As detailed in my last post my World of Warcraft project for this Christmas break was to get my bank alt Gnome to level 80 for a Herald of the Titans run that’ll be happening sometime later this year.

Unfortunately I did not commit the necessary time to the project to get it done. I did however get him 13 more levels up to a nice 53. About halfway through I was informed that I really should have him in a guild with all the leveling perks and was hindering things by keeping him in my banking guild ‘The Royal Bank of Grokk’.

A quick switcheroo later and I’m now soaking up the perks. What a nub.

My Christmas Project

December 21st, 2012 § 3 comments § permalink

My 2012 Christmas Project is to level my 40-ish bank alt Grokknome. The tricksy little Gnome Rogue must be level 80 by the end of the break so I can take him into Ulduar and get a Herald of the Ancients achievement at some point next year. Failure on this point will result in not getting said achievement – this is bad.

There. Since it’s now written down it has to happen.

Mists of Pandaria beta

May 9th, 2012 § 0 comments § permalink

I was fortunate enough to get on the Cataclysm Beta. If you scroll down enough you’ll see my huge screenshot gallery and possibly a few thoughts on it. It was a fantastic experience but I’m not going to repeat it.

Because Spoilers.

Since I purchased the Annual pass I was guaranteed a spot on the MoP beta. This excited me back last year when I signed up but as time passed I’ve decided that no, I don’t want to know what a Panda is like, that no, I don’t want a Monk just yet and that no, I really don’t want to know how they’ve changed the Holy Paladin’s play style/role/armour/beard

So sorry for a lack of screen shots. You’ll have to make do with the one above.

css.php