Hi. I’m struggling to escape double curly braces in a dictionary. I’ve tried the {{ ‘{{’ }} blah {{ ‘}}’ }} method, tried using backslashes and also tried using {% raw %}{{blah}}{% endraw %}
I need to be able to do this as datadog uses curly braces in its alerts as macros.
Here’s an example I’m using to debug:
vars/main.yml:
datadog_alerts:
- name: “Testy test test McTest {{ ‘{{’ }}host.name{{ ‘}}’ }}”
query: “‘testhost.status’.over(‘*’).by(‘check’,‘id’).last(2).count_by_status()”
type: service check
message: ‘Testy test test test test’
tasks/main.yml:
- name: List datadog monitors
debug: “{{ item.type }} {{ item.name }} {{ item.query }}”
with_items: datadog_alerts
Running that play (Ansible v2.1.0) results in:
TASK [datadog-alerts : List datadog monitors] **********************************
fatal: [localhost]: FAILED! => {“failed”: true, “msg”: “ERROR! ERROR! ‘host’ is undefined”}
as it’s trying to interpolate host.name.
Does anyone have any ideas on how to get around this?
Regards,
Brian