Added puppet module skeleton (also puppet module tool is lame)

This commit is contained in:
2013-10-19 10:37:30 -04:00
parent 9895e8efbf
commit 363d5ef262
4 changed files with 118 additions and 9 deletions

View File

@@ -3,27 +3,48 @@ BUILD:=$(shell bash -c 'source version.sh ; echo $$BUILD')
OS_NAME:=$(shell bash -c 'source version.sh ; echo $$OS_NAME') OS_NAME:=$(shell bash -c 'source version.sh ; echo $$OS_NAME')
ifeq "$(OS_NAME)" "win" ifeq "$(OS_NAME)" "win"
PIP=$(shell pwd)/virtualenv/Scripts/pip PIP=$(shell pwd)/virtualenv/Scripts/pip
SDIST_EXT=zip
VIRTUALENV_PKGS_DIR=$(shell pwd)/virtualenv/Lib/site-packages VIRTUALENV_PKGS_DIR=$(shell pwd)/virtualenv/Lib/site-packages
else else
PIP=$(shell pwd)/virtualenv/bin/pip PIP=$(shell pwd)/virtualenv/bin/pip
SDIST_EXT=tar.gz
VIRTUALENV_PKGS_DIR=$(shell pwd)/virtualenv/lib/site-packages VIRTUALENV_PKGS_DIR=$(shell pwd)/virtualenv/lib/site-packages
endif endif
VIRTUALENV=$(shell which virtualenv) VIRTUALENV=$(shell which virtualenv)
PYTHON=$(shell which python) PYTHON=$(shell which python)
PYTHON_FILES=setup.py mercy/version.py $(shell find mercy -iname "*py") PYTHON_FILES=setup.py mercy/version.py $(shell find mercy -iname "*py")
PYTHON_SDIST=./dist/mercy-$(MAJOR)-$(BUILD).$(SDIST_EXT) PYTHON_SDIST=./dist/mercy-$(MAJOR)-$(BUILD).tar.gz
.PHONY: virtualenv
virtualenv:
$(VIRTUALENV) --no-site-packages --distribute virtualenv
.PHONY: clean .PHONY: clean
clean: clean:
rm -fr dist/* rm -fr dist/*
find mercy -iname "*pyc" -exec rm -vf \{\} \; find mercy -iname "*pyc" -exec rm -vf \{\} \;
cd puppet && make clean
############## Targets for puppet module
puppet/version.sh: version.sh
cp version.sh $@
.PHONY: puppet
puppet: puppet_dist
.PHONY: puppet_dist
puppet_dist: puppet/version.sh
cd puppet && make dist
.PHONY: puppet_install
puppet_install: puppet/version.sh
cd puppet && make install
.PHONY: puppet_uninstall
puppet_uninstall: puppet/version.sh
cd puppet && make uninstall
################ /puppet module
############### Targets for python app
dist: $(PYTHON_SDIST) puppet
sdist: $(PYTHON_SDIST) sdist: $(PYTHON_SDIST)
@@ -31,10 +52,18 @@ mercy/version.py: version.sh
source version.sh && echo "VERSION=\"$${MAJOR}-$${BUILD}\"" > $@ source version.sh && echo "VERSION=\"$${MAJOR}-$${BUILD}\"" > $@
$(PYTHON_SDIST): $(PYTHON_FILES) $(PYTHON_SDIST): $(PYTHON_FILES)
$(PYTHON) setup.py sdist $(PYTHON) setup.py sdist --formats=gztar
uninstall: uninstall:
rm -fr $(VIRTUALENV_PKGS_DIR)/mercy-* || echo 'not installed' rm -fr $(VIRTUALENV_PKGS_DIR)/mercy-* || echo 'not installed'
install: $(PYTHON_SDIST) install: $(PYTHON_SDIST) virtualenv
$(PIP) install $(PYTHON_SDIST) --upgrade $(PIP) install $(PYTHON_SDIST) --upgrade
.PHONY: virtualenv
virtualenv:
if [ ! -e $(PIP) ]; then \
$(VIRTUALENV) --no-site-packages --distribute virtualenv ; \
fi
################## /python app

32
puppet/Makefile Normal file
View File

@@ -0,0 +1,32 @@
MAJOR:=$(shell bash -c 'source version.sh ; echo $$MAJOR')
BUILD:=$(shell bash -c 'source version.sh ; echo $$BUILD')
MODULEPATH:=$(shell puppet config print modulepath)
ifeq ($(MODULEPATH),)
$(error "I can't figure out your puppet modulepath, this will cause all kinds of bad things to happen with 'make install' and 'make uninstall'")
endif
PUPPET_DEPS=$(find mercy -type f)
PUPPET_DIST=mercy/pkg/akesterson-mercy-$(MAJOR).$(BUILD).tar.gz
.PHONY: clean
clean:
rm pkg/*
rm Modulefile
mercy/Modulefile: Modulefile.template.sh version.sh
source version.sh && bash Modulefile.template.sh > Modulefile
$(PUPPET_DIST): $(PUPPET_DEPS) mercy/Modulefile
rm -f $(PUPPET_DIST)
mkdir -p $$(dirname $(PUPPET_DIST))
echo 'We would use puppet module tool here but we dont because it doesnt work on windows buildhosts and cant upload from the command line anyway'
tar --exclude=mercy/Modulefile --exclude=mercy/pkg -czvf $(PUPPET_DIST) mercy/
dist: $(PUPPET_DIST)
all: $(PUPPET_DIST)
install: $(PUPPET_DIST)
tar -zxvf $(PUPPET_DIST) -C $(MODULEPATH)
uninstall:
rm -fr $(MODULEPATH)/mercy

View File

@@ -0,0 +1,12 @@
#!/bin/bash
cat <<EOF
name 'akesterson-mercy'
version '${MAJOR}-${BUILD}'
dependency 'apache/apache'
summary 'Puppet module for deploying the mercy web application'
description 'Puppet module for deploying the mercy web application'
project_page http://github.com/akesterson/mercy/tree/master/puppet
license 'MIT'
author 'Andrew Kesterson <andrew@aklabs.net>'
EOF

36
puppet/README.md Normal file
View File

@@ -0,0 +1,36 @@
mercy
=====
A puppet module for installing the Mercy Flask application
Requirements
============
This puppet module assumes that you have:
* Working apache with a puppet service
* Working python 2.7 and pip
* Working postgres with a username, password, and database for mercy to use
Aside from that, the module has no dependencies.
Usage
=========
class { 'mercy::application':
environment => 'dev|production',
ensure => 'absent|latest|MAJOR-MINOR',
vhost_dir => '/etc/apache/httpd/conf.d',
apache_service => 'httpd',
postgres_uri => 'localhost',
postgres_user => 'mercy',
postgres_pw => 'mercy',
postgres_db => 'mercy'
}
If 'environment' is dev, then the mercy application will be installed via a tarball located in ./mercy/files/mercy-${ensure}.tar.gz. If 'environment' is production, then mercy will be installed via pip and ensured at the given version.
Events
======
This puppet module will notify your apache service whenever the vhost is modified, or the mercy application version is updated, since an apache graceful restart will be required in either case.