Created
February 14, 2012 18:52
-
-
Save artyom/1829079 to your computer and use it in GitHub Desktop.
deployer prototype (tired of cfengine :))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/make -rf | |
SELF := $(shell hostname -s) | |
.NOTPARALLEL: | |
.ONESHELL: | |
SHELL := /bin/sh | |
.SHELLFLAGS := -e | |
.PHONY: UPDATE_SOURCES ALL $(PACKAGES) | |
#PACKAGES := nginx-full apache2-utils | |
PACKAGES := nginx-full | |
CONFIGS := /etc/foo.config | |
ALL: $(PACKAGES) $(CONFIGS) | |
$(PACKAGES): | UPDATE_SOURCES | |
dpkg -l | awk -v pkg=$@ \ | |
'$$1=="ii"&&$$2==pkg{fnd=1;exit 0}END{if(!fnd)exit 1}' || \ | |
apt-get -f -y install $@ | |
UPDATE_SOURCES: | |
echo running apt-get -q update | |
# consider /etc/foo.config as a conffile for nginx | |
ifeq "$(SELF)" "myhostname" | |
/etc/foo.config: $(PWD)/foo.template $(PWD)/foo.var.$(SELF) | nginx-full | |
echo $(SELF) | |
test -e $@ || :>$@ | |
chmod 0640 $@ | |
chown artyom:artyom $@ | |
set -a ; . $(PWD)/foo.var.$(SELF) ; envsubst < $< > $@ | |
endif | |
# these ones' are for illustration purposes only, | |
# normally you should create them with text editor | |
$(PWD)/foo.template: | |
printf 'FOO is $$FOO,\nBAR is $$BAR\n' > $@ | |
$(PWD)/foo.variables: | |
echo FOO=\'Foo_value\' > $@ | |
echo BAR=\'bar value\' >> $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment