-
Notifications
You must be signed in to change notification settings - Fork 1
/
openshift-workshop-step1.rb
executable file
·225 lines (203 loc) · 7.54 KB
/
openshift-workshop-step1.rb
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
220
221
222
223
224
225
#!/usr/bin/env ruby
require 'rubygems'
require 'hetzner-bootstrap'
# get your API login from Hetzner's customer panel at: https://robot.your-server.de/
# assign env variables:
# HBC_ROBOT_USER
# HBC_ROBOT_PASSWORD
#
# rbenv-tip: checkout rbenv-vars, it's awesome!
# https://github.com/sstephenson/rbenv-vars/
otmaster = Hetzner::Bootstrap.new(api: Hetzner::API.new(
ENV['HBC_ROBOT_USER'],
ENV['HBC_ROBOT_PASSWORD']
))
otnode1 = Hetzner::Bootstrap.new(api: Hetzner::API.new(
ENV['HBC_ROBOT_USER'],
ENV['HBC_ROBOT_PASSWORD']
))
otnode2 = Hetzner::Bootstrap.new(api: Hetzner::API.new(
ENV['HBC_ROBOT_USER'],
ENV['HBC_ROBOT_PASSWORD']
))
otnode3 = Hetzner::Bootstrap.new(api: Hetzner::API.new(
ENV['HBC_ROBOT_USER'],
ENV['HBC_ROBOT_PASSWORD']
))
# osnode4 = Hetzner::Bootstrap.new(api: Hetzner::API.new(
# ENV['HBC_ROBOT_USER'],
# ENV['HBC_ROBOT_PASSWORD']
# ))
# osnode5 = Hetzner::Bootstrap.new(api: Hetzner::API.new(
# ENV['HBC_ROBOT_USER'],
# ENV['HBC_ROBOT_PASSWORD']
# ))
# osnode6 = Hetzner::Bootstrap.new(api: Hetzner::API.new(
# ENV['HBC_ROBOT_USER'],
# ENV['HBC_ROBOT_PASSWORD']
# ))
template = <<EOT
DRIVE1 /dev/sda
DRIVE2 /dev/sdb
## ===============
## SOFTWARE RAID:
## ===============
## activate software RAID? < 0 | 1 >
SWRAID 1
## Choose the level for the software RAID < 0 | 1 >
SWRAIDLEVEL 0
## which bootloader should be used? < lilo | grub >
BOOTLOADER grub
HOSTNAME <%= hostname %>
## PART <mountpoint/lvm> <filesystem/VG> <size in MB>
##
## * <mountpoint/lvm> mountpoint for this filesystem *OR* keyword 'lvm'
## to use this PART as volume group (VG) for LVM
## * <filesystem/VG> can be ext2, ext3, reiserfs, xfs, swap *OR* name
## of the LVM volume group (VG), if this PART is a VG
## * <size> you can use the keyword 'all' to assign all the
## remaining space of the drive to the *last* partition.
## you can use M/G/T for unit specification in MIB/GIB/TIB
##
## notes:
## - extended partitions are created automatically
## - '/boot' cannot be on a xfs filesystem!
## - '/boot' cannot be on LVM!
## - when using software RAID 0, you need a '/boot' partition
PART /boot ext4 2G
PART lvm vg0 all
#LV <VG> <name> <mount> <filesystem> <size>
LV vg0 root / ext4 1024G
LV vg0 swap swap swap 5G
LV vg0 home /home xfs 10G
## ========================
## OPERATING SYSTEM IMAGE:
## ========================
## full path to the operating system image
## supported image sources: local dir, ftp, http, nfs
## supported image types: tar, tar.gz, tar.bz, tar.bz2, tgz, tbz
## examples:
#
# local: /path/to/image/filename.tar.gz
# ftp: ftp://<user>:<password>@hostname/path/to/image/filename.tar.bz2
# http: http://<user>:<password>@hostname/path/to/image/filename.tbz
# https: https://<user>:<password>@hostname/path/to/image/filename.tbz
# nfs: hostname:/path/to/image/filename.tgz
# Default images provided by hetzner as of October 2014:
# Archlinux-2014-64-minmal.tar.gz
# CentOS-65-32-minimal.tar.gz
# CentOS-65-64-cpanel.tar.gz
# CentOS-65-64-minimal.tar.gz
# CentOS-70-64-minimal.tar.gz
# Debian-76-wheezy-32-minimal.tar.gz
# Debian-76-wheezy-64-LAMP.tar.gz
# Debian-76-wheezy-64-minimal.tar.gz
# openSUSE-131-64-minimal.tar.gz
# Ubuntu-1204-precise-64-minimal.tar.gz
# Ubuntu-1404-trusty-64-minimal.tar.gz
IMAGE /root/.oldroot/nfs/install/../images/CentOS-74-64-minimal.tar.gz
EOT
storage_node_template = <<EOT
DRIVE1 /dev/sda
# DRIVE2 /dev/sdb
## ===============
## SOFTWARE RAID:
## ===============
## activate software RAID? < 0 | 1 >
SWRAID 0
## Choose the level for the software RAID < 0 | 1 >
# SWRAIDLEVEL 0
## which bootloader should be used? < lilo | grub >
BOOTLOADER grub
HOSTNAME <%= hostname %>
## PART <mountpoint/lvm> <filesystem/VG> <size in MB>
##
## * <mountpoint/lvm> mountpoint for this filesystem *OR* keyword 'lvm'
## to use this PART as volume group (VG) for LVM
## * <filesystem/VG> can be ext2, ext3, reiserfs, xfs, swap *OR* name
## of the LVM volume group (VG), if this PART is a VG
## * <size> you can use the keyword 'all' to assign all the
## remaining space of the drive to the *last* partition.
## you can use M/G/T for unit specification in MIB/GIB/TIB
##
## notes:
## - extended partitions are created automatically
## - '/boot' cannot be on a xfs filesystem!
## - '/boot' cannot be on LVM!
## - when using software RAID 0, you need a '/boot' partition
PART /boot ext4 2G
PART lvm vg0 all
#LV <VG> <name> <mount> <filesystem> <size>
LV vg0 root / ext4 1024G
LV vg0 swap swap swap 5G
LV vg0 home /home xfs 10G
## ========================
## OPERATING SYSTEM IMAGE:
## ========================
## full path to the operating system image
## supported image sources: local dir, ftp, http, nfs
## supported image types: tar, tar.gz, tar.bz, tar.bz2, tgz, tbz
## examples:
#
# local: /path/to/image/filename.tar.gz
# ftp: ftp://<user>:<password>@hostname/path/to/image/filename.tar.bz2
# http: http://<user>:<password>@hostname/path/to/image/filename.tbz
# https: https://<user>:<password>@hostname/path/to/image/filename.tbz
# nfs: hostname:/path/to/image/filename.tgz
# Default images provided by hetzner as of October 2014:
# Archlinux-2014-64-minmal.tar.gz
# CentOS-65-32-minimal.tar.gz
# CentOS-65-64-cpanel.tar.gz
# CentOS-65-64-minimal.tar.gz
# CentOS-70-64-minimal.tar.gz
# Debian-76-wheezy-32-minimal.tar.gz
# Debian-76-wheezy-64-LAMP.tar.gz
# Debian-76-wheezy-64-minimal.tar.gz
# openSUSE-131-64-minimal.tar.gz
# Ubuntu-1204-precise-64-minimal.tar.gz
# Ubuntu-1404-trusty-64-minimal.tar.gz
IMAGE /root/.oldroot/nfs/install/../images/CentOS-74-64-minimal.tar.gz
EOT
# the post_install hook is a great place to setup further
# software/system provisioning
#
post_install = <<EOT
# knife bootstrap <%= ip %> -N <%= hostname %> "role[base],role[kvm_host]"
EOT
# duplicate entry for each system
otmaster << { ip: '136.243.53.206',
template: template, # string will be parsed by erubis
hostname: 'otmaster', # sets hostname
public_keys: '~/.ssh/id_rsa.pub', # will be copied to your system
post_install: post_install } # will be executed *locally* at the end
otnode1 << { ip: '144.76.98.107',
template: storage_node_template, # string will be parsed by erubis
hostname: 'otnode1', # sets hostname
public_keys: '~/.ssh/id_rsa.pub', # will be copied to your system
post_install: post_install } # will be executed *locally* at the end
otnode2 << { ip: '144.76.104.83',
template: storage_node_template, # string will be parsed by erubis
hostname: 'otnode2', # sets hostname
public_keys: '~/.ssh/id_rsa.pub', # will be copied to your system
post_install: post_install } # will be executed *locally* at the end
otnode3 << { ip: '5.9.29.135',
template: storage_node_template, # string will be parsed by erubis
hostname: 'otnode3', # sets hostname
public_keys: '~/.ssh/id_rsa.pub', # will be copied to your system
post_install: post_install } # will be executed *locally* at the end
t1 = Thread.new do
otmaster.bootstrap!
end
t2 = Thread.new do
otnode1.bootstrap!
end
t3 = Thread.new do
otnode2.bootstrap!
end
t4 = Thread.new do
otnode3.bootstrap!
end
t1.join
t2.join
t3.join
t4.join