-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
50 lines (40 loc) · 1.38 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# set the comma separated inventory.
# goal must be comma separated for multiple goal
# if goals is empty, it runs only default goal (host)
ifeq ($(goals),)
INVENTORY:=--limit default
else
INVENTORY:=--limit $(goals)
endif
# set tag. tag value must be comma separated
ifneq ($(tags),)
TAGS:=-t $(tags)
endif
.PHONY: install
install: ansible-install requirements
@$(ACTIVATE_VENV) && $(ANSIBLE_PLAYBOOK) $(INVENTORY) main.yml --ask-become-pass $(TAGS)
.PHONY: requirements
requirements: ansible-install
@$(ACTIVATE_VENV) && $(ANSIBLE_GALAXY) install -r requirements.yml
##@ Build Dependencies ------------------------------------------------------------
# Python VENV root
VENV ?= $(shell pwd)/.venv
$(VENV):
mkdir -p $(VENV)
# command for Activating the VENV in the Makefile
ACTIVATE_VENV = . $(VENV)/bin/activate
# Tool Versions
ANSIBLE_VERSION ?= 9.5.1
## Tool Binaries
ANSIBLE_PLAYBOOK ?= ansible-playbook
ANSIBLE_GALAXY ?= ansible-galaxy
# Ensure Python VENV is created and can be activated
.PHONY: python-venv
python-venv: $(VENV)
@python3 -m venv $(VENV)
@$(ACTIVATE_VENV) && which python3
# Ensure Ansible is installed
# Installation is done using Python VENV in the project directory `.venv` in order to ensure that Ansible is running any user environment
.PHONY: ansible-install
ansible-install: python-venv
@$(ACTIVATE_VENV) && python3 -m pip install ansible==$(ANSIBLE_VERSION)