0
votes

I need to have the following in my Ansible playbook:

with_items: "{{ ab36-1E }}"

The above doesn't work and leads to an error in Ansible 2.1 and 2.2 versions.

{"failed": true, "msg": "template error while templating string: unexpected char u'E' at 8. String: {{ab36-1E}}"}

However, this works: with_items: "{{ ab361E }}"

{{ab36-1E}} is a dictionary variable defined in a YAML file and referred to in the playbook.

I am wondering if there is a way to use {{ ab36-1E }} instead of {{ ab361E }} within with_items in Ansible.

1
What is ab36-1E? not a valid variable in Ansible What are you trying to do? - helloV
Remember, in ansible within {{ }} you're essentially writing ninja. With items would expect a list. You appear to be giving it a string, but not enquoting it so jinja can't parse. - Daniel Farrell
Updated my question. - Vijay

1 Answers

0
votes

No, it is not possible and it's not limited to with_items.

What Makes A Valid Variable Name:

Variable names should be letters, numbers, and underscores. Variables should always start with a letter.