cli.meta.roles.applications.role_name package

Module contents

Compatibility wrapper.

This package was migrated from a flat module (role_name.py) to a package layout:

role_name/__main__.py contains the original implementation.

We re-export the public API so existing imports keep working.

class cli.meta.roles.applications.role_name.Path(*args, **kwargs)

Bases: PathBase, PurePath

PurePath subclass that can make system calls.

Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.

absolute()

Return an absolute version of this path No normalization or symlink resolution is performed.

Use resolve() to resolve symlinks and remove ‘..’ segments.

as_uri()

Return the path as a URI.

chmod(mode, *, follow_symlinks=True)

Change the permissions of the path, like os.chmod().

expanduser()

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

classmethod from_uri(uri)

Return a new path from the given ‘file’ URI.

glob(pattern, *, case_sensitive=None, recurse_symlinks=False)

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

group(*, follow_symlinks=True)

Return the group name of the file gid.

Make this path a hard link pointing to the same file as target.

Note the order of arguments (self, target) is the reverse of os.link’s.

is_junction()

Whether this path is a junction.

is_mount()

Check if this path is a mount point

iterdir()

Yield path objects of the directory contents.

The children are yielded in arbitrary order, and the special entries ‘.’ and ‘..’ are not included.

mkdir(mode=511, parents=False, exist_ok=False)

Create a new directory at this given path.

open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)

Open the file pointed to by this path and return a file object, as the built-in open() function does.

owner(*, follow_symlinks=True)

Return the login name of the file owner.

read_text(encoding=None, errors=None, newline=None)

Open the file in text mode, read it, and close the file.

Return the path to which the symbolic link points.

rename(target)

Rename this path to the target path.

The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.

Returns the new Path instance pointing to the target path.

replace(target)

Rename this path to the target path, overwriting if that path exists.

The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.

Returns the new Path instance pointing to the target path.

resolve(strict=False)

Make the path absolute, resolving all symlinks on the way and also normalizing it.

rglob(pattern, *, case_sensitive=None, recurse_symlinks=False)

Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.

rmdir()

Remove this directory. The directory must be empty.

stat(*, follow_symlinks=True)

Return the result of the stat() system call on this path, like os.stat() does.

Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.

touch(mode=438, exist_ok=True)

Create this file with the given access mode, if it doesn’t exist.

Remove this file or link. If the path is a directory, use rmdir() instead.

walk(top_down=True, on_error=None, follow_symlinks=False)

Walk the directory tree from this directory, similar to os.walk().

write_text(data, encoding=None, errors=None, newline=None)

Open the file in text mode, write to it, and close the file.

exception cli.meta.roles.applications.role_name.RoleNotFoundError

Bases: RuntimeError

No role under roles_path declares this application_id.

cli.meta.roles.applications.role_name.get_role(application_id, roles_path)

Find the role directory under roles_path whose vars/main.yml contains the specified application_id.

Parameters:
  • application_id – The application_id to match.

  • roles_path – Path to the roles directory.

Returns:

The name of the matching role directory.

Raises:

RuntimeError – If no match is found or if an error occurs while reading files.

cli.meta.roles.applications.role_name.load_yaml(path, *, default_if_missing: Any = <object object>) → dict[str, Any]

Load a YAML file as a dict, memoised by absolute path.

default_if_missing controls the missing-file behaviour: - Default (_MISSING): raise FileNotFoundError for callers that

want to fail loud (resolution code).

  • Pass a value (typically {}): return that value when the file does not exist, matching the behaviour expected by cli.administration.inventory.provision.yaml_io.load_yaml.

Raises TypeError when the YAML root is not a mapping; use load_yaml_any for files whose root is a list or scalar.

cli.meta.roles.applications.role_name.main()