-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
105 lines (87 loc) · 3.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
SHELL = /bin/bash
# Set paths for binaries used
bolt ?= /opt/puppetlabs/bin/bolt
ifeq ($(shell uname -s),Darwin)
bin = /usr/local/bin
else
bin = /usr/bin
endif
puppet-lint = ${bin}/puppet-lint
vagrant = ${bin}/vagrant
virtualbox = ${bin}/virtualbox
inspec = ${bin}/inspec
# Default action is to install dependencies
all: | ${bolt}
# Targets to perform update of the Dashboard application
promote_latest_to_staging:
docker pull internetstandards/dashboard:latest
docker tag internetstandards/dashboard:latest internetstandards/dashboard:staging
docker push internetstandards/dashboard:staging
promote_staging_to_live:
docker pull internetstandards/dashboard:latest
docker tag internetstandards/dashboard:latest internetstandards/dashboard:live
docker push internetstandards/dashboard:live
update_staging update_live: update_%:
${bolt} command run "/usr/local/bin/dashboard-update" --targets $*
# Spin up and provision local VM for testing
lab: labhost apply_lab
labhost: | ${vagrant} ${virtualbox}
# check if testhost is up or start it
nc 172.30.1.5 -z 22 -w 3 -n || ${vagrant} up
# Local integrationtesting
test: lab test_inspec
test_inspec: | ${inspec}
${inspec} exec spec/ \
-t ssh://[email protected] \
-i .vagrant/machines/default/virtualbox/private_key
# Apply server configuration to nodes
apply_lab apply_staging apply_live apply_all: apply_%: Boltdir/.modules/ | ${bolt}
${bolt} apply --verbose Boltdir/modules/dashboard/manifests/site.pp --targets $* ${args}
plan_lab plan_staging plan_live plan_all: plan_%: Boltdir/.modules/ | ${bolt}
${bolt} apply --noop --verbose Boltdir/modules/dashboard/manifests/site.pp --targets $* ${args}
# Development workflow
fix: .make.fix
.make.fix: $(shell find Boltdir/modules/ -name *.pp) | ${puppet-lint}
${puppet-lint} --fix Boltdir/modules
@touch $@
check: .make.check
.make.check: $(shell find Boltdir/modules/ -name *.pp)
${puppet-lint} Boltdir/modules
Boltdir/.modules/: Boltdir/Puppetfile Boltdir/bolt-project.yaml| ${bolt}
${bolt} module install
@touch $@
# Install dependencies
ifeq ($(shell uname -s),Darwin)
${vagrant} ${virtualbox}:
brew cask install ${@F}
${bolt}:
brew tap puppetlabs/puppet
brew install --cask puppet-bolt
${puppet-lint}:
brew tap rockyluke/devops
brew install puppet-lint
${inspec}:
brew cask install chef/chef/inspec
else ifneq (,$(shell grep ubuntu /etc/os-release))
${puppet-lint} ${vagrant} ${virtualbox}:
sudo apt-get install -yqq ${@F}
${bolt}:
wget https://apt.puppet.com/puppet6-release-$(shell lsb_release -c -s).deb
sudo dpkg -i puppet6-release-$(shell lsb_release -c -s).deb
rm -f puppet6-release-$(shell lsb_release -c -s).deb
sudo apt-get update -qq
sudo apt-get install -yqq puppet-bolt
${inspec}:
wget https://packages.chef.io/files/stable/inspec/4.3.2/ubuntu/18.04/inspec_4.3.2-1_amd64.deb
sudo dpkg -i inspec_4.3.2-1_amd64.deb
rm -f inspec_4.3.2-1_amd64.deb
${inspec} version --chef-license=accept-silent >/dev/null
else
$(error Unsupported system ${os})
endif
clean:
rm -rf .make.*
mrproper: destroy_vm clean
rm -rf Boltdir/.modules/
destroy_lab:
-vagrant destroy -f