-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
86 lines (73 loc) · 2.11 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
ANSIBLE_KEEP_REMOTE_FILES = $(or $(shell printenv ANSIBLE_KEEP_REMOTE_FILES),0)
ANSIBLE_FLAGS = $(or $(shell printenv ANSIBLE_FLAGS),--diff)
DOCKER_INTERACTIVE = $(if $(shell printenv GITHUB_ACTIONS),-t,-t)
GID = $(or $(shell printend GID), $(shell id -g))
GIT_REVISION = $(or $(shell printenv GIT_REVISION), $(shell git describe --match= --always --abbrev=7 --dirty))
GROUP = $(or $(shell printend GROUP), $(shell id -g -n))
HOME = $(shell printenv HOME)
PLAYBOOKS = $(shell find . -name playbook.yml)
UID = $(or $(shell printenv UID), $(shell id -u))
USER = $(or $(shell printenv USER), $(shell id -u -n))
VERSION = snapshot
.PHONY: check
check:
$(MAKE) run \
ANSIBLE_FLAGS="--check --diff" \
ARGS="${ARGS}"
.PHONY: check-docker
check-docker:
$(MAKE) docker-do-check \
ARGS="${ARGS}"
.PHONY: run
run:
ansible-playbook \
${ANSIBLE_FLAGS} \
-i inventory.yml \
${ARGS}
.PHONY: run-docker
run-docker: docker-do-run
.PHONY: lint
lint:
ansible-lint -v $(or ${ARGS},${PLAYBOOKS})
.PHONY: lint-docker
lint-docker: docker-do-lint
.PHONY: syntax
syntax:
$(MAKE) run \
ANSIBLE_FLAGS="--syntax-check -vv" \
ARGS="$(or ${ARGS},${PLAYBOOKS})"
.PHONY: syntax-docker
syntax-docker: docker-do-syntax
.PHONY: vendor
vendor:
ansible-galaxy \
install \
--verbose \
--force \
-r requirements.yml
.PHONY: vendor-docker
vendor-docker: docker-do-vendor
.PHONY: docker-do-%
docker-do-%: .dockerimage
docker \
run \
--rm \
${DOCKER_INTERACTIVE} \
-e ANSIBLE_KEEP_REMOTE_FILES=${ANSIBLE_KEEP_REMOTE_FILES} \
-e HOME=/homedir \
-e SSH_AUTH_SOCK=/var/run/ssh-agent.sock \
-v ${HOME}/.ssh:/homedir/.ssh:ro \
-v ${SSH_AUTH_SOCK}:/var/run/ssh-agent.sock \
-v ${PWD}:/workdir:ro \
-w /workdir \
ansible \
make $* ARGS="${ARGS}"
.dockerimage: Dockerfile
docker \
build \
--build-arg GID=${GID} \
--build-arg GROUP=${GROUP} \
--build-arg UID=${UID} \
--build-arg USER=${USER} \
-t ansible .
touch .dockerimage