This site is archived (last post 2022) and kept online for reference. Noe's current site is engonzal.com.

Using Ansible "when" Statements

Using Ansible “when” statements allows you to set parameters for when a task should play out. I’ve put together some examples of how to use basic when statements that I’ve come across. Booleans (True or False) In the example playbook below, I print “Hello world” when the"test_var" variable is true. In the case below we use the “bool” filter to make test_var evaluated as a boolean (ie true or false), then ensure it’s true: ...

November 12, 2018 · map[name:Noe Gonzalez]