Working on #6. I think I should break out the puppet module stuff into a
separate issue, since that risks really putting this all off target.
This commit is contained in:
@@ -9,7 +9,7 @@ Requirements
|
||||
This puppet module assumes that you have:
|
||||
|
||||
* A RabbitMQ broker that we can use for Celery tasks
|
||||
* Working apache on localhost with a puppet service we can notify
|
||||
* Working apache on localhost, with mod_wsgi enabled and with a puppet service we can notify
|
||||
* Working python 2.7 and pip on localhost
|
||||
* Working postgres with a username, password, and database for mercy to use
|
||||
|
||||
@@ -20,20 +20,25 @@ Usage
|
||||
|
||||
class { 'mercy':
|
||||
# ---- These are required, they have no defaults
|
||||
environment => 'dev|production',
|
||||
version => 'absent|latest|MAJOR-MINOR',
|
||||
ensure => 'running|stopped'.
|
||||
rabbitmq_uri => 'RABBITMQ_BROKER_URI',
|
||||
environment => 'dev|production',
|
||||
version => 'absent|latest|MAJOR-MINOR',
|
||||
ensure => 'running|stopped'.
|
||||
rabbitmq_uri => 'RABBITMQ_BROKER_URI',
|
||||
# ---- Everything below is optional
|
||||
rabbitmq_user => 'mercy',
|
||||
rabbitmq_pw => 'mercy',
|
||||
rabbitmq_vhost => 'mercy',
|
||||
vhost_dir => '/etc/apache/httpd/conf.d',
|
||||
apache_service => 'httpd',
|
||||
postgres_uri => 'localhost',
|
||||
postgres_user => 'mercy',
|
||||
postgres_pw => 'mercy',
|
||||
postgres_db => 'mercy'
|
||||
process_user => 'mercy',
|
||||
process_group => 'mercy',
|
||||
process_threads => 5,
|
||||
servername => $::fqdn,
|
||||
rabbitmq_user => 'mercy',
|
||||
rabbitmq_pw => 'mercy',
|
||||
rabbitmq_vhost => 'mercy',
|
||||
vhost_dir => '/etc/apache/httpd/conf.d',
|
||||
apache_service => 'httpd',
|
||||
port => 443,
|
||||
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.
|
||||
|
||||
31
puppet/mercy/manifests/#init.pp#
Normal file
31
puppet/mercy/manifests/#init.pp#
Normal file
@@ -0,0 +1,31 @@
|
||||
class mercy(
|
||||
$environment,
|
||||
$version,
|
||||
$ensure,
|
||||
$rabbitmq_uri,
|
||||
$process_user => 'mercy',
|
||||
$process_group => 'mercy',
|
||||
$process_threads => 5,
|
||||
$servername => $::fqdn,
|
||||
$rabbitmq_user => 'mercy',
|
||||
$rabbitmq_pw => 'mercy',
|
||||
$rabbitmq_vhost => 'mercy',
|
||||
$vhost_dir => '/etc/apache/httpd/conf.d',
|
||||
$apache_service => 'httpd',
|
||||
$port => 443,
|
||||
$postgres_uri => 'localhost',
|
||||
$postgres_user => 'mercy',
|
||||
$postgres_pw => 'mercy',
|
||||
$postgres_db => 'mercy')
|
||||
{
|
||||
if ! defined(User[$process_user]) {
|
||||
user { $process_user:
|
||||
ensure => 'present'
|
||||
}
|
||||
}
|
||||
if ! defined(Group[$process_group]) {
|
||||
user { $process_group:
|
||||
ensure => 'present'
|
||||
}
|
||||
}
|
||||
}
|
||||
22
puppet/mercy/manifests/init.pp
Normal file
22
puppet/mercy/manifests/init.pp
Normal file
@@ -0,0 +1,22 @@
|
||||
class mercy(
|
||||
$environment,
|
||||
$version,
|
||||
$ensure,
|
||||
$rabbitmq_uri,
|
||||
$process_user => 'mercy',
|
||||
$process_group => 'mercy',
|
||||
$process_threads => 5,
|
||||
$servername => $::fqdn,
|
||||
$rabbitmq_user => 'mercy',
|
||||
$rabbitmq_pw => 'mercy',
|
||||
$rabbitmq_vhost => 'mercy',
|
||||
$vhost_dir => '/etc/apache/httpd/conf.d',
|
||||
$apache_service => 'httpd',
|
||||
$port => 443,
|
||||
$postgres_uri => 'localhost',
|
||||
$postgres_user => 'mercy',
|
||||
$postgres_pw => 'mercy',
|
||||
$postgres_db => 'mercy')
|
||||
{
|
||||
include 'mercy::params'
|
||||
}
|
||||
4
puppet/mercy/manifests/params.pp
Normal file
4
puppet/mercy/manifests/params.pp
Normal file
@@ -0,0 +1,4 @@
|
||||
class mercy::params
|
||||
{
|
||||
|
||||
}
|
||||
23
puppet/mercy/manifests/params.pp~
Normal file
23
puppet/mercy/manifests/params.pp~
Normal file
@@ -0,0 +1,23 @@
|
||||
class mercy::params ( $environment,
|
||||
$version,
|
||||
$ensure,
|
||||
$rabbitmq_uri,
|
||||
# ---- Everything below is optional
|
||||
$process_user => 'mercy',
|
||||
$process_group => 'mercy',
|
||||
$process_threads => 5,
|
||||
$servername => $::fqdn,
|
||||
$rabbitmq_user => 'mercy',
|
||||
$rabbitmq_pw => 'mercy',
|
||||
$rabbitmq_vhost => 'mercy',
|
||||
$vhost_dir => '/etc/apache/httpd/conf.d',
|
||||
$apache_service => 'httpd',
|
||||
$port => 443,
|
||||
$postgres_uri => 'localhost',
|
||||
$postgres_user => 'mercy',
|
||||
$postgres_pw => 'mercy',
|
||||
$postgres_db => 'mercy'
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
12
puppet/mercy/templates/apache/vhost.erb
Normal file
12
puppet/mercy/templates/apache/vhost.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<VirtualHost * :<%= scope.lookupvar('::mercy::port') %>>
|
||||
ServerName <%= scope.lookupvar('::fqdn') %>
|
||||
WSGIDaemonProcess mercy user=<%= scope.lookupvar('::mercy::process_user') %> group=<%= scope.lookupvar('::mercy::process_group') %> threads=<%= scope.lookupvar('::mercy::process_threads') %>
|
||||
WSGIScriptAlias / /opt/mercy/scripts/mercy.wsgi
|
||||
|
||||
<Directory /opt/mercy>
|
||||
WSGIProcessGroup mercy
|
||||
WSGIApplicationGroup %{GLOBAL}
|
||||
Order deny, allow
|
||||
Allow from all
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
12
puppet/mercy/templates/apache/vhost.erb~
Normal file
12
puppet/mercy/templates/apache/vhost.erb~
Normal file
@@ -0,0 +1,12 @@
|
||||
<VirtualHost *:<%= scope.lookupvar('::mercy::params::port') %>>
|
||||
ServerName <%= scope.lookupvar('::fqdn') %>
|
||||
WSGIDaemonProcess mercy user=<%= scope.lookupvar('::mercy::params::process_user') %> group=<%= scope.lookupvar('::mercy::params::process_group') %> threads=<%= scope.lookupvar('::mercy::params::process_threads') %>
|
||||
WSGIScriptAlias / /opt/mercy/scripts/mercy.wsgi
|
||||
|
||||
<Directory /opt/mercy>
|
||||
WSGIProcessGroup mercy
|
||||
WSGIApplicationGroup %{GLOBAL}
|
||||
Order deny, allow
|
||||
Allow from all
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
49
puppet/mercy/templates/python/alembic.ini.erb
Normal file
49
puppet/mercy/templates/python/alembic.ini.erb
Normal file
@@ -0,0 +1,49 @@
|
||||
# A generic, single database configuration.
|
||||
|
||||
[alembic]
|
||||
# path to migration scripts
|
||||
script_location = /opt/mercy/alembic
|
||||
|
||||
# template used to generate migration files
|
||||
# file_template = %%(rev)s_%%(slug)s
|
||||
|
||||
# set to 'true' to run the environment during
|
||||
# the 'revision' command, regardless of autogenerate
|
||||
# revision_environment = false
|
||||
|
||||
sqlalchemy.url = postgresql://<%= scope.lookupvar('::mercy::postgres_user') %>:<%+ scope.lookupvar('::mercy::postgres_pw') %>@<%= scope.lookupvar('::mercy::postgres_uri') %>/<%= scope.lookupvar('::mercy::postgres_db') %>
|
||||
|
||||
# Logging configuration
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
handlers = console
|
||||
qualname =
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = alembic
|
||||
|
||||
[handler_console]
|
||||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
level = NOTSET
|
||||
formatter = generic
|
||||
|
||||
[formatter_generic]
|
||||
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||
datefmt = %H:%M:%S
|
||||
49
puppet/mercy/templates/python/alembic.ini.erb~
Normal file
49
puppet/mercy/templates/python/alembic.ini.erb~
Normal file
@@ -0,0 +1,49 @@
|
||||
# A generic, single database configuration.
|
||||
|
||||
[alembic]
|
||||
# path to migration scripts
|
||||
script_location = alembic
|
||||
|
||||
# template used to generate migration files
|
||||
# file_template = %%(rev)s_%%(slug)s
|
||||
|
||||
# set to 'true' to run the environment during
|
||||
# the 'revision' command, regardless of autogenerate
|
||||
# revision_environment = false
|
||||
|
||||
sqlalchemy.url = driver://mercy:mercy@postgresql.aklabs.net/mercy
|
||||
|
||||
# Logging configuration
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
handlers = console
|
||||
qualname =
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = alembic
|
||||
|
||||
[handler_console]
|
||||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
level = NOTSET
|
||||
formatter = generic
|
||||
|
||||
[formatter_generic]
|
||||
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||
datefmt = %H:%M:%S
|
||||
Reference in New Issue
Block a user