Transient Playbooks for Ansible

So I had a unique scenario where we built a solution for users using Ansible but wanted to make it simple so that it didn’t require the end users to understand how to build an inventory or playbooks. So the solution we came up with was to build Ansible playbooks and inventories with Ansible itself. The users just need a single YAML file and then run a make command and Ansible builds itself the inventory, playbooks, and group_vars at run time....

June 17, 2019 · 3 min · 463 words · John Hooks

Goniq

In my journey to better my development skills I’ve been trying to write some small Go applications. I needed a sorter like uniq but on a Windows machine for a project I was doing. So I decided to write one. Unlike uniq the input does not need sorted beforehand. The program takes either stdin or can read from a file which is passed as the first argument. stdin: echo "test thing test thing other" | goniq...

May 25, 2019 · 1 min · 148 words · John Hooks

Nomad

Nomad is a job scheduler created by Hashicorp. Since it’s written in Go, it’s a single, cross platform, statically linked binary. It has drivers for Docker, Qemu, Rkt, Java, App execution, and a beta for LXC. I’ll just go over the exec driver in this post. To start you need to download Nomad from here. I stuck it in /usr/local/bin. I used Vagrant to bring up a server and two clients....

July 7, 2018 · 3 min · 515 words · John Hooks

XFS Deduplication with Reflinks

Reflinks for XFS are available in Fedora 27, so you no longer need to pull and compile xfsprogs from git. To leverage reflinks in XFS, you need to create a file system with the reflink=1 flag. [root@starscream mnt]# mkfs.xfs -m reflink=1 filesystem In my example I just created a file and mounted it on a loop device. [root@starscream mnt]# mkfs.xfs -m reflink=1 test.img Then I’ll mount it [root@starscream mnt]# mount -o loop test....

March 4, 2018 · 2 min · 375 words · John Hooks

Directory Server using Go

I’ve been spending time learning Go and here’s a small utility I wrote that’s similar to Python’s SimpleHTTPServer. This utility just creates a small HTTP server serving the directory you define: package main import ( "log" "net/http" "os" ) func main() { if len(os.Args) < 2 { log.Fatal("You must enter a path") } path := os.Args[1] http.Handle("/", http.FileServer(http.Dir(path))) http.ListenAndServe(":8000", nil) } Then just do: go build main.go ./serve /etc

February 22, 2018 · 1 min · 69 words · John Hooks

Create VMs on KVM with Ansible

So the Ansible virt module doesn’t have a clone option and the creation of guests is a little limited. Because of this we have to use the shell or command modules and try to make them idempotent. This is a simple example and the dictionary can be expanded to a lot more customization. There is a way to use libvirt as a dynamic inventory and set group and host vars on guests, but I’ll cover that in a different post....

October 4, 2017 · 2 min · 309 words · John Hooks

Automated Ansible Testing with Molecule

Infrastructure testing provides some challenges just because of the mere fact you are building machines and not just compiling code. To test Ansible, I used to run Ansible with --syntax-check and --list-tasks. For roles I would run local tests with Vagrant using the tests/ directory in the role. The tests had Ansible test itself with the uri module or other checks. This is ok for simple checks but can be cumbersome and time consuming as it doesn’t catch everything....

September 30, 2017 · 2 min · 339 words · John Hooks