A Modern WordPress Example

@merchantguru I’ve made a few changes based on your feedback:

  1. Updated bedrock-ansible’s README to have consistent folder naming + linked to the example project
  2. Started to work on a README for the example project: https://github.com/roots/roots-example-project.com/blob/readme-instructions/README.md

Please let me know about any feedback you have on that.

I’m also going to be referencing the example project in Bedrock’s README as well.

1 Like

the roots-example-project repo is what the end goal should look like if you choose to use bedrock and deploy with ansible. If you clone the example you get the entire setup without going through all the steps that the readme now provides. If you follow the steps you learn the process top to bottom, if you use the roots-example-project you pretty much bypass them but end up at the same result…just less understanding of how you got there :wink:

If you do use the roots-example-project the following worked for me

  1. clone it into whatever project folder you are working from
  2. BEFORE you run vagrant up ensure that all the required ansible packages are there as per the instructions here: https://github.com/roots/bedrock-ansible#installation
  3. BEFORE you run vagrant up make sure you edit ansible\group_vars\development and have you dev url in there. Edit between site_hosts and php_error_reporting
  4. Run vagrant up from your project root where the vagrantfile sits
  5. Start working.
  6. Have some tea, post a thank you to @swalkinshaw and the rest of the team for being so amazing!

That worked for me :slight_smile:
Ran through it twice already with other projects, not just using the example domain.

3 Likes

Step 3 of Instructions is missing the ANSIBLE_PATH change.

ANSIBLE_PATH = 'ansible'
1 Like

true, I think the roots-example-project has already adjusted the path so I skipped that step. That also illustrates what happens when you use roots-example-project without going through the documentation from start to finish, you end up not knowing what settings are actually needed to be adjusted.

I haven’t gotten to deploying with Ansible yet so my steps reflect getting the site up and running if you clone the roots-example-project.

This is excellent, when you’re self-teaching, examples are invaluable.

One thing I’d like to see added to the readme is the DO droplet you recommend using. I was stuck for a while during setup of my production server when Mariadb kept being unable to set the db’s root password. Finally, I spun up a premade LEMP droplet and everything worked just fine. (now I’m stuck at deployment, but I’ll get there eventually.)

Thanks so much.

Thanks for incorporating the feedback on those projects. Helps a lot!

@evanfuture, I got stuck at the same (TASK: [mariadb | Set root user password] Operation CREATE USER failed for 'root') and was just about to troubleshoot it when I saw your comment. I might spin up a LEMP server now to see if that gets me by… although Ansible should normally handle this.

@evanfuture I solved this by deleting the root user with the password problem. The error was that the root user was already created, so it failed at this step. I SSH’ed into my droplet, then:

SELECT user, host, password FROM mysql.user;
DROP USER 'root'@'mydropletname';

Re-ran the ansible playbook and it continued past this step.

Both of our solutions seem outside what should be happening with Ansible. Is there a way to add your task to the roles perhaps?

They acknowledged it’s probably a bug. It happens (at least in our cases) when the playbook is re-run. I posted a GitHub issue here. Running drop user is a workaround in the meantime.

My first time working with roots tools and I got your Modern Wordpress Example example working locally as is, but haven’t had success yet when going through the whole process from start to finish as outlined in the readme. Various errors pop up - usually when installing some of the requirements.

One in particular: I’m having a bit of a problem in the scenario of starting a different project folder besides the first folder I started in. The error occurs when running ‘vagrant up’ at the point where it tries exporting NFS shared folders. The error says they are non-existant because it is looking for them in the path of the previous projects folder.

Do I need to manually change a line in Vagrantfile? Do I need to uninstall/reinstall vagrant-bindfs?

Thanks!

Not exactly sure what you’re doing but vagrant reload should redo the synced folders. Or you can always destroy and re-up.

Working now - reload/destroy didn’t work but reinstalling bindfs did and that makes me think I originally installed it in the wrong place.

That and fixing a couple of other things I did wrong and I’ve got my local dev all up and running! I’m definitely the “If I can do it anybody can” guy.

1 Like

HI, I am not using Digital Ocean, Is deploying a project to Siteground (for example) is as easy as using Digital Ocean as host?

Thanks.

Hi there!

I’m trying to set up local instance of roots-example-project. My environment is macOS, homebrew, virtualbox.

When doing vagrant up for the first time there were some errors related to logrotate component, however VM starts OK, vagrant ssh works just fine.

When I check /etc/nginx/nginx.conf, I see that does include sites-enables/* (which is expected), however in sites-enabled I’m seeing only no-default.conf - which is configured to immediately return 444, and no traces of references to WP installation (which is as I understand is under /srv/www/…)

Am I missing something?

Thanks for great work, I’m looking for development environment for WP, and Roots stack looks excellent (or rather amazing I would say), it’s just learning curve seems quite steep for me.

Thanks in advance,
Vladimir

If you got an error it might mean not everything ran. Can you try running vagrant provision again? Or destroy it and re-up. Seeing the error messages would help.

swalkinshaw, hi!

I’m getting this error (tried to destroy VM and re-up again, problem reproduced):

TASK [logrotate : nickhammond.logrotate | Install logrotate] *******************
ok: [default]

TASK [logrotate : nickhammond.logrotate | Setup logrotate.d scripts] ***********
System info:
  Ansible 2.2.2.0; Vagrant 1.9.3; Darwin
  Trellis at "WP 4.6 Compat: set WP_HOME/SITEURL directly"
---------------------------------------------------
the field 'args' has an invalid value, which appears to include a variable
that is undefined. The error was:
'ansible.vars.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'name'

The error appears to have been in '/Users/vegorov/roots.io/roots-example-
project.com/trellis/vendor/roles/logrotate/tasks/main.yml': line 5, column 3,
but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: nickhammond.logrotate | Setup logrotate.d scripts
  ^ here

fatal: [default]: FAILED! => {"failed": true}

RUNNING HANDLER [common : restart memcached] ***********************************
changed: [default]

and finally:

PLAY RECAP *********************************************************************
default                    : ok=72   changed=58   unreachable=0    failed=1   

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

VM goes up, I can ssh to it, nginx and mysql are running.

On a diffenet note - I’ve noticed also that php7.0-fpm is not running: systemctl status php7.0-fpm.service tells that it’s failed, in tail /var/log/php7.0-fpm.log I’m seeing "No pool defined"error - but again, it may be because both issues have same root cause.

Tried vagrant provision and got php-fpm related error:

TASK [php : Start php7.0-fpm service] ******************************************
System info:
  Ansible 2.2.2.0; Vagrant 1.9.3; Darwin
  Trellis at "WP 4.6 Compat: set WP_HOME/SITEURL directly"
---------------------------------------------------
Unable to start service php7.0-fpm: Job for php7.0-fpm.service failed because
the control process exited with error code. See "systemctl status
php7.0-fpm.service" and "journalctl -xe" for details.

fatal: [default]: FAILED! => {"changed": false, "failed": true}
        to retry, use: --limit @/Users/vegorov/roots.io/roots-example-project.com/trellis/dev.retry

PLAY RECAP *********************************************************************
default                    : ok=43   changed=2    unreachable=0    failed=1   

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

Thanks

That’s a really strange error. My first suggestion is to try another version of Ansible. Did you install via pip or Homebrew?

Maybe try version 2.2.0.0.

edit: to be clear, the other issues you’re experiencing are expected because the playbook stops after that error so it’s not finished yet.

You could also temporarily remove the logrotate role if you want to just get past this for now:

diff --git a/dev.yml b/dev.yml
index 156e7fe..18282a7 100644
--- a/dev.yml
+++ b/dev.yml
@@ -16,7 +16,7 @@
     - { role: xdebug, tags: [php, xdebug] }
     - { role: memcached, tags: [memcached] }
     - { role: nginx, tags: [nginx] }
-    - { role: logrotate, tags: [logrotate] }
+    #- { role: logrotate, tags: [logrotate] }
     - { role: composer, tags: [composer] }
     - { role: wp-cli, tags: [wp-cli] }
     - { role: wordpress-setup, tags: [wordpress, wordpress-setup] }
diff --git a/requirements.yml b/requirements.yml
index 15c9e89..45c12f9 100644
--- a/requirements.yml
+++ b/requirements.yml
@@ -6,9 +6,9 @@
   src: geerlingguy.ntp
   version: 1.3.0
 
-- name: logrotate
-  src: nickhammond.logrotate
-  version: e7a498d
+#- name: logrotate
+  #src: nickhammond.logrotate
+  #version: e7a498d
 
 - name: swapfile
   src: kamaln7.swapfile

@vegorov When I search discourse for the logrotate error you posted…

Regarding your version of Trellis at "WP 4.6 Compat: set WP_HOME/SITEURL directly", it looks like it is probably from Sept 2016. You may want to update your Trellis, which would likely also prevent the no pool defined error.

I’m finally figured out what was wrong - I’ve git-cloned example project repository instead of cloning trellis and bedrock from corresponding repos. Example repo has trellis and bedrock installations, but not latest, obviously.

Newly created project with up to date trellis and bedrock provisioned successfully and all runs as expected.

A lot of stuff is very new to me - I’m kinda in copy-paste mode with regard to stuff like ansible, npm, yarn, etc etc, but it’s a different story.

I’ve installed (seemingly) sage and built it, so I’ve reached good starting point.

Thanks!

2 Likes