4b23bec8dea49ef6c8cabf60dda914500d753ea0
[slapos.git] / software / helloworld / instance.cfg.in
1 #############################
2 #
3 # Deploy hello-world instance
4 #
5 #############################
6 #
7 # Now we are going how to add new parts, using new recipes
8 #
9 #############################
10 [buildout]
11 parts =
12   directory
13   hello-world
14   publish-connection-parameter
15 # Don't forget to include the new part ! It will also call [template-get] in software.cfg
16   template-creation
17
18 # Define egg directories to be the one from Software Release
19 # (/opt/slapgrid/...)
20 # Always the same.
21 eggs-directory = ${buildout:eggs-directory}
22 develop-eggs-directory = ${buildout:develop-eggs-directory}
23 offline = true
24
25
26 [instance-parameter]
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}
40
41 # Define default parameter(s) that will be used later, in case user didn't
42 # specify it.
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
48 configuration.title = 
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).
52
53
54 # Create all needed directories, depending on your needs
55 [directory]
56 recipe = slapos.cookbook:mkdirectory
57 home = $${buildout:directory}
58 etc = $${:home}/etc
59 var = $${:home}/var
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])
70 log = $${:var}/log
71
72
73 # It is now time for Jinja !
74 [template-creation]
75 recipe = slapos.recipe.template:jinja2
76 # We could also define the template inline.
77 #template = inline:
78 #  ----------------------------------
79 #  Title : {{title}}
80 #  ----------------------------------
81 #  Hello {{name}}
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
86 mode = 700
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
89 context =
90   key name instance-parameter:configuration.name
91   key title instance-parameter:configuration.title
92
93
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.
97 [hello-world]
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
105 # instance.
106 wrapper-path = $${directory:service}/hello-world
107
108
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}