-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-n-storage-setup.yml
184 lines (154 loc) · 3.58 KB
/
docker-n-storage-setup.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
---
- hosts:
- nodes
vars:
docker_device: sdc
tasks:
- name: Install docker
yum:
name: docker
state: present
- name: docker-storage-setup (remove overlay2)
lineinfile:
path: /etc/sysconfig/docker-storage-setup
regexp: overlay2
state: absent
tags:
- storage-setup
- name: docker-storage-setup (add DEV=vdb)
lineinfile:
path: /etc/sysconfig/docker-storage-setup
regexp: DEVS
line: DEVS={{ docker_device }}
tags:
- storage-setup
- name: docker-storage-setup (add VG=dockervg)
lineinfile:
path: /etc/sysconfig/docker-storage-setup
regexp: VG=
line: VG=dockervg
tags:
- storage-setup
- name: docker-storage-setup (add WIPE_SIGNATURES=true)
lineinfile:
path: /etc/sysconfig/docker-storage-setup
regexp: WIPE_SIGNATURES
line: WIPE_SIGNATURES=true
tags:
- storage-setup
- hosts:
- masters
vars:
etcd_device: /dev/sdd
gather_facts: no
tasks:
- name: Install lvm2
yum:
name: lvm2
state: present
- name: Create PV and LV on "{{ etcd_device }}"
lvg:
vg: etcd-vg
pvs: "{{ etcd_device }}"
state: present
- name: Create LV etcd-lv
lvol:
vg: etcd-vg
lv: etcd-lv
size: 100%VG
state: present
- name: Mkfs xfs on etcd-lv
filesystem:
fstype: xfs
dev: /dev/mapper/etcd--vg-etcd--lv
- name: Make /var/lib/etcd
file:
path: /var/lib/etcd
state: directory
- name: Update fstab
lineinfile:
path: /etc/fstab
regexp: etcd
line: '/dev/mapper/etcd--vg-etcd--lv /var/lib/etcd xfs defaults 0 0'
- name: Remove origin fstab entry
lineinfile:
path: /etc/fstab
regexp: origin
line: '/dev/mapper/origin--vg-origin--lv /var/lib/origin xfs defaults 0 0'
state: absent
- name: Mount filesystem
shell: 'mount -a'
- hosts:
- nodes
vars:
origin_device: /dev/sde
gather_facts: no
tasks:
- name: Install lvm2
yum:
name: lvm2
state: present
- name: Create PV and LV on "{{ origin_device }}"
lvg:
vg: origin-vg
pvs: "{{ origin_device }}"
state: present
- name: Create LV origin-lv
lvol:
vg: origin-vg
lv: origin-lv
size: 100%VG
state: present
- name: Mkfs xfs on origin-lv
filesystem:
fstype: xfs
dev: /dev/mapper/origin--vg-origin--lv
- name: Make /var/lib/origin
file:
path: /var/lib/origin
state: directory
- name: Update fstab
lineinfile:
path: /etc/fstab
regexp: origin
line: '/dev/mapper/origin--vg-origin--lv /var/lib/origin xfs defaults 0 0'
- name: Mount filesystem
shell: 'mount -a'
- hosts:
- nodes
gather_facts: no
tasks:
- name: Make sure docker is stopped
systemd:
name: docker
state: stopped
- name: Make sure docker storage is stopped
systemd:
name: docker
state: stopped
- name: Stop docker mount
systemd:
name: var-lib-docker-containers.mount
state: stopped
ignore_errors: true
- name: Remove /etc/sysconfig/docker-storage
file:
path: /etc/sysconfig/docker-storage
state: absent
- name: Remove /var/lib/docker
file:
path: /var/lib/docker
state: absent
- name: Remove the logical volume.
lvol:
vg: dockervg
lv: docker-pool
state: absent
force: yes
- name: Run container-storage-setup
command: "container-storage-setup"
- name: Start and enable docker
systemd:
name: docker.service
state: started
enabled: yes