Ansible 2.1 Server Setup Template Error

Hi, help needed please.
I am getting this error while executing ansible-playbook server.yml -e env=production

I’ve also tried this and still getting this error
ansible-playbook server.yml -i hosts/production -e env=production

Tried changing sshd_permit_root_login: true to false but has no effect too

I’m able to ssh root@myip at DigitalOcean Ubuntu 16.04 using ssh key

Thanks for your help

TASK [remote-user : Check whether Ansible can connect as root] *****************
System info:
  Ansible; Darwin
  Trellis at "Ansible 2.1 compatibility fixes"
template error while templating string: unexpected end of template, expected
'end of print statement'.. String:
fatal: []: FAILED! => {"failed": true}

NO MORE HOSTS LEFT *************************************************************
 [WARNING]: Could not create retry file 'server.retry'.         [Errno 2] No such
file or directory: ''

This kind of template error typically occurs when one of your variables includes opening jinja delimiters {{ or {% or {# etc., usually in one of your salts or password variables. I suggest you search your project’s variable files for a portion of that string, e.g., 7Ys|#2l1DIC<0]5*b to find the variable with the problem value. With the variables included in Trellis by default, the most likely places to look are in group_vars/*/vault.yml.

When you find the variable, if it is defined in group_vars you could add the variable name to the list of raw_vars added in roots/trellis#615.

If the variable is defined elsewhere (in a playbook, hosts file, etc.), it can’t yet be escaped via raw_vars so you have at least two options:

  • edit the variable value to not include a jinja delimiter like {{ or {% or {# , or
  • escape the variable value with raw like this:
var_name: "{% raw %}random_characters{% endraw %}"

The following are not likely relevant:

  • -i hosts/production
  • sshd_permit_root_login
1 Like

Found it! yes it’s literally this string 7Ys|#2l1DIC<0]5*b:%,s$5]oWj$K;>,FY?f^@UT2p]:^vaCbwlig.Cqh_D}{{DC which I thought of some kind of code…

it’s generated by Salt so i didn’t think that;s the cause…

the solution is to generate new Salt again and a bit of luck for not getting problematic characters :wink:

Thanks @fullyint !!

1 Like