instance.cfg 16.9 KB
Newer Older
1 2
[buildout]
parts =
3
  directory
4
  configtest
5
  logrotate
6 7 8 9 10
  cron
  cron-entry-logrotate
  ca-frontend
  certificate-authority
  squid-cache
11
  logrotate-entry-apache
12 13
  logrotate-entry-apache-cached
  logrotate-entry-squid
14 15
  apache-frontend
  apache-cached
16
  switch-softwaretype
17 18
  frontend-apache-graceful
  cached-apache-graceful
19
  squid-reload
20 21
  dynamic-template-default-vh
  not-found-html
22 23 24 25 26 27
  promise-apache-frontend-v4-https
  promise-apache-frontend-v4-http
  promise-apache-frontend-v6-https
  promise-apache-frontend-v6-http
  promise-apache-cached
  promise-squid
28
  publish-apache-information
29 30 31 32

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}

33 34 35
# Create all needed directories
[directory]
recipe = slapos.cookbook:mkdirectory
36 37

bin = $${buildout:directory}/bin/
38 39
etc = $${buildout:directory}/etc/
srv = $${buildout:directory}/srv/
40
var = $${buildout:directory}/var/
41
template = $${buildout:directory}/template/
42 43 44 45

backup = $${:srv}/backup
log = $${:var}/log
run = $${:var}/run
46
service = $${:etc}/service
47
promise = $${:etc}/promise
48

49 50 51
logrotate-backup = $${:backup}/logrotate
logrotate-entries = $${:etc}/logrotate.d

52 53 54 55 56 57
cron-entries = $${:etc}/cron.d
crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
ca-dir = $${:srv}/ssl

squid-cache = $${:srv}/squid_cache
58

59 60
[switch-softwaretype]
recipe = slapos.cookbook:softwaretype
61 62 63
default = $${dynamic-default-template-slave-list:rendered}
custom-personal = $${dynamic-custom-personal-template-slave-list:rendered}
custom-group = $${dynamic-custom-group-template-slave-list:rendered}
64 65 66 67

[instance-parameter]
# Fetches parameters defined in SlapOS Master for this instance.
# Always the same.
68
recipe = slapos.cookbook:slapconfiguration.serialised
69 70 71 72 73 74 75 76 77 78
computer = $${slap_connection:computer_id}
partition = $${slap_connection:partition_id}
url = $${slap_connection:server_url}
key = $${slap_connection:key_file}
cert = $${slap_connection:cert_file}
# Define default parameter(s) that will be used later, in case user didn't
# specify it
# All parameters are available through the configuration.XX syntax.
# All possible parameters should have a default.
configuration.domain = "example.org"
79
configuration.public-ipv4 = ''
80
configuration.port = 4443
81 82
configuration.plain_http_port = 8080
configuration.server-admin = admin@example.com
83 84
configuration.apache_custom_https = ""
configuration.apache_custom_http = ""
85 86 87 88 89 90 91 92 93 94 95 96

[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
rendered = $${buildout:directory}/$${:filename}
extra-context =
context =
    key eggs_directory buildout:eggs-directory
    key develop_eggs_directory buildout:develop-eggs-directory
    key slap_software_type instance-parameter:slap-software-type
    key slapparameter_dict instance-parameter:configuration
    $${:extra-context}

97 98 99 100 101 102 103 104 105
[dynamic-template-default-vh]
< = jinja2-template-base
template = ${template-default-virtualhost:target}
rendered = $${apache-directory:slave-configuration}/000.conf
extensions = jinja2.ext.do
extra-context =
    key http_port instance-parameter:configuration.plain_http_port
    key https_port instance-parameter:configuration.port

106
[dynamic-custom-personal-template-slave-list]
107 108
< = jinja2-template-base
template = ${template-slave-list:target}
109
filename = custom-personal-instance-slave-list.cfg
110 111 112 113 114
extensions = jinja2.ext.do
extra-context =
    key apache_configuration_directory apache-directory:slave-configuration
    key http_port instance-parameter:configuration.plain_http_port
    key https_port instance-parameter:configuration.port
115
    key public_ipv4 instance-parameter:configuration.public-ipv4
116 117
    key slave_instance_list instance-parameter:slave-instance-list
    key rewrite_cached_configuration apache-configuration:cached-rewrite-file
118
    key custom_ssl_directory apache-directory:vh-ssl
119
    key apache_log_directory apache-directory:slave-log
120
    raw empty_template ${template-empty:target}
121 122 123 124
    raw cache_access http://$${instance-parameter:ipv4-random}:$${apache-configuration:cache-port}
    raw template_slave_configuration ${template-slave-configuration:target}
    raw template_rewrite_cached ${template-rewrite-cached:target}

125
[dynamic-custom-group-template-slave-list]
126 127
< = jinja2-template-base
template = ${template-custom-slave-list:target}
128
filename = custom-group-instance-slave-list.cfg
129 130 131 132 133 134
extensions = jinja2.ext.do
extra-context =
    key apache_configuration_directory apache-directory:slave-configuration
    key domain instance-parameter:configuration.domain
    key http_port instance-parameter:configuration.plain_http_port
    key https_port instance-parameter:configuration.port
135
    key public_ipv4 instance-parameter:configuration.public-ipv4
136 137 138 139
    key slave_instance_list instance-parameter:slave-instance-list
    key rewrite_cached_configuration apache-configuration:cached-rewrite-file
    key custom_ssl_directory apache-directory:vh-ssl
    key template_slave_configuration dynamic-virtualhost-template-slave:rendered
140 141 142 143 144 145 146 147
    key apache_log_directory apache-directory:slave-log
    raw empty_template ${template-empty:target}
    raw cache_access http://$${instance-parameter:ipv4-random}:$${apache-configuration:cache-port}
    raw template_rewrite_cached ${template-rewrite-cached:target}

[dynamic-default-template-slave-list]
< = jinja2-template-base
template = ${template-custom-slave-list:target}
148
filename = default-instance-slave-list.cfg
149 150 151 152 153 154 155 156 157 158 159 160
extensions = jinja2.ext.do
extra-context =
    key apache_configuration_directory apache-directory:slave-configuration
    key domain instance-parameter:configuration.domain
    key http_port instance-parameter:configuration.plain_http_port
    key https_port instance-parameter:configuration.port
    key public_ipv4 instance-parameter:configuration.public-ipv4
    key slave_instance_list instance-parameter:slave-instance-list
    key rewrite_cached_configuration apache-configuration:cached-rewrite-file
    key custom_ssl_directory apache-directory:vh-ssl
    key apache_log_directory apache-directory:slave-log
    raw template_slave_configuration ${template-default-slave-virtualhost:target}
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
    raw empty_template ${template-empty:target}
    raw cache_access http://$${instance-parameter:ipv4-random}:$${apache-configuration:cache-port}
    raw template_rewrite_cached ${template-rewrite-cached:target}

[dynamic-virtualhost-template-slave]
<= jinja2-template-base
template = ${template-slave-configuration:target}
rendered = $${directory:template}/slave-virtualhost.conf.in
extensions = jinja2.ext.do
extra-context =
    key https_port instance-parameter:configuration.port
    key http_port instance-parameter:configuration.plain_http_port
    key apache_custom_https instance-parameter:configuration.apache_custom_https
    key apache_custom_http instance-parameter:configuration.apache_custom_http

176 177 178 179 180 181 182 183
# Deploy Apache Frontend (new way, no recipe, jinja power)
[dynamic-apache-frontend-template]
< = jinja2-template-base
template = ${template-apache-frontend-configuration:target}
rendered = $${apache-configuration:frontend-configuration}
extra-context =
    raw httpd_home ${apache-2.2:location}
    key httpd_mod_ssl_cache_directory apache-directory:mod-ssl
184
    key domain instance-parameter:configuration.domain
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
    key document_root apache-directory:document-root
    key instance_home buildout:directory
    key ipv4_addr instance-parameter:ipv4-random
    key ipv6_addr instance-parameter:ipv6-random
    key http_port instance-parameter:configuration.plain_http_port
    key https_port instance-parameter:configuration.port
    key server_admin instance-parameter:configuration.server-admin
    key protected_path apache-configuration:protected-path
    key access_control_string apache-configuration:access-control-string
    key login_certificate ca-frontend:cert-file
    key login_key ca-frontend:key-file
    key ca_dir  certificate-authority:ca-dir
    key ca_crl certificate-authority:ca-crl
    key access_log apache-configuration:access-log
    key error_log apache-configuration:error-log
    key pid_file apache-configuration:pid-file
    key slave_configuration_directory apache-directory:slave-configuration

[apache-frontend]
recipe = slapos.cookbook:wrapper
command-line = ${apache-2.2:location}/bin/httpd -f $${dynamic-apache-frontend-template:rendered} -DFOREGROUND
wrapper-path = $${directory:service}/frontend_apache
wait-for-files =
	       $${ca-frontend:cert-file}
	       $${ca-frontend:key-file}

# Deploy Apache for cached website
[dynamic-apache-cached-template]
< = jinja2-template-base
template = ${template-apache-cached-configuration:target}
rendered = $${apache-configuration:cached-configuration}
extra-context =
    raw httpd_home ${apache-2.2:location}
    key httpd_mod_ssl_cache_directory apache-directory:mod-ssl
219
    key domain instance-parameter:configuration.domain
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
    key document_root apache-directory:document-root
    key instance_home buildout:directory
    key ipv4_addr instance-parameter:ipv4-random
    key cached_port apache-configuration:cache-through-port
    key server_admin instance-parameter:configuration.server-admin
    key protected_path apache-configuration:protected-path
    key access_control_string apache-configuration:access-control-string
    key login_certificate ca-frontend:cert-file
    key login_key ca-frontend:key-file
    key ca_dir  certificate-authority:ca-dir
    key ca_crl certificate-authority:ca-crl
    key access_log apache-configuration:cache-access-log
    key error_log apache-configuration:cache-error-log
    key pid_file apache-configuration:cache-pid-file
    key apachecachedmap_path apache-configuration:cached-rewrite-file

[apache-cached]
recipe = slapos.cookbook:wrapper
command-line = ${apache-2.2:location}/bin/httpd -f $${dynamic-apache-cached-template:rendered} -DFOREGROUND
wrapper-path = $${directory:service}/frontend_cached_apache
wait-for-files =
	       $${ca-frontend:cert-file}
	       $${ca-frontend:key-file}

244 245 246 247 248 249
[not-found-html]
recipe = slapos.cookbook:symbolic.link
target-directory = $${apache-directory:document-root}
link-binary =
	    ${template-not-found-html:target}

250 251 252 253 254 255
[apache-directory]
recipe = slapos.cookbook:mkdirectory
document-root = $${directory:srv}/htdocs
slave-configuration = $${directory:srv}/apache-slave-conf.d/
cache = $${directory:var}/cache
mod-ssl = $${:cache}/httpd_mod_ssl
256
vh-ssl = $${:slave-configuration}/ssl
257
slave-log = $${directory:log}/httpd
258 259 260 261

[apache-configuration]
frontend-configuration = $${directory:etc}/apache_frontend.conf
cached-configuration = $${directory:etc}/apache_frontend_cached.conf
262 263 264
access-log = $${directory:log}/frontend-apache-access.log
error-log = $${directory:log}/frontend-apache-error.log
pid-file = $${directory:run}/httpd.pid
265 266 267 268 269
protected-path = /
access-control-string = none
cached-rewrite-file = $${directory:etc}/apache_rewrite_cached.txt

# Apache for cache configuration
270 271 272
cache-access-log = $${directory:log}/frontend-apache-access-cached.log
cache-error-log = $${directory:log}/frontend-apache-error-cached.log
cache-pid-file = $${directory:run}/httpd-cached.pid
273

274 275 276 277
# Comunication with squid
cache-port = 26010
cache-through-port = 26011

278 279 280 281 282
[publish-apache-information]
recipe = slapos.cookbook:publish
public-ipv4 = $${instance-parameter:configuration.public-ipv4}
private-ipv4 = $${instance-parameter:ipv4-random}
domain = $${instance-parameter:configuration.domain}
283 284 285 286

# Create wrapper for "apachectl conftest" in bin
[configtest]
recipe = slapos.cookbook:wrapper
287
command-line = ${apache-2.2:location}/bin/httpd -f $${directory:etc}/apache_frontend.conf -t
288 289
wrapper-path = $${directory:bin}/apache-configtest

290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
[certificate-authority]
recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl
ca-dir = $${directory:ca-dir}
requests-directory = $${cadirectory:requests}
wrapper = $${directory:service}/certificate_authority
ca-private = $${cadirectory:private}
ca-certs = $${cadirectory:certs}
ca-newcerts = $${cadirectory:newcerts}
ca-crl = $${cadirectory:crl}

[cadirectory]
recipe = slapos.cookbook:mkdirectory
requests = $${directory:ca-dir}/requests/
private = $${directory:ca-dir}/private/
certs = $${directory:ca-dir}/certs/
newcerts = $${directory:ca-dir}/newcerts/
crl = $${directory:ca-dir}/crl/

309 310 311 312 313 314 315 316 317
[ca-frontend]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
key-file = $${cadirectory:certs}/apache_frontend.key
cert-file = $${cadirectory:certs}/apache_frontend.crt
executable = $${directory:service}/frontend_apache
wrapper = $${directory:service}/frontend_apache
# Put domain name
name = $${instance-parameter:configuration.domain}
318

319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
[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 = $${directory:service}/crond

[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
wrapper = $${directory:bin}/cron_simplelogger
log = $${directory:log}/cron.log

[cron-entry-logrotate]
<= cron
recipe = slapos.cookbook:cron.d
name = logrotate
frequency = 0 0 * * *
command = $${logrotate:wrapper}
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357

# Deploy Logrotate
[logrotate]
recipe = slapos.cookbook:logrotate
# Binaries
logrotate-binary = ${logrotate:location}/usr/sbin/logrotate
gzip-binary = ${gzip:location}/bin/gzip
gunzip-binary = ${gzip:location}/bin/gunzip
# Directories
wrapper = $${directory:bin}/logrotate
conf = $${directory:etc}/logrotate.conf
logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup}
state-file = $${directory:srv}/logrotate.status

[logrotate-entry-apache]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = apache
358
log = $${apache-directory:slave-log}/*_log $${apache-configuration:error-log} $${apache-configuration:access-log}
359
frequency = daily
360
rotatep-num = 30
361
post = ${buildout:bin-directory}/killpidfromfile $${apache-configuration:pid-file} SIGUSR1
362 363 364
sharedscripts = true
notifempty = true
create = true
365

366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
[logrotate-entry-apache-cached]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = apache-cached
log = $${apache-configuration:cache-error-log} $${apache-configuration:cache-access-log}
frequency = daily
rotatep-num = 30
post = ${buildout:bin-directory}/killpidfromfile $${apache-configuration:cache-pid-file} SIGUSR1
sharedscripts = true
notifempty = true
create = true

[logrotate-entry-squid]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = squid
log = $${squid-cache:cache-log-path} $${squid-cache:access-log-path}
frequency = daily
rotatep-num = 30
post = ${buildout:bin-directory}/killpidfromfile $${apache-configuration:pid-file} SIGHUP
sharedscripts = true
notifempty = true
create = true

390 391
[squid-cache]
recipe = slapos.cookbook:squid
392 393
prepare-path = $${directory:service}/squid-prepare
wrapper-path = $${directory:service}/squid
394
binary-path = ${squid:location}/sbin/squid
395 396
conf-path = $${directory:etc}/squid.cfg
cache-path = $${directory:squid-cache}
397 398 399 400
ip = $${instance-parameter:ipv4-random}
port = $${apache-configuration:cache-port}
backend-ip = $${instance-parameter:ipv4-random}
backend-port = $${apache-configuration:cache-through-port}
401
public-ipv4 = $${instance-parameter:configuration.public-ipv4}
402 403 404
access-log-path = $${directory:log}/squid-access.log
cache-log-path = $${directory:log}/squid-cache.log
pid-filename-path = $${directory:run}/squid.pid
405 406 407 408 409 410 411 412 413

[squid-reload]
recipe = slapos.cookbook:wrapper
command-line = ${buildout:bin-directory}/killpidfromfile $${squid-cache:pid-filename-path} SIGHUP
wrapper-path = $${directory:service}/squid-reload

[frontend-apache-graceful]
recipe = slapos.cookbook:wrapper
command-line = ${buildout:bin-directory}/killpidfromfile $${apache-configuration:pid-file} SIGUSR1
414
wrapper-path = $${directory:service}/frontend-apache-graceful
415 416 417 418

[cached-apache-graceful]
recipe = slapos.cookbook:wrapper
command-line = ${buildout:bin-directory}/killpidfromfile $${apache-configuration:cache-pid-file} SIGUSR1
419
wrapper-path = $${directory:service}/cached-apache-graceful
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455

[promise-apache-frontend-v4-https]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promise}/apache_frontend_ipv4_https
hostname = $${instance-parameter:ipv4-random}
port = $${instance-parameter:configuration.port}

[promise-apache-frontend-v4-http]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promise}/apache_frontend_ipv4_http
hostname = $${instance-parameter:ipv4-random}
port = $${instance-parameter:configuration.plain_http_port}

[promise-apache-frontend-v6-https]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promise}/apache_frontend_ipv6_https
hostname = $${instance-parameter:ipv6-random}
port = $${instance-parameter:configuration.port}

[promise-apache-frontend-v6-http]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promise}/apache_frontend_ipv6_http
hostname = $${instance-parameter:ipv6-random}
port = $${instance-parameter:configuration.plain_http_port}

[promise-apache-cached]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promise}/apache_cached
hostname = $${instance-parameter:ipv4-random}
port = $${apache-configuration:cache-through-port}

[promise-squid]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promise}/squid
hostname = $${instance-parameter:ipv4-random}
port = $${apache-configuration:cache-port}