forked from vholer/cloudify-occi-puppet-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
97 lines (66 loc) · 2.57 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
INPUTS=example-inputs.yaml
M4INPUTS=$(INPUTS).m4
BLUEPRINT=example-blueprint.yaml
M4BLUEPRINT=$(BLUEPRINT).m4
CFM_BLUEPRINT=example
CFM_DEPLOYMENT=example
RETRIES=10
VIRTUAL_ENV?=~/cfy
.PHONY: blueprints inputs validate test clean
# blueprints
blueprints: cfy-$(BLUEPRINT) cfm-$(BLUEPRINT)
cfy-$(BLUEPRINT): $(M4BLUEPRINT)
m4 $? >".$@"
mv ".$@" $@
cfm-$(BLUEPRINT): $(M4BLUEPRINT)
m4 -D_CFM_ $? >".$@"
mv ".$@" $@
# inputs
inputs: cfy-$(INPUTS) cfm-$(INPUTS)
cfy-$(INPUTS): $(M4INPUTS) resources/ssh/id_rsa
m4 $(M4INPUTS) >".$@"
mv ".$@" $@
cfm-$(INPUTS): $(M4INPUTS) resources/ssh/id_rsa
m4 -D_CFM_ -D_CFM_BLUEPRINT_=$(CFM_BLUEPRINT) $(M4INPUTS) >".$@"
mv ".$@" $@
validate: cfy-$(BLUEPRINT) cfm-$(BLUEPRINT)
cfy blueprints validate -p cfy-$(BLUEPRINT)
cfy blueprints validate -p cfm-$(BLUEPRINT)
test: validate inputs cfy-init clean
clean:
-rm -rf cfy-$(INPUTS) .cfy-$(INPUTS) cfm-$(INPUTS) .cfm-$(INPUTS) cfy-$(BLUEPRINT) .cfy-$(BLUEPRINT) cfm-$(BLUEPRINT) .cfm-$(BLUEPRINT) resources/puppet.tar.gz resources/ssh/ local-storage/
cfy-deploy: cfy-init cfy-exec-install
cfy-undeploy: cfy-exec-uninstall
cfy-test: cfy-deploy cfy-undeploy
cfm-deploy: cfm-init cfm-exec-install
cfm-test: cfm-deploy cfm-exec-uninstall cfm-clean
### Resources ####################################
resources/ssh/id_rsa:
mkdir -p resources/ssh/
ssh-keygen -N '' -f resources/ssh/id_rsa
resources/puppet.tar.gz: resources/puppet/
tar -czvf $@ -C $? .
### Standalone deployment ########################
cfy-init: cfy-$(BLUEPRINT) cfy-$(INPUTS) resources/puppet.tar.gz
cfy local init -p cfy-$(BLUEPRINT) -i cfy-$(INPUTS) --install-plugins
# execute deployment
cfy-exec-%:
cfy local execute -w $* --task-retries $(RETRIES)
### Cloudify Manager managed deployment ##########
cfm-init: cfm-$(BLUEPRINT) cfm-$(INPUTS) resources/puppet.tar.gz
cfy blueprints upload -b $(CFM_BLUEPRINT) -p cfm-$(BLUEPRINT)
cfy deployments create -b $(CFM_BLUEPRINT) -d $(CFM_DEPLOYMENT) -i cfm-$(INPUTS)
cfm-exec-%:
cfy executions start -d $(CFM_DEPLOYMENT) -w $*
sleep 10
cfm-clean:
cfy deployments delete -d $(CFM_DEPLOYMENT)
cfy blueprints delete -b $(CFM_BLUEPRINT)
### Bootstrap cfy ################################
bootstrap:
test -f get-cloudify.py && unlink get-cloudify.py || /bin/true
which virtualenv || ( yum install -y python-virtualenv || apt-get install -y python-virtualenv )
which pip || ( yum install -y python-pip || apt-get install -y python-pip )
wget -O get-cloudify.py 'http://repository.cloudifysource.org/org/cloudify3/get-cloudify.py'
python get-cloudify.py -e $(VIRTUAL_ENV)
unlink get-cloudify.py