Skip to content

Instantly share code, notes, and snippets.

@zeitounator
Last active March 28, 2021 08:54
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 zeitounator/8c5834bf149a514441f3cdf8cd683f05 to your computer and use it in GitHub Desktop.
Save zeitounator/8c5834bf149a514441f3cdf8cd683f05 to your computer and use it in GitHub Desktop.
# This is an old ini style
- name: Set some vars
set_fact: var1=toto var2=titi
# Yaml style is easier to read...
- name: Set some vars
set_fact:
var1: toto
var2: titi
# ..and is more flexible with real use cases (Note mandatory quotes arrount the jinja value since it starts with a double moustache)
- name: Set complex vars ini
set_fact: a_list=["element1","element2"] a_dict={"key1":"value1"} a_word=toto a_string="I'm a phrase" jinja_string="{{ some_var }}"
- name: Set complex vars yaml
set_fact:
a_list:
- element1
- element2
a_dict:
key1: value1
a_word: toto
a_string: I'm a phrase
jinja_string: "{{ some_var }}" # mandatory quotes in ansible because it starts with double moustache
other_string: "The value of var is {{ some_var }}" # Not mandatory here but I suggest you keep them as a good practice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment