'vagrant up' - Error at Trellis at "Add MariaDB 10.2 PPA"

I’m getting the below error when I try to run ‘vagrant up --provision’. New to Trellis and can’t find anything to resolve the issue online.

fatal: [default]: FAILED! => {“msg”: "The conditional check ‘site_uses_local_db and item.value.db_create | default(true)’ failed. The error was: {{ site_env.db_host == ‘localhost’ }}: {{ wordpress_env_defaults | combine(item.value.env | default({}), vault_wordpress_sites[item.key].env) }}: |combine expects dictionaries, got None\n\nThe error appears to have been in

This error would be really hard to understand.

Ansible loads a YAML variable without a value as the python None (another example), and the combine filter that Trellis uses here only works with hashes/dictionaries. I’m guessing your group_vars/development/wordpress_sites.yml has

env:   
# nothing down here, thus env is None

If that’s the case, just remove that empty env var name or comment it out and try vagrant provision

Thanks for getting back to me. I don’t have that line. It’s just the below:

# Documentation: https://roots.io/trellis/docs/local-development-setup/
# `wordpress_sites` options: https://roots.io/trellis/docs/wordpress-sites
# Define accompanying passwords/secrets in group_vars/development/vault.yml

wordpress_sites:
  xsite.com:
    site_hosts:
      - canonical: xsite.test
        redirects:
          - www.xsite.test
    local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
    admin_email: admin@xsite.test
    multisite:
      enabled: false
    ssl:
      enabled: false
      provider: self-signed
    cache:
      enabled: false

Hmm, yeah, your wordpress_sites looks fine.

I thought it less likely to occur, so I didn’t mention it: The same error could occur if your group_vars/development/vault.yml has an empty env value in vault_wordpress_sites. Could you check that?

no, it has a value:

env:
db_password: “rEk#W$xxxxxxxxxxyF4MQWZp”

the full error msg is below if that helps narrow things down:

TASK [wordpress-setup : Create databases for sites] ****************************
System info:
  Ansible 2.4.3.0; Vagrant 2.0.2; Darwin
  Trellis at "Add MariaDB 10.2 PPA"
---------------------------------------------------
fatal: [default]: FAILED! => {"msg": "The conditional check 'site_uses_local_db and item.value.db_create | default(true)' failed. The error was: {{ site_env.db_host == 'localhost' }}: {{ wordpress_env_defaults | combine(item.value.env | default({}), vault_wordpress_sites[item.key].env) }}: |combine expects dictionaries, got None\n\nThe error appears to have been in '/Users/username/workspace/xsite-wp/trellis/roles/wordpress-setup/tasks/database.yml': line 3, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n- block:\n  - name: Create databases for sites\n    ^ here\n"}

The values beneath env are only part of env if they are indented. Compare the default indentation.
Try this adjustment:

  env:
- db_password: “rEk#W$xxxxxxxxxxyF4MQWZp”
+   db_password: “rEk#W$xxxxxxxxxxyF4MQWZp”

Without that indentation, env is empty and db_password is just some separate variable.

With the indentation, env is a hash or dictionary with a db_password dictionary key/value.

2 Likes

sorry, it is indented. I just formatted the above incorrectly in the message. It’s as below:

env:
  db_password: "rEk#W$q&CxxxxxxxxxxMQWZp"

As far as I can tell, the relevant combine is for the site_env var. We’ve confirmed proper format for 2 of the 3 dictionaries being combined.

The one dictionary format we still haven’t confirmed is wordpress_env_defaults. Could you confirm that yours looks like the default in terms of indentation and content?

1 Like

I pasted the formatted version from that link and it ran ok. Thanks for all your help on this.

2 Likes