0

I need to be able to set variables using tasks in Ansible. I use set_fact for this, but cannot seem to access the fact I set with this. What is wrong with the code below:

- name: kludge1 
  set_fact: fake_y = "{{ [] }}" 

- name: Loop 
  debug: 
    msg: "{{ item }}" 
  with_items: "{{ fake_y }}"
jdoestackoverflow
  • 607
  • 1
  • 7
  • 15

1 Answers1

1

You have spaces before and after =...

- name: kludge1 
  set_fact: fake_y="{{ [] }}"

Avoid var= shortcut syntax. Use original YAML syntax instead, it gives less errors:

- name: kludge1 
  set_fact:
    fake_y: "{{ [] }}"
Konstantin Suvorov
  • 65,183
  • 9
  • 162
  • 193