Skip to main content

py_animus

animus as in a sense of purpose and reason

A python based plugable and extensible manifest processing system

The general idea is to create an extensible system that would be responsible for processing YAML Manifest files (similar to Kubernetes) in a consistent way to ensure the desired state as described in these files can be achieved.

Why use this solution

The project was created as a result of finding a better way to manage environments with a mixture of deployment technologies including AWS CloudFormation and Terraform.

This project is not a replacement of any of these technologies but rather a wrapper of sorts that can use any number of existing deployments systems in any number of on-premise or public cloud scenarios.

More specifically, this project includes the base classes and basic processing and will rely on other projects to provide the detailed implementation logic for systems like AWS CloudFormation and Terraform.

Note Imagine you have a mixed on-premise environment where you have some infrastructure as code in shell scripts and Terraform and you also have several public cloud accounts, each with their own tooling for deploying infrastructure as code. Now imagine you have complex applications that need to provision resources in multiple of these environments when deployed. How to you coordinate and orchestrate something like that? Existing tools like Terraform and others could be used. This implementation is a Python based approach to this problem and does not replace any of your existing tooling, but merely helps you bind it all together to perform some really complex orchestration.

Although the initial focus was on Infrastructure, it could very well be used in many other types of scenarios, including:

  • Provisioning of public cloud accounts in a bootstrapping type scenario
  • Deploying a mixture of Kubernetes based applications where some may use Helm and others using other technologies and/or package management solution.

Advantages of this system or approach:

  • None of your existing tooling have to be replaced and often no additional modifications are required
  • This tool can assist in orchestration of several existing tools to accomplish a single goal, for example the provisioning of infrastructure to support the deployment of an application
  • This tool has no knowledge of anything, and all logic to process any manifest needs to be provided as Python code. In the future there will hopefully be a growing library of manifest processing implementations that support a growing number of environments and tools
  • Implementation classes can be versioned and can be tied to specific versions of a manifest. In a real life scenario you could maintain various versions of implementation logic and manifests along side each other.
  • A built in manifest dependency reference system allows you to dictate which manifests depend on which other manifests. The system will determine from this the order in which manifests needs to be applied
  • The solution provides a class to store various variables that are shared and usable among all manifest implementations. Therefore, some context derived in the processing of one manifest can be stored and made available for consuming while processing other manifest implementations.
  • The logic for applying and deleting manifest state is provided and in future releases also rollback and other features will be supported
  • A basic command line tool is provided, as well as a containerized version of the command line tool. Just point to the class sources and the manifests and the system will process and implement state as defined and implemented.
  • Apart from the command line tool, it is also possible to have full control over the processing of manifests, as all classes can be extended as required. You can therefore roll your own unique version of the command line tools.

what is animus

The Manifest File

Any Manifest file has the following top-level attribute names:

  • kind
  • apiVersion
  • metadata
  • spec

The goal is to implement classes that can process any kind of manifest of a specific version (or range of versions).

Processing a class means essentially to take the metadata and spec sub-attributes into consideration to ensure the stated configuration is applied during processing.

Processing must ensure that the desired end-state of the manifest can be implemented by user-defined logic.

Overall the system needs to be able to derive the implemented state versus the desired state in order to calculate and implement changes required to reach a desired state as defined in the manifest.

If this sounds very familiar, then yes - it is basically how Kubernetes work. The difference is that this library is not Kubernetes specific and aims to be more generalized methods that could be employed by potentially any system that must be continuously monitored and updated to fit a desired state.

Documentation

Warning I no longer consider this to be beta software, but real life usage is still limited. Therefore note that there may still be bugs. Please log all bugs as an issue.

Quick Intro Usage

Installation

This project is also hosted on https://pypi.org/project/py-animus/

Installation:

pip install py-animus

Note It is always a good idea to use Python Virtual environments and I encourage it as well.

Using pre-built Docker Image

Pull the image:

docker pull ghcr.io/nicc777/py-animus:latest

Get quick help:

docker run --rm -e "DEBUG=1" ghcr.io/nicc777/py-animus:latest -h

Use (as per the hello world example):

docker run --rm -e "DEBUG=1" \
  -v $PWD/examples/hello-world/src:/tmp/src \
  -v $PWD/examples/hello-world/manifest:/tmp/data \
  -v /tmp/results:/tmp/hello-world-result \
  ghcr.io/nicc777/py-animus:latest apply -m /tmp/data/hello-v1.yaml -s /tmp/src

The above command will create a file in /tmp/results with the content as defined in the manifest file:

$ cat /tmp/results/output.txt
This is the contents of the file
specified in the content property
of the spec.

More complex example:

docker run --rm -e "DEBUG=1" \
  -v $PWD/examples/linked-manifests/src:/tmp/src \
  -v $PWD/examples/linked-manifests/manifest/round_1:/tmp/data \
  -v /tmp/results:/tmp/example-page-result \
  ghcr.io/nicc777/py-animus:latest apply -m /tmp/data/linked-v1.yaml -s /tmp/src

To reverse out any of the applied commands, just use the command delete instead of apply

The file will no longer be available

$ cat /tmp/results/output.txt
cat: /tmp/results/output.txt: No such file or directory

Acknowledgements

Icons

Metadata

Release files for py-animus 1.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-animus 1.0.16
File Size Uploaded
py_animus-1.0.16.tar.gz 53.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-animus 1.0.16
File Interpreter ABI Platform
py_animus-1.0.16-py3-none-any.whl Python 3 none any Details

Total release size: 92.7 kB

Release files / py_animus-1.0.16.tar.gz

Download URL py_animus-1.0.16.tar.gz
Size 53.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8eec4b95c935f2b582e0f2acb143aeb4a4389c7632eb98368a5702d85f56786d
BLAKE2b-256 checksum
How to use checksums
7a2558456f5d7e747cb15a86230665da3925c9f7e9427a1d4485cc2d0593193d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / py_animus-1.0.16-py3-none-any.whl

Download URL py_animus-1.0.16-py3-none-any.whl
Size 39.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77aa5fb51e38fbe6902b1d41c0ef8d59c3b08c6ad1e792241033f4e4f74e78d0
BLAKE2b-256 checksum
How to use checksums
fa7c509874a5ee32fe8cf85f2392bce4296c66017aacade3cbfbbc1904cd5893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.0.16 This release

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.10

2 release files

0.9.9

2 release files

0.9.8

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page