Setting up Vagrant Box Error 'dict object' has no attribute 'site_hosts'", 'failed': True}]}

Been trying to set up a new Vagrant box. First I had a MariaDB issue which I overcame, but now I am suck installing wordpress it seems

TASK: [wordpress-setup | Create WordPress configuration for Nginx] ************ 
    fatal: [default] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'site_hosts'", 'failed': True}
    fatal: [default] => {'msg': 'One or more items failed.', 'failed': True, 'changed': False, 'results': [{'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'site_hosts'", 'failed': True}]}
    
    FATAL: all hosts have already failed -- aborting
    
    PLAY RECAP ******************************************************************** 
               to retry, use: --limit @/Users/jasper/dev.retry
    
    default                    : ok=64   changed=1    unreachable=1    failed=0   
    
    Ansible failed to complete successfully. Any error output should be
    visible above. Please fix these errors and try again.

Any ideas?

Looks like a problem with your group_vars/development file. Did you define any site_hosts?

1 Like

I have

mysql_root_password: devpw

web_user: vagrant

wordpress_sites:
  rukn.dev:
    rukn.dev:
      - rukn.dev
    local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
    repo: git@github.com:roots/bedrock.git
    site_install: true
    site_title: rukn Site
    admin_user: admin
    admin_password: admin
    admin_email: admin@rukn.dev
    multisite:
      enabled: false
      subdomains: false
    ssl:
      enabled: false
    cache:
      enabled: false
      duration: 30s
    system_cron: true
    env:
      wp_home: http://rukn.dev
      wp_siteurl: http://rukn.dev/wp
      wp_env: development
      db_name: rukn_dev
      db_user: rukn_dbuser
      db_password: rukn_dbpassword

php_error_reporting: 'E_ALL'
php_display_errors: 'On'
php_display_startup_errors: 'On'
php_track_errors: 'On'
php_mysqlnd_collect_memory_statistics: 'On'
php_opcache_enable: 0

xdebug_install: false
php_xdebug_remote_enable: true
php_xdebug_remote_connect_back: true
php_xdebug_remote_host: localhost
php_xdebug_remote_port: 9000
php_xdebug_remote_log: /tmp/xdebug.log
php_xdebug_idekey: XDEBUG
php_max_nesting_level: 200

Ah. You are right. I see the issue. Will rerun all again after fix. :blush:

I’m having he same issue → One or more undefined variables: ‘dict object’ has no attribute ‘my-site’ - The first time I ran vagran up I only could see the welcome nginx page, I tried to provision and now I get this:

I’m doing this on a windows host using GIT bash:

Here is my wordpress_sites.yml

# Documentation: https://roots.io/trellis/docs/local-development-setup/
wordpress_sites:
  inspirationlmn.com:
    site_hosts:
      - inspirationlmn.vvv
    local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
    site_install: true
    site_title: Inspiration Dev
    admin_user: admin
    # admin_password: (defined in group_vars/development/vault.yml)
    admin_email: admin@example.dev
    permalink_structure: "/%postname%/"
    multisite:
      enabled: false
      subdomains: false
    ssl:
      enabled: false
    cache:
      enabled: false
      duration: 30s
    env:
      disable_wp_cron: true
      wp_home: http://inspirationlmn.vvv
      wp_siteurl: http://inspirationlmn.vvv/wp
      wp_env: development
      db_name: root
      db_user: root
      # db_password: (defined in group_vars/development/vault.yml)

@Rafael Have you changed example.com to inspirationlmn.com in group_vars/development/vault.yml?

6 Likes

Hey @fullyint, that was missing! It works now!

Cheers

Having same issue right now (latest trellis). Here is content of my settings files:
wordpress_sites.yml

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

vault.yml

    # Documentation: https://roots.io/trellis/docs/vault/
    vault_mysql_root_password: devpw

    # Documentation: https://roots.io/trellis/docs/security/
    vault_sudoer_passwords:
      admin: $6$rounds=100000$JUkj1d3hCa6uFp6R$3rZ8jImyCpTP40e4I5APx7SbBvDCM8fB6GP/IGOrsk/GEUTUhl1i/Q2JNOpj9ashLpkgaCxqMqbFKdZdmAh26/

    # Variables to accompany `group_vars/development/wordpress_sites.yml`
    # Note: the site name (`example.com`) must match up with the site name in the above file.
    vault_wordpress_sites:
      growthminds.com:
        admin_password: admin
        env:
          db_password: example_dbpassword

The exact error you’re seeing would help here. Also you may have run into a bug which I just fixed in https://github.com/roots/trellis/commit/fc44e94d6f174792b00833d79a89dd92d4b1daf8