ERROR! 'AnsibleUnicode' object has no attribute 'keys'

I followed all the instructions but when I run Vagrant up command I get this error:

ERROR! ‘AnsibleUnicode’ object has no attribute ‘keys’

The error states: No closing quotation Ansible failed to complete successfully.

When I open vagrant/machines/default/virtualbox/private_key, it seems to be ok

All this is very new to me, I am wondering if it has to do with not setting up a production environment. Can I just test locally with out setting up a remote server?

Yes, you can use Trellis locally without deploying to a remote server.

Copy and paste the output directly, then click the “< />” button above the post box to format it.

ERROR! 'AnsibleUnicode' object has no attribute 'keys'
/Users/cristianrodriguez/Documents/Cristian's Work/Web Sites Folder/example.com/trellis/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory:3: Error parsing host definition 'default ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user='vagrant' ansible_ssh_private_key_file='/Users/cristianrodriguez/Documents/Cristian's Work/Web Sites Folder/example.com/trellis/.vagrant/machines/default/virtualbox/private_key'': No closing quotation
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

Doing a quick search of ‘AnsibleUnicode’ within Trellis shows it’s used as part of /trellis/lib/trellis/plugins/vars/vars.py:

# wrap values if they match raw_vars pattern
elif isinstance(item, AnsibleUnicode):
    match = next((pattern for pattern in patterns if re.match(pattern, key_string)), None)
    return ''.join(['{% raw %}', item, '{% endraw %}']) if not item.startswith(('{% raw', '{%raw')) and match else item

See raw_vars in /trellis/group_vars/all/main.yml:

# Values of raw_vars will be wrapped in `{% raw %}` to avoid templating problems if values include `{%` and `{{`.
# Will recurse dicts/lists. `*` is wildcard for one or more dict keys, list indices, or strings. Example:
#   - vault_wordpress_sites.*.*_salt    -- matches vault_wordpress_sites.example.com.env.secure_auth_salt etc.
# Will not function for var names or topmost dict keys that contain a period ('.').
raw_vars:
  - vault_mail_password
  - vault_mysql_root_password
  - vault_users.*.password
  - vault_users.*.salt
  - vault_wordpress_sites

So my guess is it’s related to your vault.yml file :slight_smile:

Thanks for your help. I will take another look at it.

The error is a closing quote. You have a quote in the path. That’s most likely interfering with it.

2 Likes

That was it. Command line and this particularly type of development is completely new to me. I am used to naming directories on a Mac and never would have figured this out with out your help. Thank you very much.

1 Like