You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.1 KiB
Makefile
54 lines
1.1 KiB
Makefile
vault:=group_vars/all/vault.yml
|
|
playbooks_dir:=playbooks
|
|
playbooks:=$(wildcard ${playbooks_dir}/*.yml)
|
|
credentials_dir:=credentials
|
|
credentials_file:=misc/credentials.tar.gpg
|
|
venv_dir:=venv
|
|
|
|
# Default Target (must be first target)
|
|
|
|
.PHONY: main
|
|
main:
|
|
ansible-playbook site.yml
|
|
|
|
# Virtual Environment's Setup
|
|
|
|
.PHONY: setup
|
|
setup: ansible_collections ${venv_dir}
|
|
|
|
ansible_collections: collection-requirements.yml ${venv_dir}
|
|
mkdir --parent $@
|
|
. ./${venv_dir}/bin/activate && ansible-galaxy install -r $<
|
|
|
|
${venv_dir}: pip-requirements.txt
|
|
python3 -m venv $@
|
|
. ./$@/bin/activate && python3 -m pip install -r $<
|
|
|
|
# Playbook Execution
|
|
|
|
.PHONY: list
|
|
list:
|
|
@echo ${playbooks}
|
|
|
|
.PHONY: ${playbooks}
|
|
${playbooks}:
|
|
ansible-playbook ${playbooks_dir}/$@.yml
|
|
|
|
# Vault Handling
|
|
|
|
.PHONY: vault
|
|
vault:
|
|
ansible-vault edit ${vault}
|
|
|
|
# Credential Handling
|
|
|
|
.PHONY: store-credentials
|
|
store-credentials: ${credentials_file}
|
|
|
|
${credentials_file}: $(shell find "${credentials_dir}")
|
|
tar -cf - "${credentials_dir}" | gpg --encrypt --recipient 73D09948B2392D688A45DC8393E1BD26F6B02FB7 > "$@"
|
|
|
|
.PHONY: load-credentials
|
|
load-credentials:
|
|
< "${credentials_file}" gpg --decrypt | tar -xf -
|