Skip to main content

Build hosts in Foreman from a template file

Project description

[![Build Status](https://travis-ci.org/xnaveira/foreman-host-builder.svg?branch=master)](https://travis-ci.org/xnaveira/foreman-host-builder)

# foreman-host-builder

This package contains a script that uses the python-foreman module to build a set of hosts in foreman

IMPORTANT: At the moment it is only tested with vmware and ovirt backends. Amazon and Google are under development.

  • foreman-host-builder.py

The configuration resides in the file config.cfg.

## Installation

Get the code from this repository:

git clone https://github.com/xnaveira/foreman-host-builder

Use the installation script to install it and get the dpeendencies:

cd foreman-host-builder; python setup.py install

Or, if you are only interested in the script:

pip install foreman-host-builder

## Configuration

The configuration in config.cfg can either be manually edited or entered at script execution time. If you are editing the file manually you have to enconde the passwords in base64.

If any of the values in config.cfg is not initialized, the script will ask for them and offer the possibility of saving those values to the file. The passwords are obfuscated with base64 encoding, while this offers no security (that should be provided by the right management of user permissions) it does difficult the fact of someone seeing the password while you are editing the file.

The configuration values are the addresses and credentials of the systems used by the scripts, these are:

  • Foreman REST api


## foreman-host-builder.py

This is a script that creates a set of virtual machines using the foreman API. It aims to work independently of what virtualization provider the Foreman is using.

The script assumes that the foreman instance that it will be using is configured and able to create machines by itself.

The way it works is taking as input a template file in a given format. In the template a set of parameters are supplied, hostname, operating system, ip address and so on. The template file format is explained in detail bellow.

Needs to be prepared in foreman

The following elements must be prepared in foreman before attempting to create the machines

  • location

  • domain

  • subnet

## Template file format

The template file supports comments preceded by the ‘#’ symbol. Every non preceded by ‘#’ line will be interpreted as a server. The expected fields are the following (semicolon separated), the exact name used in foreman must be provided in the template file.

HOSTNAME;DOMAIN;LOCATION;SUBNET;ENVIRONMENT;ARCHITECTURE;COMPUTE_RESOURCE;HOSTGROUP;COMPUTE_PROFILE;OPERATING_SYSTEM;IP;PTABLE;MEDIA;PUPPET_CA_PROXY;PUPPET_PROXY”

## Command line arguments

From running ./foreman-host-builder.py:

./foreman-host-builder [OPTIONS]

Creates a set of machines on the foreman server specified in config.py

-t , –template <template_file>

the template file containing the lst with machines to be created and their configuration parameters

The template format is a csv file as follows:

HOSTNAME;DOMAIN;LOCATION;SUBNET;ENVIRONMENT;ARCHITECTURE;COMPUTE_RESOURCE;HOSTGROUP;COMPUTE_PROFILE;OPERATING_SYSTEM;IP;PTABLE;MEDIA

Use the exact name of those resources as they appear in Foreman GUI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foreman-host-builder-1.4.tar.gz (12.0 kB view details)

Uploaded Source

File details

Details for the file foreman-host-builder-1.4.tar.gz.

File metadata

File hashes

Hashes for foreman-host-builder-1.4.tar.gz
Algorithm Hash digest
SHA256 ab7e43122decd8228af0fda337eb1fbd92ad7d8fbcea4a1e2f1e97c83f258654
MD5 50f4e6ea5f3b9f6190fb90fc0b19da48
BLAKE2b-256 d143ae75f151e78bc1a004b5d9cf5a61709f776dca29da8e260811cd61bc1be8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page