First commit
This commit is contained in:
commit
c8f2b3ef39
14 changed files with 372 additions and 0 deletions
60
Makefile
Normal file
60
Makefile
Normal file
|
@ -0,0 +1,60 @@
|
|||
# Ansible options
|
||||
ansible_user ?= ephase
|
||||
ansible_roles := deps
|
||||
ansible_options ?= --diff
|
||||
ansible_playbook ?= playbook.yml
|
||||
ansible_req ?= requirements.yml
|
||||
# venv options
|
||||
venv_source ?= .venv
|
||||
venv_cmd := . $(venv_source)/bin/activate
|
||||
|
||||
#Python
|
||||
python_bin ?= python
|
||||
pip_req ?= requirements.txt
|
||||
|
||||
.PHONY: inventory
|
||||
inventory:
|
||||
ansible-inventory --graph -i inventory.ini
|
||||
|
||||
$(ansible_req):
|
||||
|
||||
deps: $(ansible_req)
|
||||
$(shell mkdir -p $(ansible_roles))
|
||||
ifeq ($(wildcard $(ansible_req)),)
|
||||
$(error there is not requirements.yml file in $(ansible_data)!)
|
||||
endif
|
||||
$(venv_cmd) && ansible-galaxy install \
|
||||
--ignore-errors \
|
||||
--roles-path="$(ansible_roles)" \
|
||||
--role-file="$(ansible_req)"
|
||||
|
||||
.PHONY: check-syntax
|
||||
check-syntax: ## check-syntax #Check playbook syntax
|
||||
$(venv_cmd) && ansible-playbook -i inventory.ini \
|
||||
--syntax-check $(ansible_playbook)
|
||||
|
||||
.PHONY: dry-run
|
||||
dry-run: ## dry-run #run playbook in check mode
|
||||
$(venv_cmd) && ansible-playbook -i inventory.ini \
|
||||
--check $(ansible_options) $(ansible_playbook) \
|
||||
-u $(ansible_user)
|
||||
|
||||
.PHONY: dry-run
|
||||
run: ## dry-run #run playbook in check mode
|
||||
$(venv_cmd) && ansible-playbook -i inventory.ini \
|
||||
$(ansible_options) $(ansible_playbook) \
|
||||
-u $(ansible_user)
|
||||
|
||||
# venv management
|
||||
$(venv_source):
|
||||
$(python_bin) -m venv $(venv_source)
|
||||
|
||||
$(pip_req):
|
||||
|
||||
$(venv_source)/dep: $(venv_source) $(pip_req)
|
||||
touch $(venv_source)/dep
|
||||
$(venv_cmd) && pip install -r $(pip_req)
|
||||
|
||||
.PHONY: clean-venv
|
||||
clean-venv:
|
||||
[ -d $(venv_source) ] && rm -rf $(venv_source)
|
Loading…
Add table
Add a link
Reference in a new issue