Pense-bête ansible - Jinja - syntax if
This commit is contained in:
@@ -8,6 +8,12 @@ date: 2024-07-19
|
||||
|
||||
# Pense-bête Ansible
|
||||
|
||||
### Syntaxe `if`
|
||||
```jinja
|
||||
'{%- if env_trigramme not in ['pro'] %}[{{ env_without_pi | upper }}]{% endif -%}'
|
||||
```
|
||||
Affichera `''` si `env_trigramme: pro` ou `ENV` si `env_trigramme: env`.
|
||||
|
||||
### Ternary pour choisir la valeur d'une variable selon un état vrai ou faux
|
||||
```yaml
|
||||
- name: "{{ boolean_var is not defined|ternary('is true', variable + 'is false') }}"
|
||||
|
||||
Reference in New Issue
Block a user