hashbangcode / vlad

Vlad - Vagrant LAMP Ansible Drupal
173 stars 53 forks source link

Improve on playbooks/site*.yml files following conditional added to Vagrantfile #35

Closed philipnorton42 closed 10 years ago

philipnorton42 commented 10 years ago

Catchy title right there.

So pull request #28 saw the addition of vlad/playbooks/site-custom.yml right beside site.yml. This is so that Vagrantfile can opt to run an alternative playbook if a required custom role file is missing (tasks/main.yml) - regardless of whether the user has opted to run the custom role.

The bugger is, site-custom.yml is only slightly different from site.yml and now we have to maintain a whole bunch of code in both files. This seems weighty and is in no way DRY.

Let's use this issue to discuss how we can improve on things.


philipnorton42 commented 10 years ago

Yey for v0.8!


Original Comment By: Dan Bohea

philipnorton42 commented 10 years ago

Tested as working by all parties :) This change has been rolled into version 0.8.


Original Comment By: Philip Norton

philipnorton42 commented 10 years ago

I've also tested with the custom playbook that you sent me the other day. As long as the main.yml file exists then it behaves nicely :)


Original Comment By: Philip Norton

philipnorton42 commented 10 years ago

Just tested this on an existing project with a custom playbook and a brand new test project with no custom playbook and seemed fine.


Original Comment By: Dan Bohea

philipnorton42 commented 10 years ago

Just pushed come fixes for this into dev.


Original Comment By: Philip Norton

philipnorton42 commented 10 years ago

We used to run the local tasks like this before we moved over to the triggers so I think it should work. I roll something together and push it up into dev.

Also, the verbose thing is mostly for developing vlad and seeing what was going wrong (if anything). Popping it into a variable makes sense as this is the last user editable thingy within that file.


Original Comment By: Philip Norton

philipnorton42 commented 10 years ago

So in settings.yml:

# v | vv | vvv | vvvv
ansible_verbosity: "v"

That's assuming we're only using "v" at present. What are we using at present?


Original Comment By: Dan Bohea

philipnorton42 commented 10 years ago

Looks good. Have you tried it? If it works then great - I'm up for it.

While we're at it, we might as well make the value of ansible.verbose a variable via settings.yml - this would save having to uncomment one or any lines in the Vagrantfile to get this kind of output. It would also allow us to use any other level of verbosity that Ansible/Vagrant provides.

+10 points to me for the use of the word 'verbosity' in an issue :)


Original Comment By: Dan Bohea

philipnorton42 commented 10 years ago

What about doing this in the Vagrantfile?:

#!yml
  # Provision vagrant box with Ansible.
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "vlad/playbooks/site.yml"
    ansible.host_key_checking = false
    ansible.extra_vars = {user:"vagrant"}
    # Optionally allow verbose output from ansible.
    # ansible.verbose = 'vvvv'
  end

  # Run the custom Ansible playbook (if it exists)
  if File.exist?("vlad/playbooks-custom/custom/tasks/main.yml")
    config.vm.provision "ansible" do |ansible|
      ansible.playbook = "vlad/playbooks/site-custom.yml"
      ansible.host_key_checking = false
      ansible.extra_vars = {user:"vagrant"}
      # Optionally allow verbose output from ansible.
      # ansible.verbose = 'vvvv'
    end
  end

That would mean we can reduce down the site-custom.yml file to just the basic tasks without having to repeat everything. Possibly...


Original Comment By: Philip Norton