# How to debug a unexpected char while templating on Trellis deploy

**URL:** https://discourse.roots.io/t/how-to-debug-a-unexpected-char-while-templating-on-trellis-deploy/5939
**Category:** trellis
**Created:** 2016-02-15T09:18:13Z
**Posts:** 6

## Post 1 by @MiquelAdell — 2016-02-15T09:18:13Z

Hi,

I have a roots fullstack environment workin on local and I’m trying to deploy to digitalocean.

I’ve created the droplet and added the ip to hosts/staging and edited staging/wordpress\_sites.yml

When I run

```
ansible-playbook server.yml -e env=staging -vvvvv
```

Everithing works untill:

```
TASK [wordpress-setup : Create/assign database user to db and grant permissions] ***
task path: /Users/miqueladell/code/miqueladell.com/trellis/roles/wordpress-setup/tasks/database.yml:11
fatal: [46.101.166.56]: FAILED! => {"failed": true, "msg": "ERROR! template error while templating string: unexpected char u'`' at 53"}
```

If I go to line 11 of

```
/Users/miqueladell/code/miqueladell.com/trellis/roles/wordpress-setup/tasks/database.yml
```

I see nothing that could cause the error:  
(I’ve added line numbers)

```
…
09 when: not mysql_remote_database and item.value.db_create | default(True)
10
11 - name: Create/assign database user to db and grant permissions
12 mysql_user: name="{{ item.value.env.db_user }}"
13 password="{{ vault_wordpress_sites[item.key].env.db_password }}"
…
```

I guess ansible is using some data from staging/wordpress\_sites.yml to fill database.yml and then run it but I don’t see anything on wordpress\_sites.yml that could produce this error:

```
env:
      disable_wp_cron: true
      wp_home: http://staging.miqueladell.com
      wp_siteurl: http://staging.miqueladell.com/wp
      wp_env: staging
      db_name: staging
      db_user: staging
```

How could I see the exact line that it’s failing? I don’t think I can add more -vvv to the command :frowning:

I really don’t know how to debug this further. Any help will be greatly appreciated, thanks.

---

## Post 2 by @fullyint — 2016-02-15T09:58:25Z

Strange. I don’t recall the backtick `` ` ever causing trouble in variable definitions.

As you know, the [calling task](https://github.com/roots/trellis/blob/cf5dfef47b01817232dbc52ebd96d914b4cddf07/roles/wordpress-setup/tasks/database.yml#L11-L21) is having trouble templating out the relevant variables. You could check these variables’ definitions for backticks or inconsistent open/closing quotes (if any quotes at all). In addition to variables you checked in `wordpress_sites.yml`, check these:

- [`db_password`](https://github.com/roots/trellis/blob/904587996849cc8397e7eb289de9701e8c59c362/group_vars/staging/vault.yml#L12)
- [`vault_mysql_root_password`](https://github.com/roots/trellis/blob/904587996849cc8397e7eb289de9701e8c59c362/group_vars/staging/vault.yml#L2)
- [`mysql_root_user`](https://github.com/roots/trellis/blob/904587996849cc8397e7eb289de9701e8c59c362/group_vars/all/database.yml#L3)

I’m eager to hear what you find. I’m adding some checks to warn users if/when they have the [problematic ``{{`` and ``{%`` strings](https://github.com/roots/trellis/blob/904587996849cc8397e7eb289de9701e8c59c362/group_vars/staging/vault.yml#L14) in their `vault.yml` file. Perhaps you’ve stumbled on a new problematic string.

---

## Post 3 by @MiquelAdell — 2016-02-15T13:02:28Z

Hi @fullyint,

Thanks for your time.

I was checking vault.yml again and I’ve discovered that I was using a salt that had **{%** on it so the scaping failed.

There is a comment just above the salts saying:

```
# Generate your keys here: https://api.wordpress.org/secret-key/1.1/salt/
  # These CANNOT contain the characters "{%" in succession
```

I shoulda have payed more attention to it.

I’ve replaced the offending characters and everything works.

Sorry about the fuzz and thanks a lot again.

---

## Post 4 by @intelligence — 2016-12-01T23:05:58Z

Sorry to raise this from the dead, but I just ran into a similar problem, using [https://roots.io/salts.html](https://roots.io/salts.html) I ended up with this offending string:  
`Sp1-qWsJ=^=Rdx73W/#LB:=C-zEh&WgG@{i{{|9?-Am*!XD$Gu#tAGidEA$Z7FyO`

Error msg: `template error while templating string: unexpected '|'`

Figure it’ll happen to somebody else sooner or later.

---

## Post 5 by @fullyint — 2016-12-01T23:43:15Z

@intelligence thanks that’s a good note that should help people if they see a similar error, even just to prompt them to update their Trellis version…

Some good news is that that salts should no longer have problems with special characters after [roots/trellis#684](https://github.com/roots/trellis/pull/684). In my test, the latest Trellis ([53e7db4](https://github.com/roots/trellis/tree/53e7db4a258381c15784e7b4decb86651dfe3afc)) appears to handle the string you posted without error.

If anyone encounters a similar `unexpected` error on variables other than the salts, consider adding the variable name to the list of [`raw_vars`](https://github.com/roots/trellis/blob/53e7db4a258381c15784e7b4decb86651dfe3afc/group_vars/all/main.yml#L15) that are automatically escaped.

---

## Post 6 by @intelligence — 2016-12-01T23:52:56Z

You guys are the best! Cheers
