Wordpress Installation on staging and production

Hi guys,

First of all, what a fantastic set of products you have produced. Thank you so much for your efforts!

Now, I am attempting to perform the wordpress installation automatically on my staging site but its just not happening. Is this even possible or do i need to tweak the deploy playbook somehow? Everything else is being deployed perfectly. Here’s what my staging group_vars looks like:

wordpress_sites:
  example.com:
    site_hosts:
      - staging.example.com
    local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
    repo: git@bitbucket.org:un_titled/wordpress-experimental-boilerplate.git
    branch: master
    subtree: site # Use this if following the roots-example-project structure
    site_install: true
    site_title: Example Site
    admin_user: admin
    admin_password: admin
    admin_email: admin@example.dev
    .
    .
    .
    .

Am I doing something wrong?

Cheers

Hi @alanablett,

Can you please tell us what error(s) you are getting? Otherwise it is very difficult to help you.

No you should not need to ‘tweak’ the playbook, to get up and running you can use the Roots example:

https://github.com/roots/roots-example-project.com/blob/master/ansible/group_vars/staging/

The above is for staging, however you can also look at the development and production examples here:

https://github.com/roots/roots-example-project.com/blob/master/ansible/group_vars/

You should be able to simply replace occurrences of “roots-example-project” with your URL, that is all that should be required.

More here:

In general if stuck the example project is a great resource.

Yes it is possible to get working, I think the best thing to do is carefully follow the roots documentation and refer to the example project if stuck.

Craig

Hi Craig, thanks for your reply.

Sorry if I didnt explain correctly. I am not receiving any errors, everything is working fine. The issue I am having is that on initial deployment to my staging server I would like it if wordpress were installed automatically as part of the deploy. I thought defining site_install: true in my group_vars would do that. However, its seems the wordpress-install role isn’t even being fired off.

Hope that makes more sense now?

1 Like

In previous post I mentioned adding wordpress-install to the end of server.yml. This will not work very well for remote environments.

@fullyint pointed out to me:

I think this will attempt a composer install but the staging/production server won’t yet have a composer.json or bedrock project ready to receive install, so it will fail. The dev vagrant vm has a composer.json because of the vagrant synced folders.

Also, if there is a wp install in web root, deploy.yml will fail. I guess one of it’s checks is that current is a symlink.

TASK: [deploy | Initialize] *************************************************** 
failed: [104.131.190.246] => {"failed": true}
msg: /srv/www/example.com/current exists but is not a symbolic link

So, my first attempt at automating an install would probably not be to use the wordpress-install role. Instead, I’d add these vars to group_vars/staging and a command like this:

 project_post_finalize_commands:
+  - if ! wp core is-installed; then wp core install --url="{{ project.env.wp_home }}" --title="{{project.site_title }}" --admin_user="{{ project.admin_user }}" --admin_password="{{ project.admin_password }}" --admin_email="{{ project.admin_email }}"; fi
   - sudo service php5-fpm reload

So disregard what I said and listen to his advice :wink:

1 Like

Hi @austin

Having had time to look at it, that was the route I was going down too.

Thanks so much for your reply, fantastic pieces of information!

Alan