Skip to content

loicalbertin/bmgr

 
 

Repository files navigation

bmgr (Boot Manager)

bmgr is intended to generate and serve configuration files or scripts used in the boot and deployment sequence of a server, such as Kickstart, iPXE or Cloud-init files. It can be seen as a subset of Cobbler focused on boot script generation. It is implemented as a small piece of python code providing a Flask-based HTTP backend and the related client. Its interface is based on nodesets which helps to manage large scale clusters.

Boot scripts are identified as resources within bmgr and are generated from Jinja templates. These templates are rendered dynamically each time a host requests a resource, according to the attributes that have been associated to the host.

To associate attributes to a host, you first have to define profiles which hold a collection of attributes and are given a weight. You can then associate hosts to one ore more profiles. If an attribute is defined multiple times, the value of the attribute in the heaviest profile is used.

It is also possible to define resource aliases which allow a resource to point to one template or the other depending on the situation.

A typical usage is to switch between a normal boot from the server disk and a deployment boot to reinstall the server from the network. To achieve this, you can create a 'boot' alias that points to the 'normal' resource by default and make that alias point to the 'deploy' resource when you want to redeploy your server. You can make that alias 'oneshot' so that the 'deploy' resource is only served once while subsequent requests return the 'normal' resource.

Demo

Quick evaluation of bmgr using Docker

  1. Deploy a http server and database with docker-compose

From the repository root:

# docker-compose up -d
  1. Join the bmgr container
# docker exec -ti bmgr_bmgr_1 /bin/bash
  1. Initialize the datbase
# FLASK_APP=bmgr.app flask initdb
  1. Try the CLI (see more CLI usage examples below)
$ bmgr resource list
  1. Edit resource templates to your needs in /etc/bmgr/templates

Installation (Apache WSGI + MySQL backend)

  1. Install the RPM
# yum install bmgr
  1. Choose and configure database credentials
# mysql
  > CREATE DATABASE bmgr;
  > CREATE USER 'bmgr_user' IDENTIFIED BY 'bmgr_pass';
  > GRANT ALL PRIVILEGES ON bmgr.* TO bmgr_user@'%';
  > FLUSH PRIVILEGES;
  1. Initialize the database
# FLASK_APP=bmgr.app flask initdb
  1. Configure apache
# echo 'WSGIScriptAlias /bmgr "/var/www/bmgr/bmgr.wsgi"' >> /etc/httpd/conf/httpd.conf
# systemctl restart httpd

bmgr client usage examples

Hosts

  • List hosts: bmgr host list
  • Add hosts: bmgr host add --profiles PROFILES HOSTS
  • Update hosts: bmgr host update --profiles PROFILES HOSTS
  • Delete hosts: bmgr host del HOSTS
  • Show hosts: bmgr host show HOSTS

Profiles

  • List profiles: bmgr profile list
  • Add profile: bmgr profile add PROFILE --attr ATTR1 VAL1 --attr ATTR2 VAL2 --weight WEIGHT
  • Update profile: bmgr profile update PROFILE --attr ATTR1 VAL1 --attr ATTR2 VAL2 --del-attr ATTR3 --weight WEIGHT
  • Show profile: bmgr profile show PROFILE

Resources

  • List resources: bmgr resource list
  • Add resource: bmgr resource add RESOURCE TEMPLATE
  • Delete resource: bmgr resource del RESOURCE
  • Update resource: bmgr resource update RESOURCE --template TEMPLATE
  • Render resource: bmgr resource render RESOURCE HOSTNAME

Aliases

  • List aliases: bmgr alias list
  • Add alias: bmgr alias add ALIAS TARGET
  • Delete alias: bmgr alias add ALIAS
  • Override alias: bmgr alias override (--oneshot) ALIAS HOSTNAMES TARGET
  • Restore alias: bmgr alias restore ALIAS HOSTNAMES

REST API Endpoints

Hosts

Profiles

Resources (templates)

Aliases

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 94.3%
  • Jinja 4.9%
  • Dockerfile 0.8%