Prevent Ansible running an out of date version of a playbook


You've got a collection of Ansible Playbooks in a git repo shared between a team and want make sure that someone doesn't accidentally run an out of date version of a playbook.


Create a role "ensure-safe-to-run" or some such, and add it as the first role in any playbooks list.

- name: ensure local infrastructure repo is up to date
  local_action: shell git remote show origin
  register: command_result
  failed_when: "'local out of date' in command_result.stdout"
  sudo: no

This runs a local shell action, captures the result, and checks it for the text "local out of date". If it sees that in the output, it will fail and the rest of the playbook won't run. Leaving you to do a git pull manually.

It won't check on your own changes, so you can add new playbooks and modify existing ones freely 

Easily Issue "vagrant ssh -c" Commands With a "vudo" Alias


When you want to issue a command inside a running Vagrant instance instead of logging into a full blow session you can issue a single command with "vagrant ssh -c <some command>", however it's a bit of a mouthful and requires you to quote the command and you'll be in the wrong directory when the command runs.


Adding a "vudo" function to your terminal shell that aliases "vagrant ssh -c" and switches into the correct directory when it does so.

I'm using Oh My ZSH, so for me I update the ~/.zshrc with a function:

function vudo() { eval "vagrant ssh -c \"cd /vagrant && $@\"" }

Now, when I want to run something inside the vm, such as run a test suite I just type "vudo phpunit" and it fires off from the /vagrant directory. This also works for long running processes so if I want to connect to MongoDB running on Vagrant I can just type "vudo mongo" and I'm in.