-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (50 loc) · 1.52 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
# ansible
BINDIR ?= $(HOME)/.local/bin
ANSIBLE_PLAYBOOK ?= $(BINDIR)/ansible-playbook
# ansible-playbook
hosts ?= localhost
# package manager
APT ?= sudo apt-get
ifeq ($(shell id -u), 0)
APT = apt-get
endif
define apt_install
command -v $(1) >/dev/null || { \
$(APT) update -y && \
$(APT) install -y --no-install-suggests --no-install-recommends $(1); \
}
endef
.DEFAULT_GOAL=help
.PHONY: help
help: ## show this help message
@awk -F ':|##' '/^[^\t].+?:.*?##/ {\
printf "\033[36m%-10s\033[0m %s\n", $$1, substr($$0, index($$0,$$3)) \
}' $(MAKEFILE_LIST)
.PHONY: jq
jq:
$(call apt_install,jq)
# sudo activate-global-python-argcomplete
.PHONY: pipx
pipx:
$(call apt_install,pipx)
.PHONY: ansible
ansible: pipx ## pipx install ansible
command -v ansible >/dev/null || { \
pipx install ansible && \
pipx inject ansible argcomplete && \
ln -sf $(HOME)/.local/pipx/venvs/ansible/bin/ansible* $(HOME)/.local/bin/; \
}
DIFFT_VERSION ?= x86_64-unknown-linux-gnu
.PHONY: difft
difft: jq ## install difft from github releases
command -v difft >/dev/null || { \
curl -s https://api.github.com/repos/Wilfred/difftastic/releases/latest | \
jq -r '.assets[].browser_download_url | select(test("$(DIFFT_VERSION)"))' | \
wget -q -i - && \
tar -xf difft-$(DIFFT_VERSION).tar.gz && \
sudo install -m 755 difft /usr/local/bin/difft && \
rm difft-$(DIFFT_VERSION).tar.gz difft; \
}
.PHONY: install
install: ansible ## install basic stow packages with ansible and stow
$(ANSIBLE_PLAYBOOK) playbook.yaml -e 'hosts=$(hosts)'