Soup-to-nuts on Developing with Bedrock and Bedrock-Ansible

I’m about a year into programming with wordpress and do understand and use git and the terminal. However, I’ve always used desktop server or MAMP so never had a need to dig into vagrant. But I I like the way bedrock (and ansible) thinks and am trying to come to grips with how to use the whole stack (including bedrock-ansible) from soup to nuts but am really struggling with certain parts. I know official docs need to be more about ‘just the facts’ but I’m wondering if anyone knows of any great tutorial or resource that breaks the whole workflow down bit by bit?

I did come across these but they mention nothing about bedrock-ansible or how it all fits in:
http://efeqdev.com/tutorial/using-bedrock-for-wordpress-for-the-first-time/

For example; It took forever to figure out the right way to install composer and ansible and to get Vagrant up and running properly (had no idea that the ansible folder already had a VM in it - never really said that in the docs.)

Also, now I’m stuck on the group_var development file. No idea what to do here since I’ve never done it this way and I can’t seem to locate good info.

Does anyone have any suggestions?

  1. You don’t have to install Composer locally. It’s done on the VM and run automatically.
  2. What do you mean the ansible folder has a VM in it?
  3. Can you explain the troubles you’r having with configuring the group vars file for wordpress_sites?

There’s documentation on the options here and a full example here

Got it. That wasn’t clear from the current docs. It just said installation and then what to install. I had no idea it was supposed to be on a VM.

What do you mean the ansible folder has a VM in it?
When I downloaded the bedrock-ansible file , I had no idea that I could just cd into it and then just vagrant up. I thought I had to create a new VM and somehow work from there.

I think that my be my problem. Those docs are great for people who get this type of workflow. I love that you’re trying to bring wp devs into 2015 with these concepts. We all can see the features and benefits but I think what would help us even more is something more robust that shows someone, step by step, how this workflow should be set up and run from start to finish.

I’ve had to start keeping my own set of docs just from trial and error and it’s taken me 3 days so far; I know it’s a new learning curve but it could have gone much faster with some sort of guide.

Here’s what I have so far:

Setting up your local environment

  • Make sure ansible is installed on your system (using homebrew =brew install ansible)

  • per the docs run $ ansible-galaxy install -r requirements.yml -p
    vendor/roles

  • setup files like so making sure there’s not white space
    in the path leading here

example.com/ - Primary folder for the project
├── ansible/ - Your version of this repo (renamed to just ansible)
└── site/ - A Bedrock-based site (suggested to name this the generic site since your project name is already at the top level)

  • Install bedrock (or use a current bedrock setup rename to site per
    above) cd into bedrock-ansible and vagrant up cd into the bedrock
    directory

That’s all I have so far.

I mean yes that would be nice: but what is difficult about looking at the requirements and following their respective instructions?

Of course you won’t understand what group_vars does without reading the Ansible docs. Of course you won’t know the commands to run if you don’t know what Vagrant does. One should understand these tools before they try to use them.

Yes, it would be nice - a tutorial… as opposed to just documentation. To me, in this case, they are two very different things. :wink:

1 Like

I feel like I’m in the same boat as m33. I fully understand the benefits of Bedrock and why I should be using it, but I find the docs (https://roots.io/bedrock/docs/) to be a bit sparse for someone at my level. That is to say I have been working with WP for several years, comfortable with git, but just getting started with Composer, Vagrant, Ansible, etc.

Currently the docs read more as a list of features than step-by-step instructions. The actual section labeled “Installation” is clear and straightforward, and I’ve gotten as far as installing WP. But now I’m completely lost as to how to handle deployment.

I for one would pay good money for a Bedrock/Sage screencast covering installation to deployment. In the meantime I’ll dig through the docs Austin linked. Thanks.

1 Like

Kevin, are you using bedrock-ansible too? If so, mind sharing how you got everything up and running?

I worked through installing all of the requirements using the links listed in the readme, but I am stuck at editing the group_vars/development file. I’m not sure what credentials those are supposed to be. I typically use MAMP for local MySQL databases, but I’m not sure if it’s the same process with bedrock-ansible. Can anyone clarify where I am to create the database, whether I do so in MAMP or otherwise?

hilarious. I’m stuck on the same thing. I usually use desktop server. I am confused too because it says it uses MariaDB for it’s db but I’m not sure how to set that up on the VM (or even if I do) since there’s no instructions.

I have a session set up with a guy at codementor.io to help me with it tomorrow am. I’ll write it all down and post it here when I’m done.

1 Like

@kevinwhoffman @m33

I understand that trying to learn new tools, workflows and even “mindsets” can be confusing but I’m trying to understand how some of these breakdowns are happening.

bedrock-ansible says in multiple places that it automatically configures and set ups complete servers. All the software needed to run a WordPress server gets installed. That’s the entire point of the project.

We don’t expect you to install MySQL, or MariaDB, or have to create a database. When it says to provide a db name, user, password etc, you can just enter anything you want. bedrock-ansible takes those variables and creates the db user, database itself, and tells WordPress to use those credentials.

That being said, I did just update the README to be a little more explicit about configuring wordpress_sites. See here: https://github.com/roots/bedrock-ansible#wordpress-sites

I do encourage both of you to read about the Vagrant and Ansible basics. It’s really hard to understand bedrock-ansible without understanding the two main tools it uses. There are a ton of good resources online for both of them.

2 Likes

I’m new to the Bedrock workflow as well, but I’m curious where the pain points are keep you from just jumping in and trying things? Seeing what breaks and what doesn’t.

The main thing to know about Vagrant workflows is that they’re incredibly cheap and disposable. While the normal opposite of vagrant up is vagrant halt, the nuclear opposite is vagrant destroy, which removes all trace of the virtual machine. But you vagrant up again and you’re back in a couple minutes with a fresh install on a clean virtual server, all ready to go.

Today I set up a few test installs and found things to be pretty straightforward. I have been using Vagrant, Ansible and Gulp for a while, but still, this is someone else’s workflow, so my experience only helps in recognizing commands and knowing what some of the stuff does under the hood.

Straight out of the box, Bedrock can configure a Vagrant instance without changing any settings. Here are all the steps:

  1. Install the prerequisites, these are well spelled out in the Bedrock-ansible readme. this only needs to be done once.
  2. Create a site directory, “example.com” or some such.
  3. Inside that directory, clone bedrock-ansible and bedrock, side-by-side. Rename the bedrock directory to “site” or something.
  4. This is the ugliest part: cd bedrock-ansible and run this: ansible-galaxy install -r requirements.yml -p vendor/roles.
  5. Finally, vagrant up (you will probably need to enter your admin password to edit /etc/hosts)

About a minute later when Vagrant’s Ansible provisioner finishes, you can open http://example.dev in your web browser.

Once you’re there, nuke it with vagrant destroy then run vagrant up again. Change a few things in group_vars and do it again, see what changed.

The group_vars documentation probably needs some attention, it’s well written but maybe if the various sections were broken up a bit it would be easier to digest.

3 Likes

Thanks for that! Yes, I’m definitely reading up on them and have a codementor session set up to go over some basics.

As for the group_vars files, I had no idea. I’m giving that a try now. Thanks for clarifying.

@swalkinshaw Honestly I think it is the mindset of previous workflows (e.g. MAMP) that is causing some of the confusion. I’m doing extensive reading on Vagrant and Ansible. I appreciate the updated readme.

@joemaller I’m absolutely jumping in and trying things. These aren’t theoretical pain points, these are actual places where I am currently stuck. I have all of the requirements installed and followed your steps through step 4. I just can’t seem to get “vagrant up” to run successfully.

My understanding is I should be able to run “vagrant up” in terminal at the location of the ansible directory (I have closely matched your example project with ansible and site directories). I did not touch anything in group_vars/development. I’ve left example.dev and everything else untouched. Here’s where “vagrant up” fails. I can paste the entire output if that helps, but these are the last few lines.

TASK: [php | Start php5-fpm service] ******************************************
failed: [default] => {"failed": true}

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/kevin/dev.retry

default                    : ok=29   changed=13   unreachable=0    failed=1

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

Does that tell you anything?

That is super helpful. Thank you!

For me, the breakdown was happening with fact that I didnt’ know the group_var folder configured the server and site info.

In normal wp workflows, you set up the db and then enter that info the set up screen for wp or edit the config file with that. What was mystifying is that fact that the config files in group_vars doesn’t need you to set up the db and enter that info, it does it for you!

That makes sense now.

Sorry if that came across badly.

I’m trying a few things to see if I can get this to fail like yours did. What platform are you on? Also, what version of Vagrant and Ansible do you have installed? (vagrant -v and ansible --version)

Unfortunately you’ve run into a real bug that occurs because of the latest Ansible version: https://github.com/roots/bedrock-ansible/issues/205

I get the exact same error.

Ah ok. I’m on Vagrant 1.7.2 and Ansible 1.9.1.

I used sudo pip install ansible and that gives me 1.9.1. Can I get some help downgrading to 1.9.0? I did some searching myself and can’t find the syntax.

ok, cool, reproducible bug! Here’s how to fix it:

Homebrew

$ brew rm ansible
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew/e707881d4e57839a662d83fdd85e3b3bb6113bd9/Library/Formula/ansible.rb

(the second command is all one line, it’s a link to the 1.9.0.1 formula update)

Pip

$ pip uninstall ansible
$ pip install ansible==1.9.0.1

I was able to reproduce the errors @kevinwhoffman and @m33 were getting and then was able to correctly provision the VM after rolling back Ansible.

Reference for Homebrew rollbacks: http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula

2 Likes

Ok figured out how to roll it back with sudo pip install ansible==1.9.0.1 and WordPress is up and running. Thank you guys so much for the help.

Even though I know this is an Ansible issue and not a Bedrock bug, I’d suggest making note of the version conflict in the bedrock-ansible readme for the time being. Turns out I had done everything correctly with the exception of that one hiccup.

3 Likes