Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible template error while templating string: unexpected

Tags:

ansible

I have the following directory

named.0.102.10.reverse
named.0.103.10.reverse
named.0.104.10.reverse
named.0.2.10.reverse
named.dreamhosts

That's my code

---
- name: Check if the dns reverse file exist based on the ips
  find:
    paths: '/tmp/test_dns'
    patterns: '^named\.'
    use_regex: True
  register: find_results

- name: print find_results
  debug: var="{{item.path}}"
  with_items: '{{find_results.files}}'

I get the following error

FAILED! => {"failed": true, "msg": "template error while templating string: unexpected '/'. String: {{/tmp/test_dns/named.5.104.10.reverse}}"}

It's seems to be a bug but after further research the bug was fixed on my version.

So maybe, i though the problem was between the chair and the keyboard :-) . Any ideas ?

like image 956
polxpolx Avatar asked Dec 13 '22 23:12

polxpolx


1 Answers

You don't need to use template in the value of the var parameter. It should contain a variable name:

- name: print find_results
  debug: var=item.path
  with_items: '{{find_results.files}}'

Writing "{{item.path}}" you provide the variable value instead of its name and Ansible gets confused.

like image 76
techraf Avatar answered Feb 23 '23 00:02

techraf