devops_utils.install module

Implements installation process for the devops-utils image.

The main function here is install() which implements the installation process.

The Replacer, used from within install(), implements a lightweight preprocessing/templating process, thanks to which the external runner can be used as-is when installed as well as directly from source.


Install a runner and shortcuts to all supported programs.

The runner will be installed as devops-utils script in a directory from host mounted at /target. The links to all included programs will be created in the same directory, pointing to devops-utils.

The runner will execute the command it’s run as (or passed as first parameter if executed as devops-utils) via docker run.

Parameters:args (list) – command line arguments
class devops_utils.install.Replacer(input, context)[source]

Bases: object

Used to insert/replace chunks of code in a stream of lines.

This is used to embed some values into the runner script (as it doesn’t have access to them from outside a container) when installing it on the host system.

Iterating through the object will yield lines from the input with lines containing a special marker replaced. The marker format is ##INIT:OPERATOR[:PARAM]## and should be followed by a newline.

The OPERATOR can be:
  • MODULE: then PARAM specifies a python module whose contents should be inserted instead of the original line
  • PLUGINS: then PARAM specifies type of plugins to be included instead of the original line
  • SUPPRESS: supresses the line from output (no parameter)
  • VAR: then PARAM specifies name of variable to look up and place it’s definition in output instead of the original line

Typical usage:

src = StringIO('FOO = 1  ##INIT:VAR:FOO##\n')
for line in Replacer(src, {'FOO': 2}):
    assert line == 'FOO = 2\n'
  • input (iter) – iterator for input lines
  • context (dict) – look up variables to be replaced in this dict
RE_MARKER = <_sre.SRE_Pattern object>