hetzner-bootstrap 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.rubocop.yml +21 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.md +116 -10
- data/Rakefile +2 -0
- data/example.rb +95 -96
- data/hetzner-bootstrap.gemspec +22 -16
- data/lib/hetzner-bootstrap.rb +23 -25
- data/lib/hetzner/bootstrap/target.rb +87 -86
- data/lib/hetzner/bootstrap/template.rb +7 -4
- data/lib/hetzner/bootstrap/version.rb +3 -1
- data/spec/hetzner_bootstrap_spec.rb +26 -31
- data/spec/spec_helper.rb +99 -0
- metadata +94 -52
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d36bf429c8c67652f1e5887e8f99db50574d4cc8398ea718f634dc14acac31fb
|
4
|
+
data.tar.gz: df374d346e10b4af10624878a6dc0821dc30ecd106c84920fb44c449e1a3508c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f1e5c12ee923b2798351be615267e4b76ba101fe21abf5f5ef3ef092b4a89e727ec864d051532d13b21de483c5b7c4e7f26771d9adbb0842b2e27cc5367b3bcb
|
7
|
+
data.tar.gz: 20724e0ec289640e9f40416de839f40cd8fba8a9d5eed81d42e3371afd4d856fc4fb4eb63630c5f25128c34d6c491c7dd4d2ced896acde379dc935300a72e8d9
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.0
|
3
|
+
NewCops: enable
|
4
|
+
|
5
|
+
Layout/LineLength:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Metrics/MethodLength:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Naming/FileName:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/Documentation:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Metrics/ClassLength:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Metrics/AbcSize:
|
21
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.0
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,8 @@ hetzner-bootstrap
|
|
3
3
|
|
4
4
|
hetzner-bootstrap allows you to bootstrap a provisioned EQ Server from hetzner.de
|
5
5
|
|
6
|
+
[](http://badge.fury.io/rb/hetzner-bootstrap)
|
7
|
+
|
6
8
|
What it does:
|
7
9
|
-------------
|
8
10
|
|
@@ -38,6 +40,117 @@ Example:
|
|
38
40
|
|
39
41
|
Warning: All existing data on the system will be lost!
|
40
42
|
|
43
|
+
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
|
47
|
+
#!/usr/bin/env ruby
|
48
|
+
require 'hetzner-bootstrap'
|
49
|
+
|
50
|
+
bs = Hetzner::Bootstrap.new(api: Hetzner::API.new(ENV['ROBOT_USER'], ENV['ROBOT_PASSWORD']))
|
51
|
+
|
52
|
+
template = <<EOT
|
53
|
+
# see https://github.com/hetzneronline/installimage/
|
54
|
+
DRIVE1 /dev/sda
|
55
|
+
DRIVE2 /dev/sdb
|
56
|
+
|
57
|
+
## activate software RAID? < 0 | 1 >
|
58
|
+
SWRAID 1
|
59
|
+
|
60
|
+
## Choose the level for the software RAID < 0 | 1 >
|
61
|
+
SWRAIDLEVEL 1
|
62
|
+
|
63
|
+
## which bootloader should be used? < lilo | grub >
|
64
|
+
BOOTLOADER grub
|
65
|
+
|
66
|
+
HOSTNAME <%= hostname %>
|
67
|
+
|
68
|
+
## PART <mountpoint/lvm> <filesystem/VG> <size in MB>
|
69
|
+
##
|
70
|
+
## * <mountpoint/lvm> mountpoint for this filesystem *OR* keyword 'lvm'
|
71
|
+
## to use this PART as volume group (VG) for LVM
|
72
|
+
## * <filesystem/VG> can be ext2, ext3, reiserfs, xfs, swap *OR* name
|
73
|
+
## of the LVM volume group (VG), if this PART is a VG
|
74
|
+
## * <size> you can use the keyword 'all' to assign all the
|
75
|
+
## remaining space of the drive to the *last* partition.
|
76
|
+
## you can use M/G/T for unit specification in MIB/GIB/TIB
|
77
|
+
##
|
78
|
+
## notes:
|
79
|
+
## - extended partitions are created automatically
|
80
|
+
## - '/boot' cannot be on a xfs filesystem!
|
81
|
+
## - '/boot' cannot be on LVM!
|
82
|
+
## - when using software RAID 0, you need a '/boot' partition
|
83
|
+
|
84
|
+
PART /boot ext3 1G
|
85
|
+
PART lvm host 75G
|
86
|
+
PART lvm guest all
|
87
|
+
|
88
|
+
#LV <VG> <name> <mount> <filesystem> <size>
|
89
|
+
LV host root / ext4 50G
|
90
|
+
LV host swap swap swap 5G
|
91
|
+
|
92
|
+
|
93
|
+
## ========================
|
94
|
+
## OPERATING SYSTEM IMAGE:
|
95
|
+
## ========================
|
96
|
+
|
97
|
+
## full path to the operating system image
|
98
|
+
## supported image sources: local dir, ftp, http, nfs
|
99
|
+
## supported image types: tar, tar.gz, tar.bz, tar.bz2, tgz, tbz
|
100
|
+
## examples:
|
101
|
+
#
|
102
|
+
# local: /path/to/image/filename.tar.gz
|
103
|
+
# ftp: ftp://<user>:<password>@hostname/path/to/image/filename.tar.bz2
|
104
|
+
# http: http://<user>:<password>@hostname/path/to/image/filename.tbz
|
105
|
+
# https: https://<user>:<password>@hostname/path/to/image/filename.tbz
|
106
|
+
# nfs: hostname:/path/to/image/filename.tgz
|
107
|
+
|
108
|
+
# Default images provided by hetzner as of October 2014:
|
109
|
+
# Archlinux-2014-64-minmal.tar.gz
|
110
|
+
# CentOS-65-32-minimal.tar.gz
|
111
|
+
# CentOS-65-64-cpanel.tar.gz
|
112
|
+
# CentOS-65-64-minimal.tar.gz
|
113
|
+
# CentOS-70-64-minimal.tar.gz
|
114
|
+
# Debian-76-wheezy-32-minimal.tar.gz
|
115
|
+
# Debian-76-wheezy-64-LAMP.tar.gz
|
116
|
+
# Debian-76-wheezy-64-minimal.tar.gz
|
117
|
+
# openSUSE-131-64-minimal.tar.gz
|
118
|
+
# Ubuntu-1204-precise-64-minimal.tar.gz
|
119
|
+
# Ubuntu-1404-trusty-64-minimal.tar.gz
|
120
|
+
|
121
|
+
|
122
|
+
IMAGE /root/images/Ubuntu-1404-trusty-64-minimal.tar.gz
|
123
|
+
|
124
|
+
EOT
|
125
|
+
|
126
|
+
# the post_install hook is a great place to setup further software/system provisioning
|
127
|
+
#
|
128
|
+
post_install = <<EOT
|
129
|
+
# knife bootstrap <%= ip %> -N <%= hostname %> "role[base],role[kvm_host]"
|
130
|
+
EOT
|
131
|
+
|
132
|
+
bs << {
|
133
|
+
ip: '1.2.3.4',
|
134
|
+
template: template, # string will be parsed by erubis
|
135
|
+
hostname: 'server100.example.com', # will be used for setting the systems' hostname
|
136
|
+
public_keys: "~/.ssh/id_dsa.pub", # will be copied over to the freshly bootstrapped system
|
137
|
+
post_install: post_install # will be called locally at the end and can be used e.g. to run a chef bootstrap
|
138
|
+
}
|
139
|
+
|
140
|
+
bs << {
|
141
|
+
ip: '1.2.3.5',
|
142
|
+
template: template, # string will be parsed by erubis
|
143
|
+
hostname: 'server101.example.com', # will be used for setting the systems' hostname
|
144
|
+
public_keys: "~/.ssh/id_dsa.pub", # will be copied over to the freshly bootstrapped system
|
145
|
+
post_install: post_install # will be called locally at the end and can be used e.g. to run a chef bootstrap
|
146
|
+
}
|
147
|
+
|
148
|
+
...
|
149
|
+
bs.bootstrap!
|
150
|
+
|
151
|
+
|
152
|
+
```
|
153
|
+
|
41
154
|
Installation:
|
42
155
|
-------------
|
43
156
|
|
@@ -47,20 +160,13 @@ Warnings:
|
|
47
160
|
---------
|
48
161
|
|
49
162
|
* All existing data on the system will be wiped on bootstrap!
|
50
|
-
* This is not an official Hetzner
|
51
|
-
* The gem and the author are not related to Hetzner
|
163
|
+
* This is not an official Hetzner Online GmbH project.
|
164
|
+
* The gem and the author are not related to Hetzner Online GmbH !
|
52
165
|
|
53
166
|
**Use at your very own risk. Satisfaction is NOT guaranteed.**
|
54
167
|
|
55
|
-
Commercial Support available through:
|
56
|
-
-------------------------------------
|
57
|
-
|
58
|
-
[](http://moriz.de/)
|
59
|
-
|
60
|
-
[Moriz GmbH, München](http://moriz.de/)
|
61
|
-
|
62
168
|
|
63
169
|
Copyright
|
64
170
|
---------
|
65
171
|
|
66
|
-
Copyright
|
172
|
+
Copyright © 2019 [Roland Moriz](https://roland.io), [Moriz GmbH](https://moriz.de/)
|
data/Rakefile
CHANGED
data/example.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'hetzner-bootstrap'
|
4
6
|
|
5
7
|
# get your API login from Hetzner's customer panel at: https://robot.your-server.de/
|
6
8
|
# assign env variables:
|
@@ -10,105 +12,102 @@ require "hetzner-bootstrap"
|
|
10
12
|
# rbenv-tip: checkout rbenv-vars, it's awesome!
|
11
13
|
# https://github.com/sstephenson/rbenv-vars/
|
12
14
|
|
13
|
-
bs = Hetzner::Bootstrap.new
|
15
|
+
bs = Hetzner::Bootstrap.new(api: Hetzner::API.new(
|
16
|
+
ENV['ROBOT_USER'],
|
17
|
+
ENV['ROBOT_PASSWORD']
|
18
|
+
))
|
14
19
|
|
15
20
|
# 2 disks, software raid 1, etc.
|
16
|
-
template =
|
17
|
-
DRIVE1 /dev/sda
|
18
|
-
DRIVE2 /dev/sdb
|
19
|
-
FORMATDRIVE2 0
|
20
|
-
|
21
|
-
## ===============
|
22
|
-
## SOFTWARE RAID:
|
23
|
-
## ===============
|
24
|
-
|
25
|
-
## activate software RAID? < 0 | 1 >
|
26
|
-
SWRAID 1
|
27
|
-
|
28
|
-
## Choose the level for the software RAID < 0 | 1 >
|
29
|
-
SWRAIDLEVEL 1
|
30
|
-
|
31
|
-
## which bootloader should be used? < lilo | grub >
|
32
|
-
BOOTLOADER grub
|
33
|
-
|
34
|
-
HOSTNAME <%= hostname %>
|
35
|
-
|
36
|
-
## PART <mountpoint/lvm> <filesystem/VG> <size in MB>
|
37
|
-
##
|
38
|
-
## * <mountpoint/lvm> mountpoint for this filesystem *OR* keyword 'lvm'
|
39
|
-
## to use this PART as volume group (VG) for LVM
|
40
|
-
## * <filesystem/VG> can be ext2, ext3, reiserfs, xfs, swap *OR* name
|
41
|
-
## of the LVM volume group (VG), if this PART is a VG
|
42
|
-
## * <size> you can use the keyword 'all' to assign all the
|
43
|
-
## remaining space of the drive to the *last* partition.
|
44
|
-
## you can use M/G/T for unit specification in MIB/GIB/TIB
|
45
|
-
##
|
46
|
-
## notes:
|
47
|
-
## - extended partitions are created automatically
|
48
|
-
## - '/boot' cannot be on a xfs filesystem!
|
49
|
-
## - '/boot' cannot be on LVM!
|
50
|
-
## - when using software RAID 0, you need a '/boot' partition
|
51
|
-
|
52
|
-
PART /boot ext2 1G
|
53
|
-
PART lvm host 75G
|
54
|
-
PART lvm guest all
|
55
|
-
|
56
|
-
#LV <VG> <name> <mount> <filesystem> <size>
|
57
|
-
LV host root / ext3 50G
|
58
|
-
LV host swap swap swap 5G
|
59
|
-
|
60
|
-
|
61
|
-
## ========================
|
62
|
-
## OPERATING SYSTEM IMAGE:
|
63
|
-
## ========================
|
64
|
-
|
65
|
-
## full path to the operating system image
|
66
|
-
## supported image sources: local dir, ftp, http, nfs
|
67
|
-
## supported image types: tar, tar.gz, tar.bz, tar.bz2, tgz, tbz
|
68
|
-
## examples:
|
69
|
-
#
|
70
|
-
# local: /path/to/image/filename.tar.gz
|
71
|
-
# ftp: ftp://<user>:<password>@hostname/path/to/image/filename.tar.bz2
|
72
|
-
# http: http://<user>:<password>@hostname/path/to/image/filename.tbz
|
73
|
-
# https: https://<user>:<password>@hostname/path/to/image/filename.tbz
|
74
|
-
# nfs: hostname:/path/to/image/filename.tgz
|
75
|
-
|
76
|
-
# Default images provided by hetzner as of
|
77
|
-
#
|
78
|
-
# CentOS-
|
79
|
-
# CentOS-
|
80
|
-
# CentOS-
|
81
|
-
# CentOS-
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
IMAGE /root/images/Ubuntu-1204-precise-64-minimal.tar.gz
|
97
|
-
|
98
|
-
EOT
|
99
|
-
|
100
|
-
# the post_install hook is a great place to setup further software/system provisioning
|
21
|
+
template = <<~END_OF_TEMPLATE
|
22
|
+
DRIVE1 /dev/sda
|
23
|
+
DRIVE2 /dev/sdb
|
24
|
+
FORMATDRIVE2 0
|
25
|
+
|
26
|
+
## ===============
|
27
|
+
## SOFTWARE RAID:
|
28
|
+
## ===============
|
29
|
+
|
30
|
+
## activate software RAID? < 0 | 1 >
|
31
|
+
SWRAID 1
|
32
|
+
|
33
|
+
## Choose the level for the software RAID < 0 | 1 >
|
34
|
+
SWRAIDLEVEL 1
|
35
|
+
|
36
|
+
## which bootloader should be used? < lilo | grub >
|
37
|
+
BOOTLOADER grub
|
38
|
+
|
39
|
+
HOSTNAME <%= hostname %>
|
40
|
+
|
41
|
+
## PART <mountpoint/lvm> <filesystem/VG> <size in MB>
|
42
|
+
##
|
43
|
+
## * <mountpoint/lvm> mountpoint for this filesystem *OR* keyword 'lvm'
|
44
|
+
## to use this PART as volume group (VG) for LVM
|
45
|
+
## * <filesystem/VG> can be ext2, ext3, reiserfs, xfs, swap *OR* name
|
46
|
+
## of the LVM volume group (VG), if this PART is a VG
|
47
|
+
## * <size> you can use the keyword 'all' to assign all the
|
48
|
+
## remaining space of the drive to the *last* partition.
|
49
|
+
## you can use M/G/T for unit specification in MIB/GIB/TIB
|
50
|
+
##
|
51
|
+
## notes:
|
52
|
+
## - extended partitions are created automatically
|
53
|
+
## - '/boot' cannot be on a xfs filesystem!
|
54
|
+
## - '/boot' cannot be on LVM!
|
55
|
+
## - when using software RAID 0, you need a '/boot' partition
|
56
|
+
|
57
|
+
PART /boot ext2 1G
|
58
|
+
PART lvm host 75G
|
59
|
+
PART lvm guest all
|
60
|
+
|
61
|
+
#LV <VG> <name> <mount> <filesystem> <size>
|
62
|
+
LV host root / ext3 50G
|
63
|
+
LV host swap swap swap 5G
|
64
|
+
|
65
|
+
|
66
|
+
## ========================
|
67
|
+
## OPERATING SYSTEM IMAGE:
|
68
|
+
## ========================
|
69
|
+
|
70
|
+
## full path to the operating system image
|
71
|
+
## supported image sources: local dir, ftp, http, nfs
|
72
|
+
## supported image types: tar, tar.gz, tar.bz, tar.bz2, tgz, tbz
|
73
|
+
## examples:
|
74
|
+
#
|
75
|
+
# local: /path/to/image/filename.tar.gz
|
76
|
+
# ftp: ftp://<user>:<password>@hostname/path/to/image/filename.tar.bz2
|
77
|
+
# http: http://<user>:<password>@hostname/path/to/image/filename.tbz
|
78
|
+
# https: https://<user>:<password>@hostname/path/to/image/filename.tbz
|
79
|
+
# nfs: hostname:/path/to/image/filename.tgz
|
80
|
+
|
81
|
+
# Default images provided by hetzner as of October 2014:
|
82
|
+
# Archlinux-2014-64-minmal.tar.gz
|
83
|
+
# CentOS-65-32-minimal.tar.gz
|
84
|
+
# CentOS-65-64-cpanel.tar.gz
|
85
|
+
# CentOS-65-64-minimal.tar.gz
|
86
|
+
# CentOS-70-64-minimal.tar.gz
|
87
|
+
# Debian-76-wheezy-32-minimal.tar.gz
|
88
|
+
# Debian-76-wheezy-64-LAMP.tar.gz
|
89
|
+
# Debian-76-wheezy-64-minimal.tar.gz
|
90
|
+
# openSUSE-131-64-minimal.tar.gz
|
91
|
+
# Ubuntu-1204-precise-64-minimal.tar.gz
|
92
|
+
# Ubuntu-1404-trusty-64-minimal.tar.gz
|
93
|
+
|
94
|
+
|
95
|
+
IMAGE /root/images/Ubuntu-1204-precise-64-minimal.tar.gz
|
96
|
+
|
97
|
+
END_OF_TEMPLATE
|
98
|
+
|
99
|
+
# the post_install hook is a great place to setup further
|
100
|
+
# software/system provisioning
|
101
101
|
#
|
102
|
-
post_install = <<
|
102
|
+
post_install = <<END_OF_POST_INSTALL
|
103
103
|
# knife bootstrap <%= ip %> -N <%= hostname %> "role[base],role[kvm_host]"
|
104
|
-
|
104
|
+
END_OF_POST_INSTALL
|
105
105
|
|
106
106
|
# duplicate entry for each system
|
107
|
-
bs << { :
|
108
|
-
:
|
109
|
-
:
|
110
|
-
:
|
111
|
-
:
|
107
|
+
bs << { ip: '1.2.3.4',
|
108
|
+
template: template, # string will be parsed by erubis
|
109
|
+
hostname: 'server100', # sets hostname
|
110
|
+
public_keys: '~/.ssh/id_dsa.pub', # will be copied to your system
|
111
|
+
post_install: post_install } # will be executed *locally* at the end
|
112
112
|
|
113
113
|
bs.bootstrap!
|
114
|
-
|
data/hetzner-bootstrap.gemspec
CHANGED
@@ -1,26 +1,32 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
+
require 'hetzner/bootstrap/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
7
|
+
s.name = 'hetzner-bootstrap'
|
7
8
|
s.version = Hetzner::Bootstrap::VERSION
|
8
9
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = [
|
10
|
-
s.email = [
|
11
|
-
s.homepage =
|
12
|
-
s.summary =
|
13
|
-
s.description =
|
10
|
+
s.authors = ['Roland Moriz']
|
11
|
+
s.email = ['roland@moriz.de']
|
12
|
+
s.homepage = 'https://github.com/rmoriz/hetzner-bootstrap'
|
13
|
+
s.summary = 'Easy bootstrapping of hetzner.de rootservers using hetzner-api'
|
14
|
+
s.description = 'Easy bootstrapping of hetzner.de rootservers using hetzner-api'
|
14
15
|
|
15
|
-
s.
|
16
|
-
s.add_dependency '
|
17
|
-
s.add_dependency '
|
16
|
+
s.required_ruby_version = '~> 3.0'
|
17
|
+
s.add_dependency 'erubis', '>= 2.7.0'
|
18
|
+
s.add_dependency 'hetzner-api', '>= 1.1.0'
|
19
|
+
s.add_dependency 'net-ssh', '~> 6.1'
|
20
|
+
s.add_dependency 'rexml'
|
18
21
|
|
19
|
-
s.add_development_dependency
|
20
|
-
s.add_development_dependency
|
22
|
+
s.add_development_dependency 'rake'
|
23
|
+
s.add_development_dependency 'rspec', '~> 3.4.0'
|
24
|
+
s.add_development_dependency 'rubocop', '~> 1.10'
|
25
|
+
s.add_development_dependency 'rubocop-rake'
|
26
|
+
s.add_development_dependency 'rubocop-rspec'
|
21
27
|
|
22
28
|
s.files = `git ls-files`.split("\n")
|
23
29
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
-
s.require_paths = [
|
30
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
31
|
+
s.require_paths = ['lib']
|
26
32
|
end
|