Commit e712c04f authored by Marco Mariani's avatar Marco Mariani

made lapp stack independent from maarch; comments

parent 3d0141f7
...@@ -34,14 +34,16 @@ import os ...@@ -34,14 +34,16 @@ import os
import lxml import lxml
# TODO: remove the hack below, used to reach psycopg2
# XXX: When run inside webrunner, Postgres refuses connection. # XXX: When run inside webrunner, Postgres refuses connection.
# TODO: make the recipe work inside webrunner # TODO: make the recipe work inside webrunner
# XXX What follows is a crud hack to import psycopg2.
# It basically relies on the fact that lxml (required by slapos.core) is installed
# alongside with psycopg2.
# This should be rewritten (how?) and DOES NOT WORK WHEN DEVELOPING slapos.core.
def temporary_hack(): def temporary_hack():
# XXX TODO provide psycopg to sys.path by other means
import sys import sys
develop_eggs = '/'.join(lxml.__file__.split('/')[:lxml.__file__.split('/').index('develop-eggs')+1]) develop_eggs = '/'.join(lxml.__file__.split('/')[:lxml.__file__.split('/').index('develop-eggs')+1])
for egg_folder in os.listdir(develop_eggs): for egg_folder in os.listdir(develop_eggs):
......
...@@ -12,27 +12,57 @@ parts = ...@@ -12,27 +12,57 @@ parts =
template-apache-php template-apache-php
#----------------
#--
#-- Main application part
#-- XXX provide a better URL
[application] [application]
url = http://downloads.sourceforge.net/project/maarch/Maarch%20Entreprise/MaarchEntreprise-1.3.zip?r=http%3A%2F%2Fwww.maarch.org%2Ftelecharger&ts=1347961624&use_mirror=ignum url = http://downloads.sourceforge.net/project/maarch/Maarch%20Entreprise/MaarchEntreprise-1.3.zip?r=http%3A%2F%2Fwww.maarch.org%2Ftelecharger&ts=1347961624&use_mirror=ignum
md5sum = 5c2c859dee9d0dde3ba959474fd5fc86 md5sum = 5c2c859dee9d0dde3ba959474fd5fc86
#----------------
#--
#-- We don't need this static configuration file.
#-- An empty file is provided because it is required by the lapp stack.
#--
[application-template] [application-template]
# XXX we don't need this
recipe = slapos.recipe.download recipe = slapos.recipe.download
url = ${:_profile_base_location_}/config.php.in url = ${:_profile_base_location_}/config.php.in
#md5sum = md5sum = d41d8cd98f00b204e9800998ecf8427e
download-only = True download-only = True
filename = template.in filename = template.in
mode = 0644 mode = 0644
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
[application-configuration] [application-configuration]
# XXX we don't need this
location = config.php location = config.php
#----------------
#--
#-- Define parts that will be executed later, in the instance.
#--
[custom-application-deployment]
path = ${custom-application-deployment-template:output}
part-list = maarch-configuration
[custom-application-deployment-template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-custom.cfg.in
output = ${buildout:directory}/instance-custom.cfg
md5sum = f132fcb57297ad9b10c07f97023b5ff4
mode = 0644
#----------------
#--
#-- Install PHP channels and modules (only if they are not already installed).
#--
[pear-modules] [pear-modules]
recipe = cp.recipe.cmd recipe = cp.recipe.cmd
pear = ${apache-php-postgres:location}/bin/pear pear = ${apache-php-postgres:location}/bin/pear
...@@ -41,3 +71,6 @@ install_cmd = ...@@ -41,3 +71,6 @@ install_cmd =
${:pear} info maarch/CLITools-0.3.1 >/dev/null || ${:pear} install maarch/CLITools-0.3.1 ${:pear} info maarch/CLITools-0.3.1 >/dev/null || ${:pear} install maarch/CLITools-0.3.1
${:pear} info MIME_Type >/dev/null || ${:pear} install MIME_Type ${:pear} info MIME_Type >/dev/null || ${:pear} install MIME_Type
#----------------
[buildout] [buildout]
extends = ${custom-application-deployment:path}
parts = parts =
certificate-authority certificate-authority
...@@ -14,14 +15,17 @@ parts = ...@@ -14,14 +15,17 @@ parts =
frontend-promise frontend-promise
content-promise content-promise
publish-connection-informations publish-connection-informations
maarch-instance ${custom-application-deployment:part-list}
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true offline = true
# Creation of all needed directories #----------------
#--
#-- Creation of all needed directories.
[rootdirectory] [rootdirectory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/ etc = $${buildout:directory}/etc/
...@@ -60,7 +64,10 @@ newcerts = $${directory:ca-dir}/newcerts/ ...@@ -60,7 +64,10 @@ newcerts = $${directory:ca-dir}/newcerts/
crl = $${directory:ca-dir}/crl/ crl = $${directory:ca-dir}/crl/
# Deploy stunnel #----------------
#--
#-- Deploy stunnel.
[stunnel] [stunnel]
recipe = slapos.cookbook:stunnel recipe = slapos.cookbook:stunnel
client = true client = true
...@@ -78,7 +85,10 @@ wrapper = $${rootdirectory:bin}/raw_stunnel ...@@ -78,7 +85,10 @@ wrapper = $${rootdirectory:bin}/raw_stunnel
post-rotate-script = $${rootdirectory:bin}/stunnel_post_rotate post-rotate-script = $${rootdirectory:bin}/stunnel_post_rotate
# Certificate stuffs #----------------
#--
#-- Certificate stuff.
[certificate-authority] [certificate-authority]
recipe = slapos.cookbook:certificate_authority recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl openssl-binary = ${openssl:location}/bin/openssl
...@@ -99,7 +109,10 @@ key-file = $${stunnel:key-file} ...@@ -99,7 +109,10 @@ key-file = $${stunnel:key-file}
cert-file = $${stunnel:cert-file} cert-file = $${stunnel:cert-file}
# Request Postgres instance and parse its URL #----------------
#--
#-- Request Postgres instance and parse its URL.
[request-postgres] [request-postgres]
<= slap-connection <= slap-connection
recipe = slapos.cookbook:request recipe = slapos.cookbook:request
...@@ -115,7 +128,11 @@ recipe = slapos.cookbook:urlparse ...@@ -115,7 +128,11 @@ recipe = slapos.cookbook:urlparse
url = $${request-postgres:connection-url} url = $${request-postgres:connection-url}
# Deploy Apache + PHP application #----------------
#--
#-- Deploy Apache + PHP application.
#-- Despite the names of mysql-* parameters, they are not really specific to mysql.
[apache-php] [apache-php]
recipe = slapos.cookbook:apachephp recipe = slapos.cookbook:apachephp
source = ${application:location} source = ${application:location}
...@@ -144,7 +161,10 @@ mysql-host = $${stunnel:local-host} ...@@ -144,7 +161,10 @@ mysql-host = $${stunnel:local-host}
mysql-port = $${stunnel:local-port} mysql-port = $${stunnel:local-port}
# Deploy logrotate, cron, configure it #----------------
#--
#-- Deploy logrotate, cron, configure it.
[logrotate] [logrotate]
recipe = slapos.cookbook:logrotate recipe = slapos.cookbook:logrotate
# Binaries # Binaries
...@@ -202,7 +222,10 @@ frequency = 0 0 * * * ...@@ -202,7 +222,10 @@ frequency = 0 0 * * *
command = $${logrotate:wrapper} command = $${logrotate:wrapper}
# Request frontend #----------------
#--
#-- Request frontend.
[request-frontend] [request-frontend]
<= slap-connection <= slap-connection
recipe = slapos.cookbook:requestoptional recipe = slapos.cookbook:requestoptional
...@@ -216,7 +239,10 @@ return = site_url ...@@ -216,7 +239,10 @@ return = site_url
config-custom_domain = $${slap-parameter:domain} config-custom_domain = $${slap-parameter:domain}
# Deploy slapmonitor #----------------
#--
#-- Deploy slapmonitor.
[slapmonitor] [slapmonitor]
recipe = slapos.cookbook:slapmonitor recipe = slapos.cookbook:slapmonitor
pid-file = $${basedirectory:run}/apache.pid pid-file = $${basedirectory:run}/apache.pid
...@@ -239,14 +265,20 @@ slapreport-path = ${buildout:bin-directory}/slapreport ...@@ -239,14 +265,20 @@ slapreport-path = ${buildout:bin-directory}/slapreport
path = $${basedirectory:services}/slapreport path = $${basedirectory:services}/slapreport
# Publish all instance parameters (url of instance) #----------------
#--
#-- Publish all instance parameters (url of instance).
[publish-connection-informations] [publish-connection-informations]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
backend_url = $${apache-php:url} backend_url = $${apache-php:url}
url = $${request-frontend:connection-site_url} url = $${request-frontend:connection-site_url}
# Deploy promises scripts #----------------
#--
#-- Deploy promises scripts.
[promise] [promise]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
path = $${basedirectory:promises}/apache path = $${basedirectory:promises}/apache
...@@ -267,6 +299,9 @@ url = $${request-frontend:connection-site_url} ...@@ -267,6 +299,9 @@ url = $${request-frontend:connection-site_url}
dash_path = ${dash:location}/bin/dash dash_path = ${dash:location}/bin/dash
curl_path = ${curl:location}/bin/curl curl_path = ${curl:location}/bin/curl
[slap-parameter] [slap-parameter]
# Default value if no domain is specified # Default value if no domain is specified
domain = domain =
...@@ -276,15 +311,3 @@ logbox-port = ...@@ -276,15 +311,3 @@ logbox-port =
logbox-user = logbox-user =
logbox-passwd = logbox-passwd =
[maarch-instance]
recipe = slapos.cookbook:maarch.configuration
htdocs = $${apache-php:htdocs}
db_host = $${postgres-urlparse:host}
db_port = $${postgres-urlparse:port}
db_dbname = $${postgres-urlparse:path}
db_username = $${postgres-urlparse:username}
db_password = $${postgres-urlparse:password}
language = en
php_ini_dir = $${directory:php-ini-dir}
root_docservers = $${buildout:directory}/srv/docservers
...@@ -7,7 +7,6 @@ parts = ...@@ -7,7 +7,6 @@ parts =
template-apache-php template-apache-php
template-postgres template-postgres
extends = extends =
../../component/apache/buildout.cfg ../../component/apache/buildout.cfg
../../component/apache-php/buildout.cfg ../../component/apache-php/buildout.cfg
...@@ -21,12 +20,6 @@ extends = ...@@ -21,12 +20,6 @@ extends =
../slapos.cfg ../slapos.cfg
[application]
recipe = hexagonit.recipe.download
strip-top-level-dir = true
[eggs] [eggs]
recipe = zc.recipe.egg recipe = zc.recipe.egg
eggs = eggs =
...@@ -36,31 +29,42 @@ eggs = ...@@ -36,31 +29,42 @@ eggs =
cns.recipe.symlink cns.recipe.symlink
#----------------
#-- Application-specific part (maarch, etc.)
[application]
recipe = hexagonit.recipe.download
strip-top-level-dir = true
#----------------
#-- Instance-level buildout profiles.
[template] [template]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
#md5sum = md5sum = fad4fe349039b9bac5f95322af1b8f5a
mode = 0644 mode = 0644
[template-apache-php] [template-apache-php]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/apache/instance-apache-php.cfg.in url = ${:_profile_base_location_}/apache/instance-apache-php.cfg.in
output = ${buildout:directory}/template-apache-php.cfg output = ${buildout:directory}/template-apache-php.cfg
#md5sum = md5sum = 6519eb4bb8a7e7b554fe482cc4c01c5b
mode = 0644 mode = 0644
[template-postgres] [template-postgres]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/postgres/instance-postgres.cfg.in url = ${:_profile_base_location_}/postgres/instance-postgres.cfg.in
output = ${buildout:directory}/template-postgres.cfg output = ${buildout:directory}/template-postgres.cfg
#md5sum = md5sum = ef659916da2ed5e5d886e07fac3c8ef4
mode = 0644 mode = 0644
# Dummy parts in case no application configuration file is needed #----------------
#-- Dummy parts in case no application configuration file is needed
[application-template] [application-template]
filename = filename =
location = location =
...@@ -68,6 +72,10 @@ location = ...@@ -68,6 +72,10 @@ location =
[application-configuration] [application-configuration]
location = location =
#----------------
#-- Postgres driver for Python recipes.
[psycopg2-env] [psycopg2-env]
PATH = ${postgresql:location}/bin:%(PATH)s PATH = ${postgresql:location}/bin:%(PATH)s
...@@ -85,3 +93,18 @@ rpath = ...@@ -85,3 +93,18 @@ rpath =
${postgresql:location}/lib ${postgresql:location}/lib
#----------------
#--
#-- Optional part allowing applications using this stack to run a custom
#-- instance.cfg at the end of Apache/PHP instance deployment.
#-- To use it in your application, just override those two parameters, like:
[custom-application-deployment]
# path = /path/to/instance-custom.cfg
# part-list = part1 part2
# See software/maarch/software.cfg for an example.
path =
part-list =
#----------------
...@@ -13,8 +13,11 @@ develop-eggs-directory = ${buildout:develop-eggs-directory} ...@@ -13,8 +13,11 @@ develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true offline = true
#----------------
#--
#-- Fetches parameters defined in SlapOS Master for this instance
[instance-parameters] [instance-parameters]
# Fetches parameters defined in SlapOS Master for this instance
recipe = slapos.cookbook:slapconfiguration recipe = slapos.cookbook:slapconfiguration
computer = $${slap-connection:computer-id} computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id} partition = $${slap-connection:partition-id}
...@@ -23,21 +26,9 @@ key = $${slap-connection:key-file} ...@@ -23,21 +26,9 @@ key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file} cert = $${slap-connection:cert-file}
[cron] #----------------
recipe = slapos.cookbook:cron #--
dcrond-binary = ${dcron:location}/sbin/crond #-- Creation of all needed directories.
cron-entries = $${directory:cron-entries}
crontabs = $${directory:crontabs}
cronstamps = $${directory:cronstamps}
catcher = $${cron-simplelogger:wrapper}
binary = $${basedirectory:services}/crond
[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
wrapper = $${rootdirectory:bin}/cron_simplelogger
log = $${basedirectory:log}/crond.log
[rootdirectory] [rootdirectory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
...@@ -60,14 +51,30 @@ crontabs = $${rootdirectory:etc}/crontabs/ ...@@ -60,14 +51,30 @@ crontabs = $${rootdirectory:etc}/crontabs/
cronstamps = $${rootdirectory:etc}/cronstamps/ cronstamps = $${rootdirectory:etc}/cronstamps/
[symlinks] #----------------
recipe = cns.recipe.symlink #--
symlink_target = $${rootdirectory:bin} #-- Cron
symlink_base = ${postgresql:location}/bin
[cron]
recipe = slapos.cookbook:cron
dcrond-binary = ${dcron:location}/sbin/crond
cron-entries = $${directory:cron-entries}
crontabs = $${directory:crontabs}
cronstamps = $${directory:cronstamps}
catcher = $${cron-simplelogger:wrapper}
binary = $${basedirectory:services}/crond
[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
wrapper = $${rootdirectory:bin}/cron_simplelogger
log = $${basedirectory:log}/crond.log
#----------------
#--
#-- Creates a Postgres cluster, configuration files, and a database.
[postgres-instance] [postgres-instance]
# create cluster, configuration files and a database
recipe = slapos.cookbook:postgres recipe = slapos.cookbook:postgres
# Options # Options
...@@ -83,7 +90,20 @@ bin = $${rootdirectory:bin} ...@@ -83,7 +90,20 @@ bin = $${rootdirectory:bin}
dependency-symlinks = $${symlinks:recipe} dependency-symlinks = $${symlinks:recipe}
# Deploy promises scripts #----------------
#--
#-- Creates symlinks from the instance to the software release.
[symlinks]
recipe = cns.recipe.symlink
symlink_target = $${rootdirectory:bin}
symlink_base = ${postgresql:location}/bin
#----------------
#--
#-- Deploy promise scripts.
[postgres-promise] [postgres-promise]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
path = $${basedirectory:promises}/postgres path = $${basedirectory:promises}/postgres
...@@ -91,6 +111,10 @@ hostname = $${slap-network-information:global-ipv6} ...@@ -91,6 +111,10 @@ hostname = $${slap-network-information:global-ipv6}
port = $${postgres-instance:port} port = $${postgres-instance:port}
#----------------
#--
#-- Publish instance URL.
[urls] [urls]
recipe = slapos.cookbook:publishurl recipe = slapos.cookbook:publishurl
url = $${postgres-instance:url} url = $${postgres-instance:url}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment