Module fs

This module offers some resource to manage files and directories on a host.

  • License: ASL 2.0

  • Version: 1.1.1

Typedefs

typedef fs::json_format_t
  • Base type string

  • Type constraint (self in ['json', 'yaml'])

typedef fs::operation_t
  • Base type string

  • Type constraint (self in ['replace', 'merge', 'remove'])

Entities

entity fs::ConfigFile

Parents: fs::File

A file with often used defaults for configuration files.

attribute int? mode=644
attribute string? owner='root'
attribute string? group='root'

The following implements statements select implementations for this entity:

entity fs::Content

Parents: std::Entity

A content block as a prefix or suffix to a file. This blocks are only merged with the content at export time. This is an advanced pattern that can be used to speed up the compilation in very specific use cases.

attribute string? sorting_key=null

The key to use to sort the content blocks in the same list. When this attribute is not set value is used as sorting key.

attribute string value

The value to prepend or append

The following implements statements select implementations for this entity:

entity fs::DefaultDirectory

Parents: fs::Directory

A directory that is world readable. It is also writable for its owner root.

attribute int? mode=755
attribute string? owner='root'
attribute string? group='root'

The following implements statements select implementations for this entity:

entity fs::Directory

Parents: std::PurgeableResource

A directory on the filesystem

attribute string path

The path of the directory

attribute int? mode=null

The permissions of the directory

attribute string? owner=null

The owner of the directory

attribute string? group=null

The group of the directory

attribute bool send_event=true
relation mitogen::Context via [0:1]

Mitogen context dedicated to this resource. If not specified, defaults to the one of the host.

relation std::Host host [1]

Relation to the host on which the directory should be deployed.

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity fs::File

Parents: std::PurgeableResource

This represents a file on the filesystem

attribute string path

The path of the file

attribute int? mode=null

The permissions of the file

attribute string? owner=null

The owner of the file

attribute string? group=null

The group of the file

attribute string content

The file contents

attribute string content_separator='\n'

A string to use to join all of the prefix/suffix content entities together.

attribute bool send_event=true
relation mitogen::Context via [0:1]

Mitogen context dedicated to this resource. If not specified, defaults to the one of the host.

relation std::Host host [1]

Relation to the host on which the file should be deployed.

relation fs::Content prefix_content [0:*]

Relation to content that should be inserted at the start of the file.

relation fs::Content suffix_content [0:*]

Relation to content that should be appended at the end of the file.

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity fs::JsonFile

Parents: std::PurgeableResource

A JsonFile on the given host. The resource contains a set of values that needs to be enforced on the given file. See fs::JsonValue for more information about the usage of said values. This resource can be split into multiple ones, which share the management of the file. This is ideal for managing files which need to be part of multiple resource sets.

The following example will make sure that: 1. The file /tmp/example.json exists 2. The file is a valid json file 3. The json object of the file contains a key “bob”, which has as value

the given dict: {“name”: “bob”, “age”; 31}

..code-block:

fs::JsonFile(
    host=...,
    path="/tmp/example.json",
    resource_discriminator="bob",
    values=[
        JsonObject(
            path="bob",
            value={"name": "bob", "age": 31},
        ),
    ],
)
attribute string path

The path where the file should be managed.

attribute string resource_discriminator=''

An additional field which allows to create multiple resources for a single file.

attribute int? mode=null

The permissions to set on the file

attribute string? owner=null

The name of the user owning of the file

attribute string? group=null

The name of the group owning the file

attribute int indent=2

The indentiation to use when writing in the file.

attribute fs::json_format_t format='json'

The format the json content is supposed to be written in.

attribute bool send_event=true
relation std::Host host [1]

The host that this file is managed on.

relation mitogen::Context via [0:1]

Mitogen context dedicated to this resource. If not specified, defaults to the one of the host.

relation fs::JsonValue values [0:*]

The set of values that will be enforced in the file.

other end: fs::JsonValue.json_file [1]

The following implements statements select implementations for this entity:

entity fs::JsonObject

Parents: fs::JsonValue

A json object value in a json file.

attribute dict value

The dict value to set for this value.

The following implements statements select implementations for this entity:

entity fs::JsonValue

Parents: std::Entity

A value present in a json file. This is an abstract entity, it should be extended for each type of value that can be set in the desired state. The children entities should have one attribute: value, that should contain the value to enforce, whichever type it is.

attribute string path

A dict path expression pointing to an element in the json file. The dict path operation should respect what is defined here https://github.com/inmanta/inmanta-core/blob/master/src/inmanta/util/dict_path.py

attribute fs::operation_t operation='replace'

The way the value should be enforced in the file.

relation fs::JsonFile json_file [1]

The set of values that will be enforced in the file.

other end: fs::JsonFile.values [0:*]

Parents: std::PurgeableResource

A symbolic link on the filesystem

attribute string src

The path on the file system that the created symlink should point to.

attribute string dst

The path on the filesystem where the symlink should be created.

attribute bool send_event=true
relation mitogen::Context via [0:1]

Mitogen context dedicated to this resource. If not specified, defaults to the one of the host.

relation std::Host host [1]

Relation to the host where the symlink should be deployed.

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

Implementations

implementation fs::dirHost
implementation fs::fileHost
implementation fs::symHost

Plugins

fs.file(path: 'string') 'string'

Return the textual contents of the given file

fs.list_files(path: 'string') 'list'

List files in a directory

fs.source(path: 'string') 'string'

Return the textual contents of the given file

Resources

class fs.resources.Directory

A directory on a filesystem

class fs.resources.File

A file on a filesystem

class fs.json_file.JsonFileResource

A symbolic link on the filesystem

Handlers

class fs.resources.PosixFileProvider

This handler can deploy files on a unix system

class fs.resources.DirectoryHandler

A handler for creating directories

class fs.resources.SymlinkProvider

This handler can deploy symlinks on unix systems

class fs.json_file.JsonFileHandler