Recent posts

Jinja2 selectattr() Filter

April 18, 2017

As per the documentation: “selectattr() filters a sequence of objects by applying a test to the specified attribute of each object, and only selecting the objects with the test succeeding. If no test is specified, the attribute’s value will be evaluated as a boolean.“ Example #1 This blog post does a great job of demonstrating how to use sele...

Jinja2 Overview

April 18, 2017

There are two ways in which you can use Jinja templates inside of Ansible are: Templates Filters This blog post demonstrates both of these techniques being used. The information contained in the post is contained below for convenience. Data The following data will be used by the template and filter in the subsequent sections of this pa...

Jinja2 map() Filter

April 18, 2017

Reference: jinja Applies a filter on a sequence of objects or looks up an attribute. This is useful when dealing with lists of objects but you are really only interested in a certain value of it. The basic usage is mapping on an attribute. Imagine you have a list of users but you are only interested in a list of usernames: Users on this page:...

Jinja2 Filter Overview

April 18, 2017

Reference: Stack Overflow With the pipe character you pass a value to a filter. There are numerous Jinja 2 filters but Ansible brings some additional filters. (Also see Conditionals.) The term filter might be confusing at times because all the filters work very differently. Some for example reduce a result set of a hash/array, some modify cont...

Jinja2 equalto() Test

April 18, 2017

Reference: Jinja Check if an object has the same value as another object. Example As per the selectattr( )  page, the Jinja equalto( )  Test, as well as the Ansible match( )  and search( )  Tests all work in a similar fashion. Using this dictionary: - hosts: localhost connection: local gather_facts: no vars: network: address...