instance-runner-import.cfg.in 6.7 KB
Newer Older
1
[buildout]
2 3
extends = {{ template_runner_path }}
          {{ pbsready_import_template_path }}
4 5

parts +=
6 7 8 9
  nginx_conf
  nginx-launcher
  certificate-authority
  ca-nginx
10 11
  certificate-authority-service
  ca-nginx-service
12 13
  gunicorn-launcher
  gunicorn-graceful
14
  slaprunner-promise
15
  slaprunner-supervisord-wrapper
16 17
  runner-sshd-add-authorized-key
  runner-sshd-promise
18
  runner-sshd-service
19
  runtestsuite
20
  shellinabox
21
  shellinabox-service
22
  slapos-cfg
23
  cron-entry-prepare-software
24
  deploy-instance-parameters
25
  instance-software-type
26
  bash-profile
27
  supervisord-wrapper
28
  importer-consistency-promise
29
  software-release-deployment-promise
30
  template-slapuser-script
31 32

  resilient-software-release-information
33

34 35
  monitor-base

36 37 38 39 40 41
[directory]
recipe = slapos.cookbook:mkdirectory
# XXX - keep srv path with slash at the end.
srv = ${:home}/srv/


42 43 44 45
# For the needs of importer, we run the full slaprunner
# In case both exporter and importer (aka main instance and clone instance)
# run with the same IP (usually for testing purposes),
# run slaprunner using different ports.
46 47 48 49
[proxy-free-port]
recipe = slapos.cookbook:free_port
minimum = 49990
maximum = 49999
50
ip = ${slap-network-information:local-ipv4}
51 52 53 54 55

[runner-free-port]
recipe = slapos.cookbook:free_port
minimum = 50015
maximum = 50024
56
ip = ${slap-network-information:global-ipv6}
57

58
[slaprunner]
59 60
proxy_port = ${proxy-free-port:port}
runner_port = ${runner-free-port:port}
61 62 63 64 65

[supervisord-free-port]
recipe = slapos.cookbook:free_port
minimum = 39996
maximum = 40005
66
ip = ${slaprunner:ipv4}
67 68

[supervisord]
69
port = ${supervisord-free-port:port}
70

71 72 73
[runner-sshd-port]
minimum = 22232
maximum = 22241
74

75 76 77 78 79
# Deactivate the call to prepareSoftware, and let the importer script
# handle the build&run of the instance.
[cron-entry-prepare-software]
recipe =

80
[importer]
81
recipe = slapos.recipe.template:jinja2
82 83
template = {{ importer_script_path }}
rendered = ${directory:bin}/${slap-parameter:namebase}-importer
84
# backward compatibility for resilient stack
85
wrapper = ${:rendered}
86
mode = 700
87
restore-exit-code-file = ${directory:srv}/${:restore-exit-code-file-basename}
88
restore-exit-code-file-basename = importer-exit-code-file
89
restore-error-message-file = ${directory:srv}/${:restore-error-message-file-basename}
90
restore-error-message-file-basename = importer-error-message-file
91
resilient-log-basename = resilient.log
92
context =
93 94
  import sys sys
  import easy_install zc.buildout.easy_install
95
  key backend_url slaprunner:access-url
96 97
  key ipv4 slaprunner:ipv4
  key ipv6 slaprunner:ipv6
98
  key proxy_port slaprunner:proxy_port
99
  key instance_folder slaprunner:instance_root
100
  section directory directory
101
  section supervisord supervisord
102 103
  raw  output_log_file ${directory:log}/${:resilient-log-basename}
  raw  shell_binary {{ bash_executable_location }}
104
  raw  sqlite3_binary {{ sqlite3_executable_location }}
105 106 107
  raw  rsync_binary {{ rsync_executable_location }}
  raw  restore_exit_code_file ${:restore-exit-code-file}
  raw  restore_error_message_file ${:restore-error-message-file}
108

109
[importer-consistency-promise-bin]
110
# Test that the importer script and "after-import" subscripts
111
# are not older than 2 days (1 day + some slack), and have succeeded
112 113
recipe = collective.recipe.template
input = inline: #!/bin/sh
114 115
  EXIT_CODE_FILE="${importer:restore-exit-code-file}"
  RECENT_EXIT_CODE_FILE=$(find ${directory:srv} -maxdepth 1 -name "${importer:restore-exit-code-file-basename}" -mtime -2)
116
  RESILIENT_LOG_URL=${monitor-publish-parameters:monitor-base-url}/share/private/log/${importer:resilient-log-basename}
117
  if [ ! -f "$EXIT_CODE_FILE" ]; then
118 119 120 121 122 123
    exit 0;
  else
    if [ -z "$RECENT_EXIT_CODE_FILE" ]; then
       echo "Consistency check is too old.";
       exit 1;
    else
124 125
      if [ -f "${importer:restore-error-message-file}" ]; then
        cat ${importer:restore-error-message-file}
126
      fi
127
      echo "More information can be found here : $RESILIENT_LOG_URL";
128
      exit $(cat $EXIT_CODE_FILE);
129 130 131
    fi
  fi
  exit 1; # Something else went wrong
132
output = ${directory:bin}/importer-consistency-promise
133
mode = 755
134

135 136 137 138 139 140 141
[importer-consistency-promise]
<= monitor-promise-base
module = check_command_execute
name = importer-consistency-promise.py
config-command = ${importer-consistency-promise-bin:output}

[software-release-deployment-bin]
142 143
recipe = collective.recipe.template
input = inline: #!/bin/sh
144
  PROJECT_FILE=$(find "${directory:etc}" -maxdepth 1 -name .project)
145 146 147
  if [ -z "$PROJECT_FILE" ]; then
    exit 0;
  else
148
    INSTALLATION_FILE=$(find "${runnerdirectory:software-root}" -mindepth 2 -maxdepth 2 -name .completed)
149 150 151 152 153 154 155
    if [ -n "$INSTALLATION_FILE" ]; then
      exit 0;
    else
      exit 1;
    fi
  fi
  exit 1
156
output = ${directory:bin}/software-release-deployment-promise
157 158
mode = 755

159 160 161 162 163 164
[software-release-deployment-promise]
<= monitor-promise-base
module = check_command_execute
name = software-release-deployment-promise.py
config-command =${software-release-deployment-bin:output}

165 166
[resilient-software-release-information]
recipe = slapos.recipe.template
167 168 169
url = {{ software_release_information_template }}
output = ${directory:cgi-bin}/resilient_software_release_information.py
resilient-log-url = ${monitor-publish-parameters:monitor-base-url}/log/${importer:resilient-log-basename}
170 171
mode = 0600

172 173
[slap-parameter]
auto-deploy-instance = false
174
auto-deploy = true
175

176
[resilient-publish-connection-parameter]
177 178 179 180
monitor-base-url = ${monitor-publish-parameters:monitor-base-url}
monitor-url = ${monitor-publish-parameters:monitor-url}
monitor-user = ${monitor-publish-parameters:monitor-user}
monitor-password = ${monitor-publish-parameters:monitor-password}
181

182 183
[monitor-instance-parameter]
monitor-httpd-port = 8360
184 185 186 187 188 189 190 191
monitor-title = {{ slapparameter_dict.get('name', 'Webrunner import') }}
cors-domains = {{ slapparameter_dict.get('monitor-cors-domains', 'monitor.app.officejs.com') }}
{% if slapparameter_dict.get('monitor-username', '') -%}
username = {{ slapparameter_dict['monitor-username'] }}
{% endif -%}
{% if slapparameter_dict.get('monitor-password', '') -%}
password = {{ slapparameter_dict['monitor-password'] }}
{% endif -%}
192
instance-configuration =
193 194 195
  raw takeover-url http://[${resilient-web-takeover-httpd-configuration-file:listening-ip}]:${resilient-web-takeover-httpd-configuration-file:listening-port}/
  raw takeover-password ${resilient-web-takeover-password:passwd}
configuration-file-path = ${buildout:directory}/knowledge0.cfg
196 197

[monitor-conf-parameters]
198
private-path-list +=
199
  $${logrotate-directory:logrotate-backup}
200 201 202 203 204 205

[post-notification-run]
recipe = slapos.cookbook:wrapper
command-line = {{ software_release_bin }}/runner-importer-post-notification-run --diff-file ${:diff-file} --proof-signature-file ${:proof-signature-file} --srv-path ${directory:srv} --backup-path ${directory:backup}
wrapper-path = ${rootdirectory:bin}/post-notification-run
output = ${:wrapper-path}
206
mode = 0700