mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-29 15:39:20 +00:00
Upgraded variable support met with upgraded conditional support, see examples/playbooks/upgraded_vars.yml
for details!
This commit is contained in:
parent
38c2b14339
commit
f585c4cde7
6 changed files with 58 additions and 25 deletions
24
examples/playbooks/upgraded_vars.yml
Normal file
24
examples/playbooks/upgraded_vars.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# in Ansible 1.2 and later, the $foo variable syntax, which is friendly enough for simple things
|
||||
# has been upgraded to allow Jinja2 substitiutions as well, which is now the preferred Syntax.
|
||||
# here is an example. Note that Jinja2 conditionals belong only in templates. Use ansible conditionals
|
||||
# in playbooks.
|
||||
|
||||
---
|
||||
|
||||
- hosts: all
|
||||
|
||||
tasks:
|
||||
- shell: echo 'hello {{ ansible_hostname.upper() }}'
|
||||
|
||||
- shell: echo 'match'
|
||||
when: 2 == 2
|
||||
|
||||
- shell: echo 'no match'
|
||||
when: 2 == 2 + 1
|
||||
|
||||
- shell: echo '{{ ansible_os_family }}'
|
||||
|
||||
- shell: echo 'Centos'
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue