Giter VIP home page Giter VIP logo

bmcbutler's Introduction

bmcbutler

Status Go Report Card Development/Support

About

Bmcbutler is a BMC (Baseboard Management Controller) configuration management tool that uses bmclib.

Configuration support

Hardware User accounts Syslog NTP Ldap Ldap groups BIOS HTTPS Cert
Dell M1000e ✔️ ✔️ ✔️ ✔️ ✔️ -
Dell iDRAC8 ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Dell iDRAC9 ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
HP c7000 ✔️ ✔️ ✔️ ✔️ ✔️ -
HP iLO4 ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
HP iLO5 ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Supermicro X10 ✔️ ✔️ ✔️ ✔️ ✔️ ✔️

Need help? See kiwiirc link above/find us on the freenode IRC channel ##bmc-toolbox.

Build

go get github.com/bmc-toolbox/bmcbutler

Build with vendored modules (>= go 1.11)

GO111MODULE=on go build -mod vendor -v

Notes on working with go mod

To point to a local copy of bmclib, add to the bottom of the go.mod file

replace github.com/bmc-toolbox/bmclib => ../bmclib

To pick a specific bmclib SHA.

GO111MODULE=on go get github.com/bmc-toolbox/bmclib@2d1bd1cb

To add/update the vendor dir.

GO111MODULE=on go mod vendor

Setup

There's two parts to setting up configuration for bmcbutler,

  • Bmcbutler configuration
  • Configuration for BMCs

This document assumes the Bmcbutler configuration directory is ~/.bmcbutler.

Bmcbutler configuration

Setup configuration Bmcbutler requires to run.

# create a configuration directory for ~/.bmcbutler
mkdir ~/.bmcbutler/

Copy the sample config into ~/.bmcbutler/ bmcbutler.yml sample

BMC configuration

Configuration to be applied to BMCs.

# create a directory for BMC config
mkdir ~/.bmcbutler/cfg

add the BMC yaml config definitions in there, for sample config see configuration.yml sample

bmc configuration templating

configuration.yml supports templating, for details see configTemplating

inventory

Bmcbutler was written with the intent of sourcing inventory assets and configuring their bmcs, a csv inventory example is provided to play with.

inventory.csv sample

The 'inventory' parameter points Bmcbutler to the inventory source.

BMC HTTPS cert signing

Bmcbutler can manage certs for BMCs, It compares the current HTTPS cert Subject attributes of a BMC with the ones declared in its configuration, if the attributes don't match, it proceeds to,

  1. Generate a CSR on the BMC using the Subject attributes declared in its configuration.
  2. Pass the CSR to the signer executable, read the signed cert.
  3. Upload the signed cert to the BMC.
  4. Reset the BMC if required.

To have this setup,

  1. Declare a https_cert configuration section in the BMC config template, see configuration.yml sample
  2. Declare a signer executable in the bmcbutler config, see bmcbutler.yml sample

The signer executable is required to accept a CSR through STDIN and spit out the signed cert through STDOUT. An example signer that uses lemur can be found under helpers

Load credentials from Vault

Credentials to login to BMCs and configure them can be declared in the configuration file, or can be looked up from Vault.

To setup secrets lookup from Vault,

  • enable secretsFromVault: true in bmcbutler.yml
  • Use the lookup_secret::Administrator parameter in place of the credential in bmcbutler.yml
  • Use the <%= lookup_secret("Administrator") %> YAML templating parameter in place of credentials in configuration.yml sample
  • See the sample bmcbutler.yml for options to set the vault token.

Examples

Set credentials in Vault, using --config and command substitution to prevent leaking the vault token to other processes (command line arguments are visible to all processes).

curl --config <( builtin printf 'header = "X-Vault-Token: %s"' "${VAULT_TOKEN}" ) \
    -H "Content-Type: application/json" \
    -X POST -d '{"Administrator": "hunter2", "Ops": "foobar"}' https://vault.example.com/v1/secret/baremetal/bmc

Check credentials were set

curl --config <( builtin printf 'header = "X-Vault-Token: %s"' "${VAULT_TOKEN}" ) \
      -X GET https://vault.example.com/v1/secret/baremetal/bmc

bmcbutler.yml - declare Vault config and replace credentials

secretsFromVault: true
vault:
  hostAddress: "http://172.18.0.2:8200"
  tokenFromFile: "samples/vault-token.test"
  secretsPath: /secret/baremetal/bmc
credentials:
  - Administrator: lookup_secret::Administrator
  - Administrator: lookup_secret::Admin2
  - root: lookup_secret::dell_default
  - ADMIN: lookup_secret::sm_default

configuration.yml - declare BMC user account config with lookup_secrets template method.

user:
  - name: Administrator
    # lookup_secret - requires 'secretsFromVault: true' in bmcbutler.yml
    # note - double quotes required
    password: <%= lookup_secret("Administrator") %>
    role: admin
    enable: true
  - name: Ops
    password: <%= lookup_secret("Ops") %>
    role: user
    enable: false
Run

Configure Blades/Chassis/Discretes

#configure all BMCs in inventory, dry run with debug output
bmcbutler configure --all --dryrun --debug

#configure all servers in given locations
bmcbutler configure --servers --locations ams2

#configure all chassis in given locations
bmcbutler configure --chassis --locations ams2,lhr3

#configure all servers in given location, spawning given butlers
bmcbutler configure --servers --locations lhr5 --butlers 200

#configure one or more BMCs identified by IP(s)
bmcbutler configure --ips 192.168.0.1,192.168.0.2,192.168.0.2

#configure one or more BMCs identified by serial(s) and trace log
bmcbutler configure --serials <serial1>,<serial2> --trace

bmcbutler configure --serial <serial1>,<serial2> --debug
bmcbutler configure  --serial <serial> --debug

#Apply specific configuration resource(s) and trace log
bmcbutler configure --ips 192.168.1.4 --resources ntp,syslog,user --trace

Acknowledgment

bmcbutler was originally developed for Booking.com. With approval from Booking.com, the code and specification were generalized and published as Open Source on github, for which the authors would like to express their gratitude.

bmcbutler's People

Contributors

atrubachev avatar dustinmiller avatar gfechio avatar joelrebel avatar l1cafe avatar ncode avatar nnuss avatar samcv avatar threebee 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bmcbutler's Issues

fix SIGTERM handling

When running configure on assets, a CRTL-C/SIGTERM interrupt would wait for all configuration resources to be applied on a asset and then exit.

With the changes done in #2
its possible to exit right after the resource currently being applied is done.

This requires some fixing in the way the butlers are spawned and stopped - #7

Improve code testability

There is no way to currently test bmcbutler in action, that is - applying configuration/executing commands without access to an actual vendor BMC, this dependency isn't ideal for the development of bmcbutler,

The possible approach here could be,

  • Update bmclib to mock vendor BMCs request response if a client is requested with a 'test' flag

bmcbutler does not build with go get

Awesome tool, though does not build for me.

% go get -u github.com/bmc-toolbox/bmcbutler
...
# github.com/bmc-toolbox/bmcbutler/butler
go/src/github.com/bmc-toolbox/bmcbutler/butler/butler.go:86:50: cannot use "github.com/bmc-toolbox/bmcbutler/vendor/github.com/sirupsen/logrus".TextFormatter literal (type *"github.com/bmc-toolbox/bmcbutler/vendor/github.com/sirupsen/logrus".TextFormatter) as type "github.com/sirupsen/logrus".Formatter in argument to logging.SetFormatter:
        *"github.com/bmc-toolbox/bmcbutler/vendor/github.com/sirupsen/logrus".TextFormatter does not implement "github.com/sirupsen/logrus".Formatter (wrong type for Format method)
                have Format(*"github.com/bmc-toolbox/bmcbutler/vendor/github.com/sirupsen/logrus".Entry) ([]byte, error)
                want Format(*"github.com/sirupsen/logrus".Entry) ([]byte, error)
go/src/github.com/bmc-toolbox/bmcbutler/butler/butler.go:88:24: cannot use "github.com/bmc-toolbox/bmcbutler/vendor/github.com/sirupsen/logrus".DebugLevel (type "github.com/bmc-toolbox/bmcbutler/vendor/github.com/sirupsen/logrus".Level) as type "github.com/sirupsen/logrus".Level in argument to logging.SetLevel

additional infos: go version go1.10.3 linux/amd64

Attempt chassis setup actions, only if its powered on.

bmcbutler doesn't check chassis power status before attempting to power up modules,
https://github.com/bmc-toolbox/bmcbutler/blob/master/pkg/butler/setup_chassis.go#L87

On the Dell M1000e this will prevent blades from being powered up, the error seen is,

$ racadm serveraction -m server-1 powerup
ERROR: Unable to perform requested operation.

The fix here is to,

  1. check chassis power status,
    https://github.com/bmc-toolbox/bmclib/blob/master/providers/dell/m1000e/actions.go#L69

  2. Power up the chassis,
    https://github.com/bmc-toolbox/bmclib/blob/master/providers/dell/m1000e/actions.go#L33

It takes a few minutes for the blades to power up, so we skip the chassis configuration at this point,
and expect it to be setup in the next run.

Build integration with https://github.com/purpleidea/mgmt/

Hi @joelrebel and @ncode !

I'm the main developer of https://github.com/purpleidea/mgmt/ and I wasn't sure how best to contact you, so I hope this is okay. If not, feel free to ignore/close/delete.

I came across your project, and I think it would be fantastic if we could integrate the automation of such BMC's with a tool like mgmt. In mgmt we have a concept of resources and a special language that let's you declare what you'd like to automate.

If you are interested, I think it could provide some compelling live demos and integrations. Unfortunately I cannot test directly because I do not have the appropriate hardware. Give me a shout if you'd like to discuss more. Here, or in #mgmtconfig on Freenode IRC. I'm purpleidea.

Thanks for reading!

Split up ApplyCfg

The ApplyCfg loop is ugly and should not live in bmclib,
https://github.com/bmc-toolbox/bmcbutler/blob/master/pkg/butler/configure.go#L71
https://github.com/bmc-toolbox/bmclib/blob/master/providers/hp/c7000/configure.go#L10

Since each vendor may require configuration to be applied in a certain order,
after a connection is established,and the device model, vendor is known,
we order the configuration as per the vendor.

  • Split up ApplyCfg
  • Support ordering of configuration resources based on vendor.

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.