Want to test Ansible playbooks that require systemd in Docker? Try this.

Reading Time: Approximately 2 minutes.

Kubernetes and other cloud-native strategies might be putting configuration management out to pasture, but I found myself writing a playbook recently while learning how to create infrastructure as code for Azure. I needed to start my Flask web server and Postgres database with systemd, which isn’t a pattern that’s easily supported by Docker. I got this working with Docker Compose, however, and this post will show you how! Create a Docker Compose file with the following services: version: '2. … »

Getting output from Docker containers from within Ansible

Reading Time: Approximately 1 minutes.

The Problem

You want to use Ansible’s docker_container module to do stuff, but want to also perform actions based on their output without specifying a logging driver or writing to a temp file.

The Solution

Do this:


Winning at Ansible: How to manipulate items in a list!

Reading Time: Approximately 3 minutes.

The Problem

Ansible is a great configuration management platform with a very, very extensible language for expressing yoru infrastructure as code. It works really well for common workflows (deploying files, adding authorized_keys, creating new EC2 instances, etc), but its limitations become readily apparent as you begin embarking in more custom and complex plays.

Here’s a quick example. Let’s say you have a playbook that uses a variable (or var in Ansible-speak) that contains a list of tables, like this: