Declarative parametrization, extension and validation of Inmanta DSL models.
Project description
GitOps module
This package is an integration module that is meant to be used with the inmanta orchestrator: https://docs.inmanta.com
It allows you to easily parametrize a model by defining slices, and then instantiating as many slices as you need to by simply creating json or yaml files in the project repository. This module aims at enabling its users to manage an infra in a "Git-Ops" fashion. Key ideas are:
- Declarative Configuration: The desired state of your infrastructure and applications is described in a declarative format (json/yaml files) within a Git repository.
- Version Control: Git serves as the central source of truth, meaning all changes are committed to the repository, providing a complete history of the system's evolution.
- Automated Synchronization: The orchestrator continuously monitors the Git repository and pulls in new updates.
- Pull Requests for Changes: When you want to make a change, you create a pull request to modify the Git repository.
- Deployment & Reconciliation: Once the pull request is approved and merged, the orchestrator automatically pulls the changes and deploys them to the live environment, ensuring the actual system state matches the desired state in Git.
All of this is already natively supported by the orchestrator by modifying the main.cf file of a project. This works but scales poorly and it is not possible to track deleted items, this modules aims at addressing these limitations.
More details about the design in the docs folder.
Packaged modules
The inmanta-module-git-ops python package ships three top-level modules:
inmanta_plugins.git_ops: the inmanta module itself, containing the plugins, slice/store primitives and processors used by the model. This is the public API to import from other inmanta modules building on top of git_ops.pytest_inmanta_git_ops: a pytest plugin exposing thegit_ops_projectfixture and theGitOpsProjecthelper class to write tests for modules using git_ops. This is the public API to import from the test suite of other inmanta modules.inmanta_git_ops: holds code that must live outside ofinmanta_plugins(constants, thegit-opsCLI, the project generator). Theinmanta_pluginsnamespace can be reloaded by various code paths (notably theclean_resetfixture frominmanta-core), so anything that needs stable module-level state (e.g. constants used as monkeypatch targets) is extracted here. This module is not meant to be imported from other inmanta modules.
Cli
This module also provides a cli interface, to facilitate the creation of a module based on git_ops and the management of a project using git_ops.
If the module is installed in your venv, just run the git-ops command.
$ git-ops --help
Usage: git-ops [OPTIONS] COMMAND [ARGS]...
Inmanta module git_ops CLI tool.
Options:
--log-level [DEBUG|INFO|WARNING|ERROR]
--help Show this message and exit.
Commands:
module Commands to manage the module containing slice definitions.
project Commands to manage the current Inmanta project.
Testing modules built on git_ops
The pytest_inmanta_git_ops plugin provides a git_ops_project fixture that wraps the
pytest-inmanta project fixture and lets you drive update/sync/export/prune compiles
on a model, write/remove slices, and assert on the resulting instances.
from inmanta_plugins.example.slices import fs
from pytest_inmanta_git_ops.project import GitOpsProject
def test_fs(git_ops_project: GitOpsProject) -> None:
git_ops_project.load_stores("import example::slices::fs::unroll")
slice1 = git_ops_project.test_slice(
fs.RootFolder(root="/tmp/", name="test"),
store_name=fs.STORE.name,
)
# Write the slice to disk and trigger an update + sync compile
assert git_ops_project.write_slice(slice1).version == 1
assert len(git_ops_project.get_instance(slice1).directories) == 0
# Mutate the slice, write again, and check the new version
slice1.slice.directories = [fs.Folder(name="a"), fs.Folder(name="b")]
assert git_ops_project.write_slice(slice1).version == 2
# Remove the slice
git_ops_project.remove_slice(slice1)
git_ops_project.prune()
A more complete example lives in docs/example, including the matching slice definitions and the full test suite under docs/example/tests.
Running tests
- Set up a new virtual environment, then install the module in it. The first line assumes you have
virtualenvwrapperinstalled. If you don't, you can replace it withpython3 -m venv .env && source .env/bin/activate.
mkvirtualenv inmanta-test -p python3 -a .
pip install -e . -c requirements.txt -r requirements.dev.txt
- Run tests
pytest tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inmanta_module_git_ops-0.4.0.tar.gz.
File metadata
- Download URL: inmanta_module_git_ops-0.4.0.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c5b7b55932f500be8e5ab72b3638ef2b3bebb43b6972752424298938527d18d
|
|
| MD5 |
bc14e6a50dcbe3f4f5892ffc5f24c92e
|
|
| BLAKE2b-256 |
95a0319bced346810e1b7319825c08c2e2c8a7b70cd666a3c3a2673b39b73ca6
|
Provenance
The following attestation bundles were made for inmanta_module_git_ops-0.4.0.tar.gz:
Publisher:
continuous-delivery.yml on edvgui/inmanta-module-git-ops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inmanta_module_git_ops-0.4.0.tar.gz -
Subject digest:
8c5b7b55932f500be8e5ab72b3638ef2b3bebb43b6972752424298938527d18d - Sigstore transparency entry: 1676045144
- Sigstore integration time:
-
Permalink:
edvgui/inmanta-module-git-ops@7ad986ef1ae56132c09158b69a453ba19398ed3a -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/edvgui
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
continuous-delivery.yml@7ad986ef1ae56132c09158b69a453ba19398ed3a -
Trigger Event:
push
-
Statement type:
File details
Details for the file inmanta_module_git_ops-0.4.0-py3-none-any.whl.
File metadata
- Download URL: inmanta_module_git_ops-0.4.0-py3-none-any.whl
- Upload date:
- Size: 47.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b5257a4f48f5c8428bbe2356335698feee03a89ebdf7ecdf8e9b7235dc81aa9
|
|
| MD5 |
e8effa717085b2d38e620bea6d9325b2
|
|
| BLAKE2b-256 |
8e1c937f680cdfa52531584d65e2b70d4dbd6731d04d10453b636dca366e7887
|
Provenance
The following attestation bundles were made for inmanta_module_git_ops-0.4.0-py3-none-any.whl:
Publisher:
continuous-delivery.yml on edvgui/inmanta-module-git-ops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inmanta_module_git_ops-0.4.0-py3-none-any.whl -
Subject digest:
0b5257a4f48f5c8428bbe2356335698feee03a89ebdf7ecdf8e9b7235dc81aa9 - Sigstore transparency entry: 1676045164
- Sigstore integration time:
-
Permalink:
edvgui/inmanta-module-git-ops@7ad986ef1ae56132c09158b69a453ba19398ed3a -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/edvgui
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
continuous-delivery.yml@7ad986ef1ae56132c09158b69a453ba19398ed3a -
Trigger Event:
push
-
Statement type: