Skip to content

Instantly share code, notes, and snippets.

@adamreid
Created June 13, 2013 15:15
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 adamreid/5774514 to your computer and use it in GitHub Desktop.
Save adamreid/5774514 to your computer and use it in GitHub Desktop.
Failed and expression in ansible when clause
# Configure yum repos based on requirement for stable,
# unstable, current, or specific assembly number
---
- hosts: test
vars:
branch: trunk
branch_repo: unstable
tasks:
- name: use unstable repository
action: command echo -u
register: repo_flag
when: branch_repo == 'unstable'
- name: use stable repository
action: command echo -s
register: repo_flag
when: branch_repo == 'stable'
- name: use current repository
action: command echo -s
register: repo_flag
when: branch_repo == 'current'
- name: use latest repository
action: command echo -s
register: repo_flag
when: branch_repo == 'latest'
- name: use assembly number
action: command echo -a {{ branch_repo['assembly'] }}
register: repo_flag
when: mapping(branch_repo) and defined(branch_repo['assembly'])
- name: show repo configuration
action: command echo {{ branch }} {{ branch_repo }} {{ repo_flag }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment