Set missing parameters in resilient requests.
[slapos.git] / stack / resilient / template-replicated.cfg.in
1 {% macro replicate(namebase, nbbackup, typeexport, typeimport, heriteLeader='', heriteBackup='') %}
2
3 ## Tells the Backupable recipe that we want a backup
4 [resilient]
5 recipe = slapos.cookbook:request
6 config-namebase = {{namebase}}
7 software-url = ${slap-connection:software-release-url}
8
9 ## Every request is double to provide the 3 IPs.
10 [request-{{namebase}}]
11 <= resilient
12    slap-connection
13    {{heriteLeader}}
14 software-type = {{typeexport}}
15 name = {{namebase}}0
16 return = url ssh-public-key ssh-url notification-id ip
17
18 config = number authorized-key notify ip-list namebase
19 config-number = 0
20 config-authorized-key = {% for id in range(1,nbbackup|int) %} ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}{% endfor %}
21 config-notify = {% for id in range(1,nbbackup|int) %} ${request-pbs-{{namebase}}-{{id}}:connection-notification-url}{% endfor %}
22 config-ip-list =
23
24 {% for id in range(1,nbbackup|int) %}
25
26 [request-{{namebase}}-pseudo-replicating-{{id}}]
27 <= slap-connection
28    resilient
29    {{heriteBackup}}
30 recipe = slapos.cookbook:request
31 name = {{namebase}}{{id}}
32
33 software-url = ${slap-connection:software-release-url}
34 software-type = {{typeimport}}
35 return = url ssh-public-key ssh-url notification-url ip
36
37 pbs-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-push
38
39 config = number authorized-key on-notification ip-list namebase
40 config-number = {{id}}
41 config-authorized-key = ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}
42 config-on-notification = ${request-pbs-{{namebase}}-{{id}}:connection-feeds-url}${:pbs-notification-id}
43 config-ip-list =
44
45 {% endfor %}
46
47 [iplist]
48 config-ip-list = ${request-{{namebase}}:connection-ip}{% for j in range(1,nbbackup|int) %} ${request-{{namebase}}-pseudo-replicating-{{j}}:connection-ip}{% endfor %}
49
50 [request-{{namebase}}-2]
51 <= resilient
52    slap-connection
53    iplist
54    {{heriteLeader}}
55
56 recipe = slapos.cookbook:request
57 name = {{namebase}}0
58
59 software-url = ${slap-connection:software-release-url}
60 software-type = {{typeexport}}
61 return = url ssh-public-key ssh-url notification-id ip
62
63 config = number authorized-key notify ip-list namebase
64 config-number = 0
65 config-authorized-key = {% for id in range(1,nbbackup|int) %} ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}{% endfor %}
66 config-notify = {% for id in range(1,nbbackup|int) %} ${request-pbs-{{namebase}}-{{id}}:connection-notification-url}{% endfor %}
67
68 {% for id in range(1,nbbackup|int) %}
69 [request-{{namebase}}-pseudo-replicating-{{id}}-2]
70 <= slap-connection
71    resilient
72    iplist
73    {{heriteBackup}}
74
75 recipe = slapos.cookbook:request
76 name = {{namebase}}{{id}}
77
78 software-url = ${slap-connection:software-release-url}
79 software-type = {{typeimport}}
80 return = url ssh-public-key ssh-url notification-url
81
82 pbs-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-push
83
84 config = number authorized-key on-notification ip-list namebase
85 config-number = {{id}}
86 config-authorized-key = ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}
87 config-on-notification = ${request-pbs-{{namebase}}-{{id}}:connection-feeds-url}${:pbs-notification-id}
88
89 {% endfor %}
90
91
92
93 ## The PBS and their push / pull slaves
94 ## Adding a PBS provides resiliency
95 ## Adding a backup server provides availability
96
97 ## Having 3 backups pulling from the same PBS provides
98 ##only availability, not resiliency
99
100 ## WARNING : SLAVES ARE ALLOCATED AT RANDOM, THIS NEEDS TO BE FIXED.
101
102 [request-pbs-common]
103 <= slap-connection
104 recipe = slapos.cookbook:request
105 software-url = ${slap-connection:software-release-url}
106 software-type = pull-backup
107
108 {% for id in range(1,nbbackup|int) %}
109
110 [request-pbs-{{namebase}}-{{id}}]
111 <= request-pbs-common
112 name = PBS ({{namebase}} / {{id}})
113 return = ssh-key notification-url feeds-url
114 slave = false
115
116 [request-pull-backup-server-{{namebase}}-{{id}}]
117 <= request-pbs-common
118 name = PBS {{id}} pulling from ${request-{{namebase}}:name}
119 config = url name type server-key on-notification notify notification-id title
120 config-url = ${request-{{namebase}}:connection-ssh-url}
121 config-name = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-{{id}}
122 config-type = pull
123 config-server-key = ${request-{{namebase}}:connection-ssh-public-key}
124 config-on-notification = ${request-{{namebase}}:connection-notification-id}
125 config-notify = ${request-pbs-{{namebase}}-{{id}}:connection-notification-url}
126 config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-{{id}}-pull
127 config-title = Pulling from {{namebase}}
128 slave = true
129 sla = instance_guid
130 sla-instance_guid = ${request-pbs-{{namebase}}-{{id}}:instance_guid}
131
132 [request-pull-backup-server-{{namebase}}-backup-{{id}}]
133 <= request-pbs-common
134 name = PBS pushing on ${request-{{namebase}}-pseudo-replicating-{{id}}:name}
135 config = url name type server-key on-notification notify notification-id title
136 config-url = ${request-{{namebase}}-pseudo-replicating-{{id}}:connection-ssh-url}
137 config-name = ${request-pull-backup-server-{{namebase}}-{{id}}:config-name}
138 config-type = push
139 config-server-key = ${request-{{namebase}}-pseudo-replicating-{{id}}:connection-ssh-public-key}
140 config-on-notification = ${request-pbs-{{namebase}}-{{id}}:connection-feeds-url}${request-pull-backup-server-{{namebase}}-{{id}}:config-notification-id}
141 config-notify = ${request-{{namebase}}-pseudo-replicating-{{id}}:connection-notification-url}
142 config-notification-id = ${request-{{namebase}}-pseudo-replicating-{{id}}:pbs-notification-id}
143 config-title = Pushing to {{namebase}} backup {{id}}
144 slave = true
145 sla = instance_guid
146 sla-instance_guid = ${request-pbs-{{namebase}}-{{id}}:instance_guid}
147 {% endfor %}
148
149 {% endmacro %}