1 #############################
3 # Deploy hello-world instance
5 #############################
7 # Now we are going how to add new parts, using new recipes
9 #############################
14 publish-connection-parameter
15 # Don't forget to include the new part ! It will also call [template-get] in software.cfg
18 # Define egg directories to be the one from Software Release
21 eggs-directory = ${buildout:eggs-directory}
22 develop-eggs-directory = ${buildout:develop-eggs-directory}
27 # Fetch arbitrary parameters defined by the user in SlapOS Master for his instance.
28 # We use the slapconfiguration recipe with a few parameters (partition id,
29 # computer id, certificate, etc).
30 # It will then authenticate to SlapOS Master and fetch the instance parameters.
31 # The parameters are accessible from $${instance-parameter:configuration.name-of-parameter}
32 # Always the same. Just copy/paste.
33 # See docstring of slapos.cookbook:slapconfiguration for more informations.
34 recipe = slapos.cookbook:slapconfiguration
35 computer = $${slap_connection:computer_id}
36 partition = $${slap_connection:partition_id}
37 url = $${slap_connection:server_url}
38 key = $${slap_connection:key_file}
39 cert = $${slap_connection:cert_file}
41 # Define default parameter(s) that will be used later, in case user didn't
43 # All possible parameters should have a default.
44 # In our use case, we are expecting from the user to specify one (optional) parameter: "name". We put the default value here if he doesn't specify it, so that it doesn't crash.
45 configuration.name = John Doe
46 # Here is the declaration of the default value for the parameter title (actually, it is void). If commented, the recipe will crash.
47 # The first part of the name paramater ("configuration.") means that the value can be manually defined thanks to the parameters of the instance
49 # If our use case requires that the user can specify a mail address so that his instance can mail to him (for example), we can do:
50 # configuration.mail-address =
51 # If the user doesn't specify it, it won't break and the recipe can handle it (i.e don't send any mail for example).
54 # Create all needed directories, depending on your needs
56 recipe = slapos.cookbook:mkdirectory
57 home = $${buildout:directory}
60 # Creation of the folder wich will contain the jinja template
61 data-fold = $${:home}/srv/data
62 # Executables put here will be started but not monitored (for startup scripts)
63 script = $${:etc}/run/
64 # Executables put here will be started and monitored (for daemons)
65 service = $${:etc}/service
66 # Executables put here will be launched after buildout has completed to see
67 # if instance is running
68 promise = $${:etc}/promise/
69 # Path of the log directory used by our service (see [hello-world])
73 # It is now time for Jinja !
75 recipe = slapos.recipe.template:jinja2
76 # We could also define the template inline.
78 # ----------------------------------
80 # ----------------------------------
82 # the value of template will be replaced thanks to the information given in software.cfg, during its own buildout
83 template = ${template-get:location}/${template-get:filename}
84 # Here we can declare where we want to get the new file rendered by Jinja
85 rendered = $${directory:data-fold}/data1.txt
87 # In the context we can define the specific values wich will be substituted in the template
88 # key mean that the value is to get in another section of this buildout config file. Go to http://git.erp5.org/gitweb/slapos.recipe.template.git/blob/HEAD:/slapos/recipe/template/README.jinja2.txt?js=1 for more information
90 key name instance-parameter:configuration.name
91 key title instance-parameter:configuration.title
94 # Create a simple shell script that will only output your name if you
95 # specified it as instance parameter.
96 # Usually, of course, we use more useful commands, like web servers.
98 # This recipe will try to "exec" the command-line after separating parameters.
99 recipe = slapos.cookbook:wrapper
100 # Notice that there is only one $ at ${dash:location}, it is because it comes from the Software Release buildout profile.
101 command-line = ${dash:location}/bin/dash -c 'echo "Hello $${instance-parameter:configuration.name}, it is $(date)." > $${directory:log}/log.log; sleep 1000000;'
102 # Put this shell script in the "etc/service" directory. Every executable of this
103 # repository will be started and monitored by supervisord. If one service
104 # exits/crashes, it will trigger a "bang" and cause run of slapgrid for the
106 wrapper-path = $${directory:service}/hello-world
109 # Publish all the parameters needed for the user to connect to the instance.
110 # It can be anything: URL(s), password(s), or arbitrary parameters.
111 # Here we'll just echo back the entered name as instance parameter
112 [publish-connection-parameter]
113 recipe = slapos.cookbook:publish
114 name = Hello $${instance-parameter:configuration.name}!
115 # Adds the published parameter "title".
116 title = $${instance-parameter:configuration.title}
117 path = $${template-creation:rendered}