roots / trellis

WordPress LEMP stack with PHP 8.2, Composer, WP-CLI and more
https://roots.io/trellis/
MIT License
2.5k stars 607 forks source link

Issues with vagrant up #7

Closed rkoberg closed 10 years ago

rkoberg commented 10 years ago

First, had to uninstall my brew installed vagrant. Both the brew install and gem install version 1.5.0. I downloaded the dmg from the vagrant site and installed the latest version 1.6.1.

Then I needed to a directory for my local site at the same level as the bedrock-ansible folder. (probably should be in the docs)

Next I got an error:

ImportError: No module named markupsafe

Fixed that with:

$ sudo pip install markupsafe

That installed with errors, so I did with help from the google:

$ export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
$ sudo pip install markupsafe
Requirement already satisfied (use --upgrade to upgrade): markupsafe in /Library/Python/2.7/site-packages
Cleaning up...

So assuming everything is good, I did a vagrant destroy and a vagrant up. This told me:

TASK: [wordpress-sites | Install Dependencies with Composer] ****************** 
failed: [default] => (item={'site_install': True, 'admin_user': 'admin', 'site_name': 'bedrock.dev', 'system_cron': True, 'user': 'vagrant', 'run_composer': True, 'multisite': {'enabled': False}, 'group': 'www-data', 'site_title': 'bedrock', 'admin_password': 'admin', 'env': {'wp_env': 'development', 'db_user': 'bedrock_dbuser', 'db_password': 'bedrock_dbpassword', 'wp_siteurl': 'http://bedrock.dev/wp', 'db_name': 'bedrock_dev', 'wp_home': 'http://bedrock.dev'}, 'site_hosts': ['192.168.50.5', 'bedrock.dev'], 'admin_email': 'admin@example.dev'}) => {"changed": true, "cmd": ["composer", "install"], "delta": "0:00:00.043257", "end": "2014-05-11 17:27:19.163028", "item": {"admin_email": "admin@example.dev", "admin_password": "admin", "admin_user": "admin", "env": {"db_name": "bedrock_dev", "db_password": "bedrock_dbpassword", "db_user": "bedrock_dbuser", "wp_env": "development", "wp_home": "http://bedrock.dev", "wp_siteurl": "http://bedrock.dev/wp"}, "group": "www-data", "multisite": {"enabled": false}, "run_composer": true, "site_hosts": ["192.168.50.5", "bedrock.dev"], "site_install": true, "site_name": "bedrock.dev", "site_title": "bedrock", "system_cron": true, "user": "vagrant"}, "rc": 1, "start": "2014-05-11 17:27:19.119771"}
stdout: Composer could not find a composer.json file in /srv/www/bedrock.dev/current
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section

FATAL: all hosts have already failed -- aborting

I added a roots/bedrock current/composer.json to my bedrock.dev directory, did a vagrant provision, which also failed with the same error as above. This was wrong, I should have added the composer.json to the bedrock.dev folder (not add a current/composer.json to bedrock.dev folder). That got me through the above error.

This resulted in the following error where I am stuck:

TASK: [wordpress-sites | WP installed?] *************************************** 
failed: [default] => (item={'site_install': True, 'admin_user': 'admin', 'site_name': 'bedrock.dev', 'system_cron': True, 'user': 'vagrant', 'run_composer': True, 'multisite': {'enabled': False}, 'group': 'www-data', 'site_title': 'bedrock', 'admin_password': 'admin', 'env': {'wp_env': 'development', 'db_user': 'bedrock_dbuser', 'db_password': 'bedrock_dbpassword', 'wp_siteurl': 'http://bedrock.dev/wp', 'db_name': 'bedrock_dev', 'wp_home': 'http://bedrock.dev'}, 'site_hosts': ['192.168.50.5', 'bedrock.dev'], 'admin_email': 'admin@example.dev'}) => {"changed": true, "cmd": ["wp", "core", "is-installed", "--allow-root"], "delta": "0:00:00.045793", "end": "2014-05-11 17:54:59.135343", "item": {"admin_email": "admin@example.dev", "admin_password": "admin", "admin_user": "admin", "env": {"db_name": "bedrock_dev", "db_password": "bedrock_dbpassword", "db_user": "bedrock_dbuser", "wp_env": "development", "wp_home": "http://bedrock.dev", "wp_siteurl": "http://bedrock.dev/wp"}, "group": "www-data", "multisite": {"enabled": false}, "run_composer": true, "site_hosts": ["192.168.50.5", "bedrock.dev"], "site_install": true, "site_name": "bedrock.dev", "site_title": "bedrock", "system_cron": true, "user": "vagrant"}, "rc": 1, "start": "2014-05-11 17:54:59.089550"}
stderr: Error: This does not seem to be a WordPress install.
Pass --path=`path/to/wordpress` or run `wp core download`.
...ignoring

TASK: [wordpress-sites | Install WP] ****************************************** 
failed: [default] => (item={'item': {'site_install': True, 'admin_user': 'admin', 'site_name': 'bedrock.dev', 'system_cron': True, 'user': 'vagrant', 'run_composer': True, 'multisite': {'enabled': False}, 'group': 'www-data', 'site_title': 'bedrock', 'admin_password': 'admin', 'env': {'wp_env': 'development', 'db_user': 'bedrock_dbuser', 'db_password': 'bedrock_dbpassword', 'wp_siteurl': 'http://bedrock.dev/wp', 'db_name': 'bedrock_dev', 'wp_home': 'http://bedrock.dev'}, 'site_hosts': ['192.168.50.5', 'bedrock.dev'], 'admin_email': 'admin@example.dev'}, u'delta': u'0:00:00.045793', u'cmd': [u'wp', u'core', u'is-installed', u'--allow-root'], u'end': u'2014-05-11 17:54:59.135343', u'stderr': u'Error: This does not seem to be a WordPress install.\nPass --path=`path/to/wordpress` or run `wp core download`.', u'stdout': u'', 'invocation': {'module_name': 'command', 'module_args': u'wp core is-installed --allow-root chdir=/srv/www/bedrock.dev/current/'}, u'changed': True, u'rc': 1, u'start': u'2014-05-11 17:54:59.089550'}) => {"changed": true, "cmd": ["wp", "core", "install", "--allow-root", "--url=http://bedrock.dev", "--title=bedrock", "--admin_user=admin", "--admin_password=admin", "--admin_email=admin@example.dev"], "delta": "0:00:00.034885", "end": "2014-05-11 17:54:59.274118", "item": {"changed": true, "cmd": ["wp", "core", "is-installed", "--allow-root"], "delta": "0:00:00.045793", "end": "2014-05-11 17:54:59.135343", "invocation": {"module_args": "wp core is-installed --allow-root chdir=/srv/www/bedrock.dev/current/", "module_name": "command"}, "item": {"admin_email": "admin@example.dev", "admin_password": "admin", "admin_user": "admin", "env": {"db_name": "bedrock_dev", "db_password": "bedrock_dbpassword", "db_user": "bedrock_dbuser", "wp_env": "development", "wp_home": "http://bedrock.dev", "wp_siteurl": "http://bedrock.dev/wp"}, "group": "www-data", "multisite": {"enabled": false}, "run_composer": true, "site_hosts": ["192.168.50.5", "bedrock.dev"], "site_install": true, "site_name": "bedrock.dev", "site_title": "bedrock", "system_cron": true, "user": "vagrant"}, "rc": 1, "start": "2014-05-11 17:54:59.089550", "stderr": "Error: This does not seem to be a WordPress install.\nPass --path=`path/to/wordpress` or run `wp core download`.", "stdout": ""}, "rc": 1, "start": "2014-05-11 17:54:59.239233"}
stderr: Error: This does not seem to be a WordPress install.
Pass --path=`path/to/wordpress` or run `wp core download`.

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/Users/rkoberg/site.retry

default                    : ok=44   changed=19   unreachable=0    failed=1   

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

Any ideas how to fix? I am attaching a screen grab of my dir structure screen shot 2014-05-11 at 10 58 20 am

I copied the exisiting bedrock-ansible/hosts.example to bedrock-ansible/hosts and did not change anything. Nothing was changed in the site.yml

My bedrock-ansible/group_vars/all looks like:


---
www_root: /srv/www

# Define your WordPress sites here
wordpress_sites:
  - site_name: bedrock.dev
    site_hosts:
      - 192.168.50.5
      - bedrock.dev
    user: vagrant
    group: www-data
    site_install: true
    site_title: bedrock
    admin_user: admin
    admin_password: admin
    admin_email: admin@example.dev
    system_cron: true
    run_composer: true
    multisite:
      enabled: false
    env:
      wp_home: http://bedrock.dev
      wp_siteurl: http://bedrock.dev/wp
      wp_env: development
      db_name: bedrock_dev
      db_user: bedrock_dbuser
      db_password: bedrock_dbpassword

My Vagrant file looks like:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.require_version '>= 1.5.1'

Vagrant.configure('2') do |config|
  config.vm.box = 'roots/bedrock'

  config.vm.network :private_network, ip: '192.168.50.5'
  config.vm.hostname = 'bedrock.dev'

  # adjust paths relative to Vagrantfile
  config.vm.synced_folder '../bedrock.dev', '/srv/www/bedrock.dev/current', owner: 'vagrant', group: 'www-data', mount_options: ['dmode=776', 'fmode=775']

  config.vm.provision :ansible do |ansible|
    # adjust paths relative to Vagrantfile
    ansible.playbook = './site.yml'
    ansible.groups = {
      'wordpress-server' => ['default']
    }
    ansible.extra_vars = {
      ansible_ssh_user: 'vagrant',
      user: 'vagrant'
    }
    ansible.sudo = true
  end

  if Vagrant.has_plugin?('vagrant-cachier')
    config.cache.scope = :box

    config.cache.synced_folder_opts = {
      type: :nfs,
      mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
    }
  end
end
rkoberg commented 10 years ago

One last thing. I did modify the composer.json from the original roots/bedrock version. Here is my modified version:

{
  "name": "roots/bedrock",
  "type": "project",
  "license": "MIT",
  "description": "A modern WordPress stack",
  "homepage": "http://roots.io/wordpress-stack/",
  "authors": [
    {
      "name": "Scott Walkinshaw",
      "email": "scott.walkinshaw@gmail.com",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "Ben Word",
      "email": "ben@benword.com",
      "homepage": "https://github.com/retlehs"
    }
  ],
  "keywords": [
    "wordpress", "stack", "capistrano", "composer", "vagrant", "wp"
  ],
  "support": {
    "issues": "https://github.com/roots/bedrock/issues",
    "forum": "http://discourse.roots.io/category/bedrock"
  },
  "config": {
    "preferred-install": "dist",
    "generate-salts": true
  },
  "autoload": {
    "psr-0": {"Bedrock\\Installer": "scripts"}
  },
  "scripts": {
    "post-root-package-install": ["Bedrock\\Installer::addSalts"]
  },
  "repositories": [
    {
      "type": "composer",
      "url": "http://wpackagist.org"
    },
    {
      "type": "composer",
      "url" : "http://rarst.net"
    },
    {
      "type": "package",
      "package": {
        "name": "wordpress/wordpress",
        "version": "3.9",
        "type": "webroot",
        "dist": {
          "type": "zip",
          "url": "https://wordpress.org/wordpress-3.9.zip"
        },
        "require" : {
          "fancyguy/webroot-installer": "1.1.0"
        }
      }
    },
    {
      "type": "package",
      "package": {
        "name": "roots/roots-sass",
        "type": "wordpress-theme",
        "version": "6.5.0",
        "dist": {
          "type": "zip",
          "url": "https://github.com/roots/roots-sass/archive/master.zip"
        }
      }
    }
  ],
  "require": {
    "php": ">=5.3.2",
    "wordpress/wordpress": "3.9",
    "fancyguy/webroot-installer": "1.1.0",
    "composer/installers": "v1.0.12",
    "vlucas/phpdotenv": "~1.0.6",
    "roots/roots-sass": "6.5.*",
    "wpackagist/advanced-custom-fields": "4.3.*"
  },
  "require-dev": {
    "rarst/laps": "~1.0",
    "wpackagist/a-fresher-cache": "*",
    "wpackagist/core-control": "*",
    "wpackagist/monster-widget": "*",
    "wpackagist/regenerate-thumbnails": "*",
    "wpackagist/debug-bar": "0.8.*",
    "wpackagist/dynamic-hostname": "0.4.*",
    "wpackagist/plugin-check": "*",
    "wpackagist/theme-check": "*"
  },
  "extra": {
    "installer-paths": {
      "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    },
    "webroot-dir": "web/wp",
    "webroot-package": "wordpress/wordpress"
  }
}
swalkinshaw commented 10 years ago

Thanks for the compressive troubleshooting! The docs definitely need some work as a lot of people get confused at a few points.

Looks like the issue is that your bedrock.dev folder is missing wp-cli.yml. This configs tells WP-CLI where the WP install is (web/wp) and without it, it can't find/detect WordPress.

https://github.com/roots/bedrock/blob/master/wp-cli.yml

rkoberg commented 10 years ago

That still was not enough. The only thing that worked for me was to copy over the https://github.com/roots/bedrock project to be at the same level as bedrock-ansible. It was not clear from the docs that this should be done, or perhaps it is common knowledge?

I renamed bedrock to bedrock.dev. And inside of bedrock-ansible, I renamed all occurences of example.dev to bedrock.dev. Then the install completed without error (the TASK: [wordpress-sites | WP installed?] was ignored and TASK: [wordpress-sites | Install WP] completed successfully).

For this to work, you need the roots/bedrock copied over as the stub site (or something very similar).

There is a minor error (having to do with the VM?) when logging in as admin:

Warning: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.) in /srv/www/bedrock.dev/current/web/wp/wp-includes/update.php on line 435

I should also say I am new to WP, vagrant, ansible, capistrano. What is setup does seem very similar to a rails project using EngineYard.

swalkinshaw commented 10 years ago

I don't think anything with bedrock-ansible is common knowledge right now unfortunately (mostly because of the lack of docs).

This playbook depends on Bedrock-based sites, so yeah you need a (mostly) complete site based on Bedrock somewhere on your local filesystem. Where that is depends on your Vagrantfile and where it is as well.