Skip to content

Instantly share code, notes, and snippets.

@phips
Created April 16, 2014 21:01
Show Gist options
  • Save phips/10932697 to your computer and use it in GitHub Desktop.
Save phips/10932697 to your computer and use it in GitHub Desktop.
ansible control Makefile
.PHONY: run test
# default inventory file
INV ?= dev
# default play
PLAY ?= site
# If a variable file is encrypted with Vault, create a file with the password
# in and run the make with SWITCHES including '--vault-password-file FILE'.
# Naturally DO NOT put that file in Git!
plays := $(wildcard *.yml)
help:
@echo "make OPTION"
@echo ""
@echo "where OPTION is one of:"
@echo ""
@echo "test: Syntax check"
@echo "plays: List available plays"
@echo "run: Run a play (defaults to \"$(PLAY)\" for inventory \"$(INV)\")"
test:
@ansible-playbook -i inventory/$(INV) $(PLAY).yml --list-hosts --list-tasks --syntax-check $(SWITCHES)
plays:
@echo $(sort $(plays:.yml=))
run:
@ansible-playbook -i inventory/$(INV) $(PLAY).yml $(SWITCHES)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment