Ansible error on vagrant provision

during this step …

default: Running ansible-playbook…
PLAY [Set ansible_python_interpreter] ******************************************

i am getting this error :

ERROR! failed to combine variables, expected dicts but got a ‘dict’ and a ‘AnsibleUnicode’:

{“ntp_timezone”: “Etc/UTC”, “site_env”: "{{ wordpress_env_defaults | combine(vault_wordpress_env_defaults | default({}), item.value.env | default({}), vault_wordpress_sites[item.key].env) }}

Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.

i had ansible 2.7.10 installed, i downgraded to 2.7.5, still getting the error and can’t complete provision

still stuck on this, im using ansible 2.7.5, vagrant 2.2.4. i have destroyed the box, re-provisioned, tried other versions of ansible. anyone seeing the same error?

Please share the full contents of any files that you modified in your Trellis install versus the base repo

thanks for your reply Ben.

i did update trellis to 1.0.2, before this happened. to check the update i have cloned trellis from github and checked out version 1.0.2, then in phpstorm compared the 2 trellis folders. the differences are:

  • .gitignore
  • ansible.cfg (one line added for vault file)
  • users.yml, vault.yml, wordpress_sites.yml
  • hosts (production & staging)
  • roles/php/defaults/main.yml (execution time, filesize settings)

the changes are just project specific configuration

this is the full error:

ERROR! failed to combine variables, expected dicts but got a ‘dict’ and a ‘AnsibleUnicode’:
{“ntp_timezone”: “Etc/UTC”, “site_env”: “{{ wordpress_env_defaults | combine(vault_wordpress_env_defaults | default({}), item.value.env | default({}), vault_wordpress_sites[item.key].env) }}”, “logrotate_scripts”: [{“path”: “{{ www_root }}/**/logs/.log", “options”: [“weekly”, “maxsize 50M”, “missingok”, “rotate 8”, “compress”, “delaycompress”, “notifempty”, “create 0640 {{ web_user }} {{ web_group }}”, “sharedscripts”], “name”: “wordpress-sites”, “scripts”: {“postrotate”: “service nginx rotate”, “prerotate”: “if [ -d /etc/logrotate.d/httpd-prerotate ]; then \\n run-parts /etc/logrotate.d/httpd-prerotate; \\n fi \\n”}}], “sshd_password_authentication”: false, “cron_enabled”: “{{ site_env.disable_wp_cron and (not item.value.multisite.enabled | default(false) or (item.value.multisite.enabled | default(false) and item.value.multisite.cron | default(true))) }}”, “ferm_input_list”: [{“dport”: [“http”, “https”], “type”: “dport_accept”, “filename”: “nginx_accept”}, {“dport”: [“ssh”], “type”: “dport_accept”, “saddr”: “{{ ip_whitelist }}”}, {“dport”: [“ssh”], “seconds”: 300, “hits”: 20, “type”: “dport_limit”}], “www_root”: “/srv/www”, “wordpress_env_defaults”: {“wp_env”: “{{ env }}”, “db_user”: “{{ item.key | underscore }}”, “disable_wp_cron”: true, “wp_siteurl”: “{{ ssl_enabled | ternary(‘https’, ‘http’) }}://{{ site_hosts_canonical | first }}/wp”, “db_name”: “{{ item.key | underscore }}_{{ env }}”, “domain_current_site”: “{{ site_hosts_canonical | first }}”, “db_host”: “localhost”, “wp_home”: “{{ ssl_enabled | ternary(‘https’, ‘http’) }}://{{ site_hosts_canonical | first }}”, “db_user_host”: “localhost”}, “apt_package_state”: “present”, “mail_password”: “{{ vault_mail_password }}”, “site_hosts_redirects”: “{{ item.value.site_hosts | selectattr(‘redirects’, ‘defined’) | sum(attribute=‘redirects’, start=[]) | list }}”, “mail_smtp_server”: “smtp.example.com:587”, “web_group”: “www-data”, “mail_user”: “smtp_user”, “site_hosts”: “{{ site_hosts_canonical | union(site_hosts_redirects) }}”, “ip_whitelist”: [“{{ (env == ‘development’) | ternary(ansible_default_ipv4.gateway, ipify_public_ip | default(‘’)) }}”], “sshd_permit_root_login”: true, “apt_dev_package_state”: “latest”, “ntp_manage_config”: true, “multisite_subdomains_wildcards”: "{{ item.value.multisite.subdomains | default(false) | ternary( site_hosts_canonical | map(‘regex_replace’, '^(www\.)?(.)$', '.\2’) | list, [] ) }}“, “admin_user”: “ubuntu”, “users”: [{“keys”: [”{{ lookup(‘file’, ‘~/.ssh/id_rsa.pub’) }}“], “name”: “{{ web_user }}”, “groups”: [”{{ web_group }}“]}, {“keys”: [”{{ lookup(‘file’, ‘~/.ssh/id_rsa.pub’) }}"], “name”: “{{ admin_user }}”, “groups”: [“sudo”]}], “mail_hostname”: “example.com”, “site_hosts_canonical”: “{{ item.value.site_hosts | map(attribute=‘canonical’) | list }}”, “sites_use_ssl”: “{{ wordpress_sites.values() | map(attribute=‘ssl’) | selectattr(‘enabled’) | list | count > 0 }}”, “composer_keep_updated”: true, “composer_global_packages”: [{“name”: “hirak/prestissimo”}], “repo_accept_hostkey”: true, “raw_vars”: [“vault_mail_password”, “vault_mysql_root_password”, "vault_users..password”, “vault_users.*.salt”, “vault_wordpress_env_defaults”, “vault_wordpress_sites”], “ssl_stapling_enabled”: “{{ item.value.ssl is defined and item.value.ssl.stapling_enabled | default(true) }}”, “web_user”: “web”, “known_hosts”: [{“name”: “github.com”, “key”: “github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==”}, {“name”: “bitbucket.org”, “key”: “bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==”}, {“name”: “gitlab.com”, “key”: “gitlab.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjquxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf”}, {“name”: “gitlab.com”, “key”: “gitlab.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onrSzH9bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9”}], “ssl_enabled”: “{{ item.value.ssl is defined and item.value.ssl.enabled | default(false) }}”, “web_sudoers”: [“/usr/sbin/service php7.3-fpm *”], “apt_security_package_state”: “latest”, “apt_cache_valid_time”: 3600, “mail_admin”: “admin@example.com”}
“30383234323962343134626231656437646533333138663138643233386533346363303561366639 6139653035306632666638376162343838636131343366630a663931366633363837373632323363 39623534343663353239646134386664646438656662656461363262313331383764323131653032 3732366631306335340a393238663134326135663466313962393134383239623638373062363230 38353939363563653032323031373736613566353234303262333465613762613936313032396631 65383664303230393531386636633463613631643463346565616664626233363438363936373530 34313065363930633435356136646437633566366231653438643332396134353263633163353639 39613030336531656138333737646232383463656466333166323730636432336264653831306264 64623530333664623061363266336265366230363032353232626138633638376565633061663330 63313731313266643732366338303137663937633062636537393534356430386133316638336164 65323336346261323837336633356336303530333838643838356161373661663931306562373132 65363334393466643537383166653031303161663137653138306137326332346238616135373939 65373535663265316534353934393665333863343264323262356436396334333030363462616363 34616335663062653139333761313435393562306530666139336432626132633633306134626162 66646364633733306666656435393634646537653662323466343161326665383761656432303133 36343133353463343630393030383834353930393162373862393033643739316138623030313837 61666433383766373961306165356636396465646562626534626463633564636239363737616636 65656362633438616237666463626265666237616635643437393463376530346536306432383636 65326461323663653839336566393938396334633764386466663835376332376437346531633839 65383561363430373230633837376137316537313432323636633838396462306662346137323837 33363366396432396330353964313866633864353166386431656164643164613138”
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

any help on this would be much appreciated, this has halted a huge chunk of work, thanks

Searching for your error gave me these:

https://grokbase.com/t/gg/ansible-project/163a0mcdt7/how-to-debug-error-failed-to-combine-variables-expected-dicts-but-got-a-dict-and-a-ansibleunicode

Do either of those apply?

Still waiting on the full contents of the files you’ve changed, not a list of the files you’ve changed

sorry ben, here are the changes:

ansibe.cfg
added 1 line:
vault_password_file = .vault_pass

group_vars/all/users.yml
changed user name:
admin_user: admin

group_vars/development/vault.yml
changed to:

vault_mysql_root_password: devpw

vault_wordpress_sites:
  myproject.co.uk:
    admin_password: admin
    env:
      db_password: example_dbpassword

group_vars/development/wordpress_sites.yml
changed to:

wordpress_sites:
  myproject.co.uk:
    site_hosts:
      - canonical: www.myproject.test
        redirects:
          - myproject.test
      - canonical: www.annual-report.myproject.test
        redirects:
          - annual-report.myproject.test
    local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
    admin_email: admin@myproject.test
    multisite:
      enabled: true
      subdomains: true
    ssl:
      enabled: false
      provider: self-signed
    cache:
      enabled: true

roles/php/defaults/main.yml
changed to:

disable_default_pool: true
memcached_sessions: false

php_extensions_default:
  php7.3-cli: "{{ apt_package_state }}"
  php7.3-common: "{{ apt_package_state }}"
  php7.3-curl: "{{ apt_package_state }}"
  php7.3-dev: "{{ apt_package_state }}"
  php7.3-fpm: "{{ apt_package_state }}"
  php7.3-gd: "{{ apt_package_state }}"
  php7.3-mbstring: "{{ apt_package_state }}"
  php7.3-mysql: "{{ apt_package_state }}"
  php7.3-opcache: "{{ apt_package_state }}"
  php7.3-xml: "{{ apt_package_state }}"
  php7.3-xmlrpc: "{{ apt_package_state }}"
  php7.3-zip: "{{ apt_package_state }}"

php_extensions_custom: {}
php_extensions: "{{ php_extensions_default | combine(php_extensions_custom) }}"

php_error_reporting: 'E_ALL & ~E_DEPRECATED & ~E_STRICT'
php_display_errors: 'Off'
php_display_startup_errors: 'Off'
php_max_execution_time: 300
php_max_input_time: 300
php_max_input_vars: 1000
php_memory_limit: 96M
php_mysqlnd_collect_memory_statistics: 'Off'
php_post_max_size: 100M
php_sendmail_path: /usr/sbin/ssmtp -t
php_session_save_path: /tmp
php_session_cookie_httponly: 'On'
php_session_cookie_secure: 'Off'
php_upload_max_filesize: 100M
php_track_errors: 'Off'
php_timezone: '{{ ntp_timezone }}'
php_output_buffering: 'Off'

php_opcache_enable: 1
php_opcache_enable_cli: 1
php_opcache_fast_shutdown: 1
php_opcache_interned_strings_buffer: 8
php_opcache_max_accelerated_files: 4000
php_opcache_memory_consumption: 128
php_opcache_revalidate_freq: 60

thanks for this. i can confirm there are only yml files in the group_vars folder and i think that i have the correct syntax for variable assignment in those yml file (key: value). please see comment below. thanks

after going through this again i managed to fix the problem. it was an extra space before a key/value pair in the wordpress_sites.yml file. thanks very much for pointing me in the right direction

This topic was automatically closed after 42 days. New replies are no longer allowed.