-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (98 loc) · 4.02 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
.PHONY: all ${MAKECMDGOALS}
MOLECULE_SCENARIO ?= install
DEBIAN_RELEASE ?= bookworm
UBUNTU_RELEASE ?= jammy
EL_RELEASE ?= 9
DEBIAN_SHASUMS = https://cloud.debian.org/images/cloud/${DEBIAN_RELEASE}/latest/SHA512SUMS
DEBIAN_KVM_FILENAME = $$(curl -s ${DEBIAN_SHASUMS} | grep "generic-amd64.qcow2" | awk '{print $$2}')
DEBIAN_KVM_IMAGE = https://cloud.debian.org/images/cloud/${DEBIAN_RELEASE}/latest/${DEBIAN_KVM_FILENAME}
UBUNTU_KVM_IMAGE = https://cloud-images.ubuntu.com/${UBUNTU_RELEASE}/current/${UBUNTU_RELEASE}-server-cloudimg-amd64.img
ALMA_KVM_IMAGE = https://repo.almalinux.org/almalinux/${EL_RELEASE}/cloud/x86_64/images/AlmaLinux-${EL_RELEASE}-GenericCloud-latest.x86_64.qcow2
ROCKY_KVM_IMAGE = https://dl.rockylinux.org/pub/rocky/${EL_RELEASE}/images/x86_64/Rocky-${EL_RELEASE}-GenericCloud-Base.latest.x86_64.qcow2
MOLECULE_KVM_IMAGE := $(UBUNTU_KVM_IMAGE)
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
ubuntu:
make dependency create prepare \
MOLECULE_KVM_IMAGE=${UBUNTU_KVM_IMAGE} \
MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
noble ubuntu2404:
make ubuntu UBUNTU_RELEASE=noble MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
jammy ubuntu2204:
make ubuntu UBUNTU_RELEASE=jammy MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
focal ubuntu2004:
make ubuntu UBUNTU_RELEASE=focal MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
debian:
make dependency create prepare \
MOLECULE_KVM_IMAGE=${DEBIAN_KVM_IMAGE} \
MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
bookworm debian12:
make debian MOLECULE_SCENARIO=${MOLECULE_SCENARIO} DEBIAN_RELEASE=bookworm
alma:
make dependency create prepare \
MOLECULE_KVM_IMAGE=${ALMA_KVM_IMAGE} \
MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
alma8:
make alma EL_RELEASE=8 MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
alma9:
make alma EL_RELEASE=9 MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
rocky:
make dependency create prepare \
MOLECULE_KVM_IMAGE=${ROCKY_KVM_IMAGE} \
MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
rocky8:
make rocky EL_RELEASE=8 MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
rocky9:
make rocky EL_RELEASE=9 MOLECULE_SCENARIO=${MOLECULE_SCENARIO}
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
@type nmcli || sudo apt-get install -y network-manager
@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} \
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} \
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