-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
91 lines (72 loc) · 2.05 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
#
# WARP
# project makefile
#
# program vars
CD:=cd
VAGRANT:=vagrant
PACKER:=packer
PRE_CMT:=pre-commit
RM:=rm -rf
GALAXY:=ansible-galaxy
PLAYBOOK:=ansible-playbook
# paths
BOX_DIR:=box
BUILD_DIR:=build
PACKER_DIR:=$(BOX_DIR)/packer
ANSIBLE_DIR=$(BOX_DIR)/ansible
# box metadata
BOX_NAME:=mrzzy/warp-box
# phony build rules
.PHONY: all box box-gcp clean fmt lint apply packer-init ansible-deps
.DEFAULT: all
all: box
lint: packer-init ansible-deps
$(PACKER) fmt -check $(PACKER_DIR)
$(PACKER) validate $(PACKER_DIR)
$(PRE_CMT) run
fmt:
$(PACKER) fmt $(PACKER_DIR)
clean: clean-box
# apply the ansible devbox playbook to the local machine
ansible-deps:
$(GALAXY) install --force -r requirements.yaml
apply: $(ANSIBLE_DIR) ansible-deps
$(PLAYBOOK) \
--inventory 127.0.0.1, \
--connection local \
--ask-become-pass \
$(ANSIBLE_DIR)/console.yaml
apply-gui: $(ANSIBLE_DIR) ansible-deps
$(PLAYBOOK) \
--inventory 127.0.0.1, \
--connection local \
--ask-become-pass \
$(ANSIBLE_DIR)/gui.yaml
# applying on laptop requires an inventory file due to required variables for borgbackup role
apply-laptop: $(ANSIBLE_DIR) ansible-deps
$(PLAYBOOK) \
--inventory inventory.yaml \
--connection local \
--ask-become-pass \
$(ANSIBLE_DIR)/laptop.yaml
# development build: build box on virtualbox only.
box: $(PACKER_DIR) packer-init ansible-deps
$(PACKER) build -var ansible_playbook=box/ansible/gui.yaml \
--on-error=ask --only="vagrant.ubuntu_vm" --force $<
box-gcp: $(PACKER_DIR) packer-init ansible-deps
$(PACKER) build --only="googlecompute.ubuntu_gce" --force $<
packer-init: $(PACKER_DIR)
$(PACKER) init $<
clean-box:
$(RM) $(BUILD_DIR)
install-box: build/package.box
$(VAGRANT) box add build/package.box --name $(BOX_NAME) --force
uninstall-box:
$(VAGRANT) box remove $(BOX_NAME)
# use the Vagrantfile generated by packer to bring the box VM up
# the name of the machine is 'output', set by the Vagrantfile
run-box: install-box
$(CD) $(BUILD_DIR) && $(VAGRANT) up
-$(CD) $(BUILD_DIR) && $(VAGRANT) ssh output
$(CD) $(BUILD_DIR) && $(VAGRANT) destroy