Giter Site home page Giter Site logo

hetzner-bootstrap's Introduction

hetzner-bootstrap

hetzner-bootstrap allows you to bootstrap a provisioned EQ Server from hetzner.de

Gem Version

What it does:

When you purchase a lot of servers at hetzner you're usually ending in reinstalling each system manually prior to the first usage because you may have different opinions about partitioning or RAID levels. This rubygem helps to fully automate the provisioning of a rootserver.

Warning: All existing data on the system will be lost!

Requirements:

Implemented steps:

  1. Enable Rescue Mode (using Hetzner's webservice)
  2. Resetting the System to boot into rescue mode (using Hetzner's webservice)
  3. Log into the rescue system, write your installimage template, execute installation
  4. Reboot
  5. verify installation (very basic check but can be overwritten)
  6. copy your local ssh public-key into root's .authorized_keys
  7. adds the generated server key into your .know_hosts file
  8. execute post_install hooks (optional)

Example:

see example.rb file for usage!

Warning: All existing data on the system will be lost!

#!/usr/bin/env ruby
require 'hetzner-bootstrap'

bs = Hetzner::Bootstrap.new(api: Hetzner::API.new(ENV['ROBOT_USER'], ENV['ROBOT_PASSWORD']))

template = <<EOT
# see https://github.com/hetzneronline/installimage/
DRIVE1 /dev/sda
DRIVE2 /dev/sdb

## 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 ext3    1G
PART lvm   host   75G
PART lvm   guest  all

#LV <VG> <name> <mount> <filesystem> <size>
LV host root /    ext4  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-1404-trusty-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

bs << {
        ip:  '1.2.3.4',
        template:  template,                # string will be parsed by erubis
        hostname: 'server100.example.com',  # will be used for setting the systems' hostname
        public_keys: "~/.ssh/id_dsa.pub",   # will be copied over to the freshly bootstrapped system
        post_install: post_install          # will be called locally at the end and can be used e.g. to run a chef bootstrap
      }

bs << {
        ip:  '1.2.3.5',
        template:  template,                # string will be parsed by erubis
        hostname: 'server101.example.com',  # will be used for setting the systems' hostname
        public_keys: "~/.ssh/id_dsa.pub",   # will be copied over to the freshly bootstrapped system
        post_install: post_install          # will be called locally at the end and can be used e.g. to run a chef bootstrap
      }

...
bs.bootstrap!

Installation:

gem install hetzner-bootstrap

Warnings:

  • All existing data on the system will be wiped on bootstrap!
  • This is not an official Hetzner Online GmbH project.
  • The gem and the author are not related to Hetzner Online GmbH !

Use at your very own risk. Satisfaction is NOT guaranteed.

Copyright

Copyright © 2019 Roland Moriz, Moriz GmbH

hetzner-bootstrap's People

Contributors

beanieboi avatar rmoriz avatar zzip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hetzner-bootstrap's Issues

README.md incomplete

Hallo,
Ich denke die README.md ist nicht ausführlich genüg.
Env. Variables sind Richtig gesetzt, da diese Skript lauft:
$ curl -u $ROBOT_USER:$ROBOT_PASSWORD https://robot-ws.your-server.de/boot/176.9.25.XXXX

Die gem install hetzner-bootstrap als root geht ohne Fehler.

Nur hier bekommt man ein Fehler:
$ chmod +x ./example.rb
$ ./example.rb
...
[enable_rescue_mode] rescue system could not be activated
something bad happened unexpectedly: Hetzner::Bootstrap::Target::CantActivateRescueSystemError => {"error"=>{"status"=>401, "code"=>"UNAUTHORIZED", "message"=>"Unauthorized"}}

Hier das ende meine example.rb
bs << { :ip => "176.9.25.XXXX",
:template => template, # string will be parsed by erubis
:hostname => 'server1.mydomain.com', # will be used for setting the systems' hostname
:public_keys => "~/.ssh/id_rsa_PR.pub", # will be copied over to the freshly bootstrapped system
:post_install => post_install } # will be called locally at the end and can be used e.g. to run a chef bootstrap

Mit freundlichen Grüßen,
Isaac Puch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.