Skip to content

Instantly share code, notes, and snippets.

@homburg
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save homburg/c790b11354d7eb480a3e to your computer and use it in GitHub Desktop.
Save homburg/c790b11354d7eb480a3e to your computer and use it in GitHub Desktop.
Ansible command line booleans
---
- hosts: all
vars:
docker: 0
tasks:
- name: ensure bool variables work
debug: msg="docker {{ docker }}.."
# When: takes a jinja2 expression
# 0 evaluates to false
# >= 1 evaluates to true
# override the default value with
# $ ansible-playbook playbook-bool.yml -e docker=1 ...
when: docker
- name: ensure variables can be negated
debug: msg="not docker!"
when: not docker
- debug: msg="not not docker!"
when: not not docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment