Hero Image

Blog

Concatenate a complex string in Ansible

Concatenate a complex string in Ansible

Constructing a long, complex string in Ansible can be achieved quite easily utilising Python string subsitution syntax.

Suppose you have the following variables:

app_protocol: http
app_host: 12.34.56.78
app_port: 8080
app_path: api/v2/testing

You could construct a string with all the component...

4th Jul 2018 - IronicBadger
Query instance specific information on AWS

Query instance specific information on AWS

When working in a dynamic environment you can use the following syntax to query an instance for information about itself.

I found this very useful when needing to discover which availability zone an instance was running in, for example.

curl http://169.254.169.254/latest/dynamic/instance-identit...

21st Jun 2018 - IronicBadger
Ansible Tip - Using the expect module

Ansible Tip - Using the expect module

Another Ansible top tip. Suppose you are running an installer or other process via Ansible which expects the user to be present accept a license agreement, enter some information or something. Enter expect, a handy little utility which can listen for certain strings in stdout and react accordingly...

23rd Mar 2018 - IronicBadger
Ansible Tip - Referencing items from a hash

Ansible Tip - Referencing items from a hash

Let's say you are in the midst of writing an Ansible playbook and you need to reference multiple values from an 'item' in different places. Here's a neat code snippet that will allow you to do just that.

hosts: all 
vars:
  file_path_1: /usr/bin
  file_path_2: /example
  file_path_3: /opt
tasks:...
23rd Mar 2018 - IronicBadger