-
Notifications
You must be signed in to change notification settings - Fork 10
/
pre-config.yml
174 lines (145 loc) · 4.94 KB
/
pre-config.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
# 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/>.
# This playbook does some basic pre-configuration of the Linodes prior to Ceph installation. In particular, it:
#
# - updates packages
# - sets up log rotation
# - configures the core dump location for easy retrieval via other ansible playbooks
# - tries to wipe the /dev/sdc device on OSDs (only works if the OSD is down);
# this is necessary after nuking the cluster as Linode does not wipe the disks
# immediately after deletion.
---
- hosts: all
become: yes
tasks:
- name: set hostname
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
- name: create hosts from inventory
become: no
shell: ./misc/generate-hosts.py linodes
register: etchosts
run_once: true
delegate_to: localhost
- name: add to /etc/hosts
blockinfile:
block: "{{ etchosts.stdout }}"
path: /etc/hosts
- name: add to /etc/hosts
blockinfile:
block: "{{ etchosts.stdout }}"
path: /etc/hosts
ignore_errors: yes
run_once: true
delegate_to: localhost
# coredump capture setup
- name: create crash directory
file:
path: /crash
state: directory
owner: root
group: root
mode: 1777
- name: set core_pattern
sysctl:
name: kernel.core_pattern
value: /crash/%e-%h-%p-%t.core
- name: add DefaultLimitCORE=infinity
lineinfile:
path: /etc/systemd/system.conf
line: DefaultLimitCORE=infinity
register: coreline
- name: reexec systemd
shell: systemctl daemon-reexec
when: coreline.changed
- name: enable epel-release
yum:
name: "epel-release"
state: latest
update_cache: yes
- name: update packages
yum:
name: "*"
state: latest
update_cache: yes
# package setup
# - logrotate needs psmisc for killall
# - ceph-ansible needs EPEL but also needs ca-certificates installed to avoid some errors, do this now
- name: install launcher packages
yum:
name: logrotate,psmisc,ca-certificates,python3,chrony,podman,lvm2
state: latest
# log rotation setup
- name: copy ceph-logrotate.timer
copy: src=ceph-log-rotate.timer dest=/etc/systemd/system/ owner=root group=root mode=644
- name: copy ceph-logrotate.service
copy: src=ceph-log-rotate.service dest=/etc/systemd/system/ owner=root group=root mode=644
- name: copy ceph logrotate config
copy: src=ceph.logrotate dest=/etc/logrotate.d/ceph owner=root group=root mode=644
# Ideally we would use the ceph-logrotate.timer but systemd has a bug requiring cron
- name: copy crontab
copy: src=crontab dest=/root/ owner=root group=root mode=644
- name: register crontab
shell: crontab crontab
- name: enable ntp
systemd:
enabled: yes
name: chronyd
state: started
- hosts: mdss
become: yes
tasks:
- name: check for mds logrotate config
local_action: stat path="ceph-mds.logrotate"
register: ceph_mds_logrotate
become: false
- name: copy ceph mds logrotate config
copy: src=ceph-mds.logrotate dest=/etc/logrotate.d/ceph owner=root group=root mode=644
when: ceph_mds_logrotate.stat.exists
- hosts: osds
become: yes
tasks:
# This cleans up after a nuke operation (disks are not wiped)
# This will fail if the lvm volume is busy
- name: clear old lvm volumes
shell: lvremove --yes /dev/ceph*/*
ignore_errors: yes
# This cleans up after a nuke operation (disks are not wiped)
# This will fail if the lvm volume is busy
- name: clear /dev/sdc
shell: wipefs -a /dev/sdc
ignore_errors: yes
- name: check for osd logrotate config
local_action: stat path="ceph-osd.logrotate"
register: ceph_osd_logrotate
become: false
- name: copy ceph osd logrotate config
copy: src=ceph-osd.logrotate dest=/etc/logrotate.d/ceph owner=root group=root mode=644
when: ceph_osd_logrotate.stat.exists
- hosts: mons
become: yes
tasks:
- name: check for mon logrotate config
local_action: stat path="ceph-mon.logrotate"
register: ceph_mon_logrotate
become: false
- name: copy ceph mon logrotate config
copy: src=ceph-mon.logrotate dest=/etc/logrotate.d/ceph owner=root group=root mode=644
when: ceph_mon_logrotate.stat.exists
- hosts: clients
become: yes
tasks:
- name: install nfs-utils
yum: name=nfs-utils state=latest update_cache=yes
- import_playbook: iptables.yml