ceph-mon: move the ceph_config call to ceph-mon role
[ceph-ansible.git] / site-container.yml.sample
1 ---
2 # Defines deployment design and assigns role to server groups
3
4 - hosts:
5   - mons
6   - osds
7   - mdss
8   - rgws
9   - nfss
10   - rbdmirrors
11   - clients
12   - iscsigws
13   - mgrs
14   - monitoring
15
16   gather_facts: false
17   become: True
18   any_errors_fatal: true
19
20   vars:
21     delegate_facts_host: True
22
23   pre_tasks:
24     - import_tasks: raw_install_python.yml
25
26   tasks:
27     # pre-tasks for following import -
28     - name: gather facts
29       setup:
30         gather_subset:
31           - 'all'
32           - '!facter'
33           - '!ohai'
34       when: not delegate_facts_host | bool or inventory_hostname in groups.get(client_group_name, [])
35       tags: always
36
37     - name: gather and delegate facts
38       setup:
39         gather_subset:
40           - 'all'
41           - '!facter'
42           - '!ohai'
43       delegate_to: "{{ item }}"
44       delegate_facts: True
45       with_items: "{{ groups['all'] | difference(groups.get('clients', [])) }}"
46       run_once: true
47       when: delegate_facts_host | bool
48       tags: always
49
50     - import_role:
51         name: ceph-defaults
52
53     # dummy container setup is only supported on x86_64
54     # when running with containerized_deployment: true this task
55     # creates a group that contains only x86_64 hosts.
56     # when running with containerized_deployment: false this task
57     # will add all client hosts to the group (and not filter).
58     - name: create filtered clients group
59       add_host:
60         name: "{{ item }}"
61         groups: _filtered_clients
62       with_items: "{{ groups.get(client_group_name, []) | intersect(ansible_play_batch) }}"
63       when: (hostvars[item]['ansible_facts']['architecture'] == 'x86_64') or (not containerized_deployment | bool)
64
65       tags: [with_pkg, fetch_container_image]
66     - import_role:
67         name: ceph-facts
68     - import_role:
69         name: ceph-validate
70     - import_role:
71         name: ceph-infra
72     - import_role:
73         name: ceph-handler
74     - import_role:
75         name: ceph-container-engine
76       tags: with_pkg
77       when: (group_names != ['clients'] and group_names != ['clients', '_filtered_clients'] and group_names != ['_filtered_clients', 'clients']) or (inventory_hostname == groups.get('_filtered_clients', [''])|first)
78     - import_role:
79         name: ceph-container-common
80       tags: fetch_container_image
81       when: (group_names != ['clients'] and group_names != ['clients', '_filtered_clients'] and group_names != ['_filtered_clients', 'clients']) or (inventory_hostname == groups.get('_filtered_clients', [''])|first)
82
83 - hosts: mons
84   gather_facts: false
85   any_errors_fatal: true
86   tasks:
87     - name: set ceph monitor install 'In Progress'
88       run_once: true
89       set_stats:
90         data:
91           installer_phase_ceph_mon:
92             status: "In Progress"
93             start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
94
95 - hosts: mons
96   become: True
97   gather_facts: false
98   any_errors_fatal: true
99   tasks:
100     - import_role:
101         name: ceph-defaults
102       tags: ['ceph_update_config']
103     - import_role:
104         name: ceph-facts
105       tags: ['ceph_update_config']
106     - import_role:
107         name: ceph-handler
108       tags: ['ceph_update_config']
109     - import_role:
110         name: ceph-config
111       tags: ['ceph_update_config']
112     - import_role:
113         name: ceph-mon
114     - import_role:
115         name: ceph-mgr
116       when: groups.get(mgr_group_name, []) | length == 0
117
118 - hosts: mons
119   gather_facts: false
120   any_errors_fatal: true
121   tasks:
122     - name: set ceph monitor install 'Complete'
123       run_once: true
124       set_stats:
125         data:
126           installer_phase_ceph_mon:
127             status: "Complete"
128             end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
129
130 - hosts: mgrs
131   become: True
132   gather_facts: false
133   any_errors_fatal: true
134   tasks:
135     # pre-tasks for following imports -
136     - name: set ceph manager install 'In Progress'
137       run_once: true
138       set_stats:
139         data:
140           installer_phase_ceph_mgr:
141             status: "In Progress"
142             start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
143
144     - import_role:
145         name: ceph-defaults
146       tags: ['ceph_update_config']
147     - import_role:
148         name: ceph-facts
149       tags: ['ceph_update_config']
150     - import_role:
151         name: ceph-handler
152       tags: ['ceph_update_config']
153     - import_role:
154         name: ceph-config
155       tags: ['ceph_update_config']
156     - import_role:
157         name: ceph-mgr
158
159     # post-tasks for upcoming imports -
160     - name: set ceph manager install 'Complete'
161       run_once: true
162       set_stats:
163         data:
164           installer_phase_ceph_mgr:
165             status: "Complete"
166             end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
167
168 - hosts: osds
169   become: True
170   gather_facts: false
171   any_errors_fatal: true
172   tasks:
173     # pre-tasks for upcoming imports -
174     - name: set ceph osd install 'In Progress'
175       run_once: true
176       set_stats:
177         data:
178           installer_phase_ceph_osd:
179             status: "In Progress"
180             start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
181
182     - import_role:
183         name: ceph-defaults
184       tags: ['ceph_update_config']
185     - import_role:
186         name: ceph-facts
187       tags: ['ceph_update_config']
188     - import_role:
189         name: ceph-handler
190       tags: ['ceph_update_config']
191     - import_role:
192         name: ceph-config
193       tags: ['ceph_update_config']
194     - import_role:
195         name: ceph-osd
196
197     # post-tasks for preceding imports -
198     - name: set ceph osd install 'Complete'
199       run_once: true
200       set_stats:
201         data:
202           installer_phase_ceph_osd:
203             status: "Complete"
204             end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
205
206 - hosts: mdss
207   become: True
208   gather_facts: false
209   any_errors_fatal: true
210   tasks:
211     # pre-tasks for following imports -
212     - name: set ceph mds install 'In Progress'
213       run_once: true
214       set_stats:
215         data:
216           installer_phase_ceph_mds:
217             status: "In Progress"
218             start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
219
220     - import_role:
221         name: ceph-defaults
222       tags: ['ceph_update_config']
223     - import_role:
224         name: ceph-facts
225       tags: ['ceph_update_config']
226     - import_role:
227         name: ceph-handler
228       tags: ['ceph_update_config']
229     - import_role:
230         name: ceph-config
231       tags: ['ceph_update_config']
232     - import_role:
233         name: ceph-mds
234
235     # post-tasks for preceding imports -
236     - name: set ceph mds install 'Complete'
237       run_once: true
238       set_stats:
239         data:
240           installer_phase_ceph_mds:
241             status: "Complete"
242             end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
243
244 - hosts: rgws
245   become: True
246   gather_facts: false
247   any_errors_fatal: true
248   tasks:
249     # pre-tasks for following imports -
250     - name: set ceph rgw install 'In Progress'
251       run_once: true
252       set_stats:
253         data:
254           installer_phase_ceph_rgw:
255             status: "In Progress"
256             start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
257
258     - import_role:
259         name: ceph-defaults
260       tags: ['ceph_update_config']
261     - import_role:
262         name: ceph-facts
263       tags: ['ceph_update_config']
264     - import_role:
265         name: ceph-handler
266       tags: ['ceph_update_config']
267     - import_role:
268         name: ceph-config
269       tags: ['ceph_update_config']
270     - import_role:
271         name: ceph-rgw
272
273     # post-tasks for preceding imports -
274     - name: set ceph rgw install 'Complete'
275       run_once: true
276       set_stats:
277         data:
278           installer_phase_ceph_rgw:
279             status: "Complete"
280             end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
281
282 - hosts: clients
283   become: True
284   gather_facts: false
285   any_errors_fatal: true
286   tags: 'ceph_client'
287   tasks:
288     # pre-tasks for following imports -
289     - name: set ceph client install 'In Progress'
290       run_once: true
291       set_stats:
292         data:
293           installer_phase_ceph_client:
294             status: "In Progress"
295             start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
296
297     - import_role:
298         name: ceph-defaults
299       tags: ['ceph_update_config']
300     - import_role:
301         name: ceph-facts
302       tags: ['ceph_update_config']
303     - import_role:
304         name: ceph-handler
305       tags: ['ceph_update_config']
306     - import_role:
307         name: ceph-config
308       tags: ['ceph_update_config']
309     - import_role:
310         name: ceph-client
311
312     # post-tasks for preceding imports -
313     - name: set ceph client install 'Complete'
314       run_once: true
315       set_stats:
316         data:
317           installer_phase_ceph_client:
318             status: "Complete"
319             end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
320
321 - hosts: nfss
322   become: True
323   gather_facts: false
324   any_errors_fatal: true
325   tasks:
326     # pre-tasks for following imports -
327     - name: set ceph nfs install 'In Progress'
328       run_once: true
329       set_stats:
330         data:
331           installer_phase_ceph_nfs:
332             status: "In Progress"
333             start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
334
335     - import_role:
336         name: ceph-defaults
337       tags: ['ceph_update_config']
338     - import_role:
339         name: ceph-facts
340       tags: ['ceph_update_config']
341     - import_role:
342         name: ceph-handler
343       tags: ['ceph_update_config']
344     - import_role:
345         name: ceph-config
346       tags: ['ceph_update_config']
347     - import_role:
348         name: ceph-nfs
349
350     # post-tasks for following imports -
351     - name: set ceph nfs install 'Complete'
352       run_once: true
353       set_stats:
354         data:
355           installer_phase_ceph_nfs:
356             status: "Complete"
357             end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
358
359 - hosts: rbdmirrors
360   become: True
361   gather_facts: false
362   any_errors_fatal: true
363   tasks:
364     # pre-tasks for following imports -
365     - name: set ceph rbd mirror install 'In Progress'
366       run_once: true
367       set_stats:
368         data:
369           installer_phase_ceph_rbdmirror:
370             status: "In Progress"
371             start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
372
373     - import_role:
374         name: ceph-defaults
375       tags: ['ceph_update_config']
376     - import_role:
377         name: ceph-facts
378       tags: ['ceph_update_config']
379     - import_role:
380         name: ceph-handler
381       tags: ['ceph_update_config']
382     - import_role:
383         name: ceph-config
384       tags: ['ceph_update_config']
385     - import_role:
386         name: ceph-rbd-mirror
387
388     # post-tasks for preceding imports -
389     - name: set ceph rbd mirror install 'Complete'
390       run_once: true
391       set_stats:
392         data:
393           installer_phase_ceph_rbdmirror:
394             status: "Complete"
395             end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
396
397 - hosts:
398     - iscsigws
399   gather_facts: false
400   any_errors_fatal: true
401   become: True
402   tasks:
403     # pre-tasks for following imports -
404     - name: set ceph iscsi gateway install 'In Progress'
405       run_once: true
406       set_stats:
407         data:
408           installer_phase_ceph_iscsi_gw:
409             status: "In Progress"
410             start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
411
412     - import_role:
413         name: ceph-defaults
414       tags: ['ceph_update_config']
415     - import_role:
416         name: ceph-facts
417       tags: ['ceph_update_config']
418     - import_role:
419         name: ceph-handler
420       tags: ['ceph_update_config']
421     - import_role:
422         name: ceph-config
423       tags: ['ceph_update_config']
424     - import_role:
425         name: ceph-iscsi-gw
426
427     # post-tasks for preceding imports -
428   post_tasks:
429     - name: set ceph iscsi gw install 'Complete'
430       run_once: true
431       set_stats:
432         data:
433           installer_phase_ceph_iscsi_gw:
434             status: "Complete"
435             end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
436
437 - import_playbook: dashboard.yml
438   when:
439     - dashboard_enabled | bool
440     - groups.get(monitoring_group_name, []) | length > 0
441
442 - hosts:
443   - mons
444   - osds
445   - mdss
446   - rgws
447   - rbdmirrors
448   - mgrs
449
450   gather_facts: false
451   become: True
452   any_errors_fatal: true
453
454   tasks:
455     - import_role:
456         name: ceph-defaults
457     - import_role:
458         name: ceph-facts
459         tasks_from: container_binary.yml
460     - import_role:
461         name: ceph-handler
462     - import_role:
463         name: ceph-crash
464
465
466 - hosts: mons
467   gather_facts: false
468   become: True
469   any_errors_fatal: true
470   tasks:
471     - import_role:
472         name: ceph-defaults
473
474     - name: check if podman binary is present
475       stat:
476         path: /usr/bin/podman
477       register: podman_binary
478
479     - name: set_fact container_binary
480       set_fact:
481         container_binary: "{{ 'podman' if (podman_binary.stat.exists and ansible_facts['distribution'] == 'Fedora') or (ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '8') else 'docker' }}"
482
483     - name: get ceph status from the first monitor
484       command: >
485         {{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_facts']['hostname'] }} ceph --cluster {{ cluster }} -s
486       register: ceph_status
487       changed_when: false
488       delegate_to: "{{ groups[mon_group_name][0] }}"
489       run_once: true
490
491     - name: "show ceph status for cluster {{ cluster }}"
492       debug:
493         msg: "{{ ceph_status.stdout_lines }}"
494       delegate_to: "{{ groups[mon_group_name][0] }}"
495       run_once: true
496       when: not ceph_status.failed