Matthew Sullivan

Posts Projects About

Helpful Ansible Bash Shortcuts

August 14, 2017

I have a series of bash aliases for Ansible that make my life better, so I thought I’d share them. If you choose to use any of these just make sure to add them to your ~/.bash_profile, assuming you’re on a Mac. Then after editing this file make sure to run source ~/.bash_profile so that you can use them immediately.

Note: In order for these shortcuts to work, you’ll need to make sure to install hf and make sure that its binary is in your $PATH.

Ansible Playbook Alias

This command is super simple, but the one I use the most. It just takes your arguments and options then passes them to the ansible-playbook command. This honestly saves me hundreds of keystrokes per day.

# ansible playbook alias
function ap () {
  ansible-playbook "$@"
}

Interactive Ansible Vault

These commands will run hf in the current directory and allow you to fuzzy search for a file and once the file is selected it will decrypt, encrypt, or show it accordingly.

# interactive ansible vault decrypt
function iavd () {
  hf -cmd="ansible-vault decrypt"
}

# interactive ansible vault encrypt
function iave () {
  hf -cmd="ansible-vault encrypt"
}

# interactive ansible vault view
function iavv () {
  hf -cmd="ansible-vault view"
}

My name is Matthew Sullivan. Currently, I'm a Senior Software Engineer at Target in Minneapolis, MN. Previously I was a Senior Software Engineer at Star Tribune, Lead Web Engineer at Botlink, and the CEO & co-founder of Jumpr.