Skip to main content

Library for image configuration

Project description

Lint

osconfiglib

osconfiglib is a Python library designed to ease the process of layer-based configuration for virtual machines (QCOW2). The library provides utilities to manage layers, apply configurations, and includes a CLI tool for easy management.

Installation

To install osconfiglib, add the following to the dependencies section of your project's pyproject.toml:

osconfiglib = "^1.0.0"

Then run:

$ pip install -r requirements.txt

Usage

Here's a basic example of how you can use osconfiglib:

from osconfiglib.layers import apply_layers

# Use osconfiglib to apply layers to a base image
apply_layers(base_image_path, os_recipe_toml_path, output_image_path, python_version)

CLI Usage

osconfiglib also includes a CLI tool to manage your layers. Here are some examples of how to use it:

# List all layers
$ osconfiglib-cli list layers

# Check version
$ osconfiglib-cli --version

# Add RPM to a layer
$ osconfiglib-cli add rpm mylayer tmux

# Add a file to a layer
$ osconfiglib-cli add file mylayer ~/.tmux.conf /home/user

# Create a new layer
$ osconfiglib-cli create layer newLayer

# Delete a layer
$ osconfiglib-cli delete layer <layer>

Repository Structure

When using osconfiglib to manage layers, your repository should follow this structure:

my-build/
├── configs/
│   ├── bin/
│   │   └── custom-executable
│   ├── etc/
│   │   └── custom-executable.conf
│   └── usr/local/bin
│       └── symlink-to-something
├── package-lists/
│   ├── rpm-requirements.txt
│   ├── dpm-requirements.txt
│   └── pip-requirements.txt
└── scripts/
    ├── 01-first-script-to-run.sh
    └── 02-second-script-to-run.sh
  • configs/: This directory is where you put custom config files that go in the root filesystem. Examples can include custom dns, dhcpd, tftp, and other services required for this "layer".
  • package-lists/: This directory contains lists for RedHat and Debian packages based on the flavor of Linux. A separate file is included for pip requirements for the system Python.
  • scripts/: Scripts are run in alphabetical order. If you number them you can control the order of the scripts.

You can refer to this os-layer-template for a complete template of the repository structure.

Developing

To run the test suite, install the dev dependencies and run pytest:

$ pip install -r dev-requirements.txt
$ pytest

Contact

If you have any issues or questions, feel free to contact me at brandon.geraci@gmail.com.

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

osconfiglib-0.1.5.tar.gz (8.1 kB view hashes)

Uploaded Source

Built Distribution

osconfiglib-0.1.5-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

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