# 'site_env' is undefined

**URL:** https://discourse.roots.io/t/site-env-is-undefined/6483
**Category:** trellis
**Created:** 2016-04-18T11:20:31Z
**Posts:** 8

## Post 1 by @Ivan_Svaljek — 2016-04-18T11:20:31Z

I’ve updated my trellis clone to the latest version, but now get this error ‘site\_env’ is undefined when I run ansible-playbook -vvvv server.yml -e env=staging.

## TASK [wordpress-setup : Create database of sites] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* task path: /home/ivan/dev/moje/fapps/trellis/roles/wordpress-setup/tasks/database.yml:2 System info: Ansible 2.0.1.0; Linux Trellis 0.9.7: April 10th, 2016

‘site\_env’ is undefined  
fatal: [46.101.240.80]: FAILED! =\> {“failed”: true}  
to retry, use: --limit @server.retry

---

## Post 2 by @swalkinshaw — 2016-04-18T12:39:03Z

It’s likely that something was missed during the update process. Maybe you had merge conflicts to fix and something was forgotten?

---

## Post 3 by @lane — 2016-05-03T22:31:59Z

I’m getting this as well while trying to run vagrant provision to re-provision my local env.

`TASK [wordpress-setup : Create database of sites] ******************************fatal: [default]: FAILED! => {"failed": true, "msg": "The conditional check 'site_uses_local_db and item.value.db_create | default(True)' failed. The error was: error while evaluating conditional (site_uses_local_db and item.value.db_create | default(True)): 'site_env' is undefined\n\nThe error appears to have been in '***/trellis/roles/wordpress-setup/tasks/database.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Create database of sites\n ^ here\n"} to retry, use: --limit @***/trellis/dev.retry`

---

## Post 4 by @swalkinshaw — 2016-05-03T22:53:11Z

My reply above applies to you as well.

`site_env` exists [here](https://github.com/roots/trellis/blob/98e2f3bd89557310e8eb1cbcfee442ec60fee5ee/group_vars/all/main.yml#L19). Make sure you have it.

---

## Post 6 by @codecowboy — 2017-02-28T11:35:07Z

@swalkinshaw I’m getting the same /similar [error.in](http://error.in) trellis as at 28/2/17 You link to a file in /group\_vars/all but it doesnt say in the docs to edit that file with that line. Can this go in /staging/main.yml?

```
TASK [wordpress-setup : Create database of sites] ******************************
System info:
  Ansible 2.2.1.0; Darwin
  Trellis at "Allow for per-project packagist.com authentication"

The conditional check 'site_uses_local_db and item.value.db_create |
default(True)' failed. The error was: error while evaluating conditional
(site_uses_local_db and item.value.db_create | default(True)): {{
site_env.db_host == 'localhost' }}: {{ wordpress_env_defaults |
combine(item.value.env | default({}), vault_wordpress_sites[item.key].env)
}}: 'unicode object' has no attribute u'staging.sliponjohn.band'

The error appears to have been in
'/Users/lukemackenzie/Sites/sliponjohn.band/trellis/roles/wordpress-
setup/tasks/database.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: Create database of sites
  ^ here

fatal: [staging.sliponjohn.band]: FAILED! => {"failed": true}
```

Or do I need to have these defined in staging/wordpress\_sites.yml?:

```
mysql_db:
    name: "{{ site_env.db_name }}"
    state: present
    login_host: "{{ site_env.db_host }}"
    login_user: "{{ mysql_root_user }}"
    login_password: "{{ mysql_root_password }}"
  with_dict: "{{ wordpress_sites }}"
```

---

## Post 7 by @swalkinshaw — 2017-02-28T13:34:06Z

You don’t have the same error.

Your error says:

> vault\_wordpress\_sites[item.key].env)  
> }}: ‘unicode object’ has no attribute u’staging.sliponjohn.band’

You need to configure your sites + vault properly according to the docs: [WordPress Sites | Trellis Docs | Roots](https://roots.io/trellis/docs/wordpress-sites/#passwordssecrets)

---

## Post 8 by @codecowboy — 2017-02-28T16:12:30Z

Thanks. Turns out it was a typo in`vault.yaml` which the parser didn’t pick up. YAML, oh how I hate thee :frowning:
