-
Notifications
You must be signed in to change notification settings - Fork 10
/
cephadm.yml
219 lines (192 loc) · 5.66 KB
/
cephadm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Copyright (C) 2020 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.---
- name: import configurations
import_playbook: settings.yml
- name: preconfigure linodes
import_playbook: pre-config.yml
- hosts: mons mgrs osds mdss grafana-servers
become: yes
tasks:
- name: setup mon-000 ssh key
delegate_to: mon-000
run_once: true
community.crypto.openssh_keypair:
path: /root/.ssh/id_ed25519
type: ed25519
comment: mon-000
register: cephadm_key
- name: register cephadm.id-ed25519 with hosts
lineinfile:
path: /root/.ssh/authorized_keys
line: "{{ cephadm_key.public_key }}"
- hosts: mons clients
become: yes
tasks:
- name: fetch cephadm
become: no
delegate_to: localhost
register: cephadm
run_once: true
uri:
force: yes
mode: 0755
return_content: yes
url: "https://download.ceph.com/rpm-{{ RELEASE }}/el9/noarch/cephadm"
- name: distribute cephadm
copy:
dest: /root/cephadm
group: root
mode: 0755
owner: root
content: "{{ cephadm.content }}"
- hosts: mons
become: yes
tasks:
- name: build cephadm spec
delegate_to: mon-000
throttle: 1
blockinfile:
create: true
state: present
insertafter: EOF
dest: /root/cluster.spec
marker_begin: "BEGIN {{ inventory_hostname }}"
marker_end: "END {{ inventory_hostname }}"
content: |
service_type: host
hostname: {{ inventory_hostname }}
addr: {{ ansible_ssh_host }}
labels:
- {{ ceph_group }}
- _admin
---
- hosts: mgrs osds mdss grafana-servers
become: yes
tasks:
- name: build cephadm spec
delegate_to: mon-000
throttle: 1
blockinfile:
create: true
state: present
insertafter: EOF
dest: /root/cluster.spec
marker_begin: "BEGIN {{ inventory_hostname }}"
marker_end: "END {{ inventory_hostname }}"
content: |
service_type: host
hostname: {{ inventory_hostname }}
addr: {{ ansible_ssh_host }}
labels:
- {{ ceph_group }}
---
- hosts: mon-000
become: yes
tasks:
- name: set mon placement in spec
blockinfile:
state: present
insertafter: EOF
dest: /root/cluster.spec
marker_begin: "BEGIN mon spec"
marker_end: "END mon spec"
content: |
service_type: mon
placement:
label: mons
---
- name: set mgr placement in spec
blockinfile:
state: present
insertafter: EOF
dest: /root/cluster.spec
marker_begin: "BEGIN mgr spec"
marker_end: "END mgr spec"
content: |
service_type: mgr
placement:
label: mgrs
---
- name: set osd placement in spec
blockinfile:
state: present
insertafter: EOF
dest: /root/cluster.spec
marker_begin: "BEGIN osd spec"
marker_end: "END osd spec"
content: |
service_id: default
service_type: osd
placement:
label: osds
data_devices:
paths:
- /dev/sdc
---
- name: set mds placement in spec
blockinfile:
state: present
insertafter: EOF
dest: /root/cluster.spec
marker_begin: "BEGIN mds spec"
marker_end: "END mds spec"
content: |
service_id: all
service_type: mds
placement:
label: mdss
---
- name: "add {{ RELEASE }} repos"
shell: "/root/cephadm add-repo {{ CEPHADM_REPO }}"
- name: "install {{ RELEASE }}"
shell: "/root/cephadm install ceph-common"
- name: check ceph already bootstrapped
stat:
path: /etc/ceph/ceph.conf
register: ceph_installed
- name: "cephadm bootstrap"
shell: "/root/cephadm bootstrap --mon-ip {{ monitor_address }} --ssh-private-key /root/.ssh/id_ed25519 --ssh-public-key /root/.ssh/id_ed25519.pub --apply-spec /root/cluster.spec"
when: not ceph_installed.stat.exists
- name: config public network
shell: ceph config set global public_network 192.168.0.0/16
- name: config cluster_network
shell: ceph config set global cluster_network 192.168.0.0/16
- name: log to files
shell: ceph config set global log_to_file true
- name: log cluster to file
shell: ceph config set global mon_cluster_log_to_file true
- name: disable stderr logging
shell: ceph config set global log_to_stderr false
- name: disable stderr logging of cluster log
shell: ceph config set global mon_cluster_log_to_stderr false
- hosts: clients
become: yes
tasks:
- name: "add {{ RELEASE }} repos"
shell: "/root/cephadm add-repo {{ CEPHADM_REPO }}"
- name: "install {{ RELEASE }}"
shell: "/root/cephadm install ceph-common ceph-fuse"
- name: generate min config
shell: ceph config generate-minimal-conf
delegate_to: mon-000
register: minimal_config
run_once: true
- name: setup config
copy:
# yay ansible bug: https://github.com/ansible/ansible/issues/6077
content: "{{ minimal_config.stdout }}\n"
dest: /etc/ceph/ceph.conf
owner: root
group: root
mode: 0644