Allow to select target node for each backup/PBS instance.
[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 = 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
25 {% for id in range(1,nbbackup|int) %}
26
27 [request-{{namebase}}-pseudo-replicating-{{id}}]
28 <= slap-connection
29    resilient
30    {{heriteBackup}}
31 recipe = slapos.cookbook:request
32 name = {{namebase}}{{id}}
33
34 software-url = ${slap-connection:software-release-url}
35 software-type = {{typeimport}}
36 return = ssh-public-key ssh-url notification-url ip
37
38 pbs-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-push
39
40 config = number authorized-key on-notification ip-list namebase
41 config-number = {{id}}
42 config-authorized-key = ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}
43 config-on-notification = ${request-pbs-{{namebase}}-{{id}}:connection-feeds-url}${:pbs-notification-id}
44 config-ip-list =
45
46 sla = computer_guid
47 sla-computer_guid = ${slap-parameter:{{namebase}}{{id}}-computer-guid}
48
49
50 {% endfor %}
51
52 [iplist]
53 config-ip-list = ${request-{{namebase}}:connection-ip}{% for j in range(1,nbbackup|int) %} ${request-{{namebase}}-pseudo-replicating-{{j}}:connection-ip}{% endfor %}
54
55 [request-{{namebase}}-2]
56 <= resilient
57    slap-connection
58    iplist
59    {{heriteLeader}}
60
61 recipe = slapos.cookbook:request
62 name = {{namebase}}0
63
64 software-url = ${slap-connection:software-release-url}
65 software-type = {{typeexport}}
66 return = ssh-public-key ssh-url notification-id ip
67
68 config = number authorized-key notify ip-list namebase
69 config-number = 0
70 config-authorized-key = {% for id in range(1,nbbackup|int) %} ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}{% endfor %}
71 config-notify = {% for id in range(1,nbbackup|int) %} ${request-pbs-{{namebase}}-{{id}}:connection-notification-url}{% endfor %}
72
73
74 {% for id in range(1,nbbackup|int) %}
75 [request-{{namebase}}-pseudo-replicating-{{id}}-2]
76 <= slap-connection
77    resilient
78    iplist
79    {{heriteBackup}}
80
81 recipe = slapos.cookbook:request
82 name = {{namebase}}{{id}}
83
84 software-url = ${slap-connection:software-release-url}
85 software-type = {{typeimport}}
86 return = ssh-public-key ssh-url notification-url
87
88 pbs-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-push
89
90 config = number authorized-key on-notification ip-list namebase
91 config-number = {{id}}
92 config-authorized-key = ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}
93 config-on-notification = ${request-pbs-{{namebase}}-{{id}}:connection-feeds-url}${:pbs-notification-id}
94
95 sla = computer_guid
96 sla-computer_guid = ${slap-parameter:{{namebase}}{{id}}-computer-guid}
97
98
99 {% endfor %}
100
101
102
103 ## The PBS and their push / pull slaves
104 ## Adding a PBS provides resiliency
105 ## Adding a backup server provides availability
106
107 ## Having 3 backups pulling from the same PBS provides
108 ##only availability, not resiliency
109
110 ## WARNING : SLAVES ARE ALLOCATED AT RANDOM, THIS NEEDS TO BE FIXED.
111
112 [request-pbs-common]
113 <= slap-connection
114 recipe = slapos.cookbook:request
115 software-url = ${slap-connection:software-release-url}
116 software-type = pull-backup
117
118 {% for id in range(1,nbbackup|int) %}
119
120 [request-pbs-{{namebase}}-{{id}}]
121 <= request-pbs-common
122 name = PBS ({{namebase}} / {{id}})
123 return = ssh-key notification-url feeds-url
124 slave = false
125 sla = computer_guid
126 sla-computer_guid = ${slap-parameter:pbs-{{namebase}}{{id}}-computer-guid}
127
128 [request-pull-backup-server-{{namebase}}-{{id}}]
129 <= request-pbs-common
130 name = PBS {{id}} pulling from ${request-{{namebase}}:name}
131 config = url name type server-key on-notification notify notification-id title
132 config-url = ${request-{{namebase}}:connection-ssh-url}
133 config-name = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-{{id}}
134 config-type = pull
135 config-server-key = ${request-{{namebase}}:connection-ssh-public-key}
136 config-on-notification = ${request-{{namebase}}:connection-notification-id}
137 config-notify = ${request-pbs-{{namebase}}-{{id}}:connection-notification-url}
138 config-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-{{id}}-pull
139 config-title = Pulling from {{namebase}}
140 slave = true
141 sla = instance_guid
142 sla-instance_guid = ${request-pbs-{{namebase}}-{{id}}:instance_guid}
143
144 [request-pull-backup-server-{{namebase}}-backup-{{id}}]
145 <= request-pbs-common
146 name = PBS pushing on ${request-{{namebase}}-pseudo-replicating-{{id}}:name}
147 config = url name type server-key on-notification notify notification-id title
148 config-url = ${request-{{namebase}}-pseudo-replicating-{{id}}:connection-ssh-url}
149 config-name = ${request-pull-backup-server-{{namebase}}-{{id}}:config-name}
150 config-type = push
151 config-server-key = ${request-{{namebase}}-pseudo-replicating-{{id}}:connection-ssh-public-key}
152 config-on-notification = ${request-pbs-{{namebase}}-{{id}}:connection-feeds-url}${request-pull-backup-server-{{namebase}}-{{id}}:config-notification-id}
153 config-notify = ${request-{{namebase}}-pseudo-replicating-{{id}}:connection-notification-url}
154 config-notification-id = ${request-{{namebase}}-pseudo-replicating-{{id}}:pbs-notification-id}
155 config-title = Pushing to {{namebase}} backup {{id}}
156 slave = true
157 sla = instance_guid
158 sla-instance_guid = ${request-pbs-{{namebase}}-{{id}}:instance_guid}
159 {% endfor %}
160
161 [slap-parameter]
162 # Default parameters for distributed deployment
163 # I.e state "backup1 of maria should go there, ..."
164 {% for id in range(1,nbbackup|int) %}
165 {{namebase}}{{id}}-computer-guid =
166 pbs-{{namebase}}{{id}}-computer-guid =
167 {% endfor %}
168
169 {% endmacro %}