Simple module containing various types of resource to manage files.
Project description
inmanta-module-files
This package is an adapter that is meant to be used with the inmanta orchestrator: https://docs.inmanta.com
Features
This module allows to manage files, on a unix host. It contains the following resources:
files::Directory
: to manage a directory, its existence, permissions and ownership.files::TextFile
: to manage a simple text file, its existence, content, permissions and ownership. This should not be used for big files, as the content of the file is embedded in the resource itself.files::HostFile
: to manage hosts file entries (i.e./etc/hosts
), but allowing the file to be managed by other tools. The resource makes sure to only modify the entries defined in its desired state and leave the rest untouched.files::JsonFile
andfiles::SharedJsonFile
: to manage json file entries. Similarly tofiles::HostFile
, only change in the file what is present in the desired state. The file can then still be modified by other tools.files::SystemdUnitFile
: an entity representing a unit file, which exposes it most useful properties directly in the model. After being exported, this resource becomes nothing more than a text file.files::Symlink
: to manage a symlink, its existence and ownership.
Example
The following example makes sure that the directory /tmp/test/a
exists, and creates a text file in it.
import mitogen
import files
import std
host = std::Host(
name="localhost",
os=std::linux,
via=mitogen::Local(),
)
dir = files::Directory(
host=host,
path="/tmp/test/a",
# The directory that is managed is /tmp/test/a, but the resource
# will also make sure that any of its parent directories exists as well
create_parents=true,
)
file = files::TextFile(
host=host,
path=f"{dir.path}/file.txt",
content="test",
# The file requires the directory to be created first
requires=[dir],
)
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file inmanta_module_files-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: inmanta_module_files-1.1.1-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c71c75a326a250bb2cd77baed5de9f2bc50cc35933898aa68a12d24ec3b43f5a |
|
MD5 | 404e114f99a8e9df4b50871b649a4c53 |
|
BLAKE2b-256 | 7579285358791d0d646602bffc10eccd7cdf6f5bedd9b8fcd1a0b9fb44457526 |