1

I have this Ansible playbook:

  vars:
    a: "key"
    b: "value"
    something:
      "{{ a }}": "{{ b }}"
  tasks:
    - name: debug
      debug:
        msg: "{{ something | to_nice_yaml }}"

The output is:

ok: [localhost] => {
    "msg": "'{{ a }}': value\n"
}

How do I make this be key: value instead of {{ a }}: value?

Misko
  • 1,542
  • 2
  • 19
  • 31

1 Answers1

1

You can try set_fact:

tasks:
    - set_fact: something="{{ a }}:{{ b }}"
graphite
  • 2,920
  • 22
  • 40
  • Unfortunately, I can't do that. I have a large dict, which contains config that is then dumped into yaml as a config for a daemon. I am not aware how would it be possible to set_fact for one attribute of that dict :( – Misko Apr 05 '18 at 17:08