aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 349df6a7cee7ccf0262f3a55b0298c4ddcf8d472 (plain)
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
ARCHIVE :=		ansible.tar.gz
HOST ?=			$(shell hostname -s)

.PHONY: all
all: sync

# check-tree ensures the git tree is clean.
.PHONY: check-tree
check-tree:
	bin/check-tree

# sync applies the Ansible configuration.
.PHONY: sync
sync:
	ANSIBLE_NOCOLOR=1 ansible-playbook --ask-vault-pass -K -i hosts $(HOST).yaml

# snapshot does the following:
# 1. clean the tree (to remove any existing snapshots).
# 2. verify the tree is clean.
# 3. applies the current configuration.
# 4. creates a git-archive of the tree.
# The first three steps ensure that the snapshot represents the true state
# of the machine currently.
.PHONY: snapshot
snapshot: clean check-tree sync $(ARCHIVE)

# This used to be:
# git archive --format tgz --prefix ansible/ -o $@ -9 HEAD
# but that doesn't include the git tree, which we need to
# pull later.
$(ARCHIVE):
	tar czf $@ $$(find ../$$(basename $$(pwd)) -type f)

# clean removes any archive and cleans out any generated docs.
.PHONY: clean
clean:
	rm -f $(ARCHIVE)
	rm -f *.retry

.PHONY: whoami
whoami:
	@echo "$(HOST)"