-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (62 loc) · 2.42 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
.PHONY: all ${MAKECMDGOALS}
MOLECULE_SCENARIO ?= binary
MOLECULE_DOCKER_IMAGE ?= ubuntu2204
MOLECULE_DOCKER_COMMAND ?= /lib/systemd/systemd
MOLECULE_KVM_IMAGE ?= https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
GALAXY_API_KEY ?=
GITHUB_REPOSITORY ?= $$(git config --get remote.origin.url | cut -d: -f 2 | cut -d. -f 1)
GITHUB_ORG = $$(echo ${GITHUB_REPOSITORY} | cut -d/ -f 1)
GITHUB_REPO = $$(echo ${GITHUB_REPOSITORY} | cut -d/ -f 2)
REQUIREMENTS = requirements.yml
ROLE_DIR = roles
ROLE_FILE = roles.yml
COLLECTION_NAMESPACE = $$(yq '.namespace' < galaxy.yml)
COLLECTION_NAME = $$(yq '.name' < galaxy.yml)
COLLECTION_VERSION = $$(yq '.version' < galaxy.yml)
all: install version lint test
test: lint
poetry run molecule test -s ${MOLECULE_SCENARIO}
install:
@type poetry >/dev/null || pip3 install poetry
@type yq || sudo apt-get install -y yq
@sudo apt-get install -y libvirt-dev
@poetry install --no-root
lint: install
poetry run yamllint .
requirements: install
@rm -rf ${ROLE_DIR}/*
@python --version
@poetry run ansible-galaxy role install \
--force --no-deps \
--roles-path ${ROLE_DIR} \
--role-file ${ROLE_FILE}
@poetry run ansible-galaxy collection install \
--force-with-deps .
@\find ./ -name "*.ymle*" -delete
build: requirements
@poetry run ansible-galaxy collection build --force
dependency create prepare converge idempotence side-effect verify destroy cleanup reset list:
MOLECULE_KVM_IMAGE=${MOLECULE_KVM_IMAGE} \
MOLECULE_DOCKER_COMMAND=${MOLECULE_DOCKER_COMMAND} \
MOLECULE_DOCKER_IMAGE=${MOLECULE_DOCKER_IMAGE} \
poetry run molecule $@ -s ${MOLECULE_SCENARIO}
ifeq (login,$(firstword $(MAKECMDGOALS)))
LOGIN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(subst $(space),,$(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))):;@:)
endif
login:
MOLECULE_KVM_IMAGE=${MOLECULE_KVM_IMAGE} \
MOLECULE_DOCKER_COMMAND=${MOLECULE_DOCKER_COMMAND} \
MOLECULE_DOCKER_IMAGE=${MOLECULE_DOCKER_IMAGE} \
poetry run molecule $@ -s ${MOLECULE_SCENARIO} ${LOGIN_ARGS}
ignore:
@poetry run ansible-lint --generate-ignore
clean: destroy reset
@poetry env remove $$(which python) >/dev/null 2>&1 || exit 0
publish: build
poetry run ansible-galaxy collection publish --api-key ${GALAXY_API_KEY} \
"${COLLECTION_NAMESPACE}-${COLLECTION_NAME}-${COLLECTION_VERSION}.tar.gz"
version:
@poetry run molecule --version
debug: version
@poetry export --dev --without-hashes