Skip to content

Instantly share code, notes, and snippets.

@kamranayub
Last active August 1, 2017 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamranayub/03eacf147591cc100300b996b92f3574 to your computer and use it in GitHub Desktop.
Save kamranayub/03eacf147591cc100300b996b92f3574 to your computer and use it in GitHub Desktop.
Makefile for using ansible-playbook to do syntax checking for YAML playbooks
# Collect top-level YAML files under plays/ folder
# e.g. plays/upgrade_ansible_tower/upgrade_ansible_tower.yml
# These should only be Ansible playbook files
# i.e. store includes in child includes/ dir
playbooks := $(wildcard plays/*/*.yml)
# Check YAML syntax using ansible-playbook
syntax: $(playbooks)
@GREEN='\033[0;32m'; \
NC='\033[0m'; \
echo "$${GREEN}Checking syntax with ansible-playbook$${NC}"
@# Execute ansible-playbook against each file
@$(foreach playbook, $^, ansible-playbook $(playbook) --syntax-check; )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment