-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
77 lines (53 loc) · 2.1 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
SHELL := $(shell which bash)
SELF := $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))
HATCH_BIN ?= $(shell command -v hatch)
ifneq ($(strip $(HATCH_BIN)),)
ENV_RUN = $(HATCH_BIN) env run -e $(1) --
ENV_DEFAULT := $(shell $(HATCH_BIN) env find default)
ENV_CEPH := $(shell $(HATCH_BIN) env find ceph)
endif
I ?= $(SELF)/inventory/example.yml
INVENTORY ?= $(I)
T ?=
TAGS ?= $(T)
S ?=
SKIP_TAGS ?= $(S)
V ?= vv
VERBOSE ?= $(V)
export
# Make sure we source ANSIBLE_ settings from ansible.cfg exclusively.
unexport $(filter ANSIBLE_%,$(.VARIABLES))
.PHONY: all
all: main
.PHONY: infra pre ceph site main
infra pre ceph site main: _TAGS := $(if $(TAGS),-t $(TAGS),)
infra pre ceph site main: _SKIP_TAGS := $(if $(SKIP_TAGS),--skip-tags $(SKIP_TAGS),)
infra pre ceph site main: _VERBOSE := $(if $(VERBOSE),-$(VERBOSE),)
ifdef ENV_DEFAULT
$(ENV_DEFAULT):
$(HATCH_BIN) env create default
endif
infra pre site main: $(ENV_DEFAULT)
cd $(SELF)/ && \
$(call ENV_RUN,default) ansible-playbook $(_VERBOSE) -i $(INVENTORY) $(_TAGS) $(_SKIP_TAGS) opennebula.deploy.$@
ifdef ENV_CEPH
$(ENV_CEPH):
$(HATCH_BIN) env create ceph
endif
ceph: $(ENV_CEPH)
cd $(SELF)/ && \
$(call ENV_RUN,ceph) ansible-playbook $(_VERBOSE) -i $(INVENTORY) $(_TAGS) $(_SKIP_TAGS) opennebula.deploy.$@
.PHONY: requirements requirements-hatch requirements-python requirements-galaxy clean-requirements
requirements: requirements-$(if $(ENV_RUN),hatch,python) requirements-galaxy
requirements-hatch: $(SELF)/pyproject.toml $(ENV_DEFAULT)
requirements-python: $(SELF)/requirements.txt
pip3 install --requirement $<
requirements-galaxy: $(SELF)/requirements.yml $(ENV_DEFAULT)
$(call ENV_RUN,default) ansible-galaxy collection install --requirements-file $<
clean-requirements:
find $(SELF)/ansible_collections/ -mindepth 1 -maxdepth 1 -type d ! -name opennebula -exec rm -rf {} +
$(if $(ENV_DEFAULT),$(HATCH_BIN) env remove default,)
$(if $(ENV_CEPH),$(HATCH_BIN) env remove ceph,)
.PHONY: lint-ansible
lint-ansible: $(ENV_DEFAULT)
cd $(SELF)/ && $(call ENV_RUN,default) ansible-lint roles/ playbooks/