forked from rmoriz/hetzner-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.rb
executable file
·111 lines (90 loc) · 3.29 KB
/
example.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
#!/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:
# ROBOT_USER
# ROBOT_PASSWORD
#
# rbenv-tip: checkout rbenv-vars, it's awesome!
# https://github.com/sstephenson/rbenv-vars/
bs = Hetzner::Bootstrap.new(api: Hetzner::API.new(
ENV['ROBOT_USER'],
ENV['ROBOT_PASSWORD']
))
# 2 disks, software raid 1, etc.
template = <<EOT
DRIVE1 /dev/sda
DRIVE2 /dev/sdb
FORMATDRIVE2 0
## ===============
## SOFTWARE RAID:
## ===============
## activate software RAID? < 0 | 1 >
SWRAID 1
## Choose the level for the software RAID < 0 | 1 >
SWRAIDLEVEL 1
## 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 ext2 1G
PART lvm host 75G
PART lvm guest all
#LV <VG> <name> <mount> <filesystem> <size>
LV host root / ext3 50G
LV host swap swap swap 5G
## ========================
## 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/images/Ubuntu-1204-precise-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
bs << { ip: '1.2.3.4',
template: template, # string will be parsed by erubis
hostname: 'server100', # sets hostname
public_keys: '~/.ssh/id_dsa.pub', # will be copied to your system
post_install: post_install } # will be executed *locally* at the end
bs.bootstrap!