instance-runner-import.cfg.in 6.46 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 18
  runner-sshd-add-authorized-key
  runner-sshd-graceful
  runner-sshd-promise
19
  runner-sshkeys-authority
20
  runner-sshkeys-authority-service
21
  runner-sshkeys-sshd
22
  runner-sshkeys-sshd-service
23
  runtestsuite
24
  shellinabox
25
  shellinabox-service
26
  symlinks
27
  slapos-cfg
28
  cron-entry-prepare-software
29
  deploy-instance-parameters
30
  instance-software-type
31
  bash-profile
32
  supervisord-wrapper
33
  importer-consistency-promise
34
  software-release-deployment-promise
35 36

  resilient-software-release-information
37
# have to repeat the next one, as it's not inherited from pbsready-import
38
  import-on-notification
39

40 41
  monitor-base

42 43 44 45 46 47
[directory]
recipe = slapos.cookbook:mkdirectory
# XXX - keep srv path with slash at the end.
srv = ${:home}/srv/


48 49 50 51
# 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.
52 53 54 55
[proxy-free-port]
recipe = slapos.cookbook:free_port
minimum = 49990
maximum = 49999
56
ip = ${slap-network-information:local-ipv4}
57 58 59 60 61

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

64
[slaprunner]
65 66
proxy_port = ${proxy-free-port:port}
runner_port = ${runner-free-port:port}
67 68 69 70 71

[supervisord-free-port]
recipe = slapos.cookbook:free_port
minimum = 39996
maximum = 40005
72
ip = ${slaprunner:ipv4}
73 74

[supervisord]
75
port = ${supervisord-free-port:port}
76

77 78 79
[runner-sshd-port]
minimum = 22232
maximum = 22241
80

81 82 83 84 85
# Deactivate the call to prepareSoftware, and let the importer script
# handle the build&run of the instance.
[cron-entry-prepare-software]
recipe =

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

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

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

158 159
[resilient-software-release-information]
recipe = slapos.recipe.template
160 161 162
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}
163 164
mode = 0600

165 166
[slap-parameter]
auto-deploy-instance = false
167
auto-deploy = true
168

169
[resilient-publish-connection-parameter]
170 171 172 173
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}
174

175 176
[monitor-instance-parameter]
monitor-httpd-port = 8360
177 178 179 180 181 182 183 184
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 -%}
185
instance-configuration =
186 187 188
  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
189 190

[monitor-conf-parameters]
191
private-path-list +=
192
  $${logrotate-directory:logrotate-backup}
193 194 195 196 197 198

[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}
199
mode = 0700