cli.setup.applications package

Module contents

Compatibility wrapper.

This package was migrated from a flat module (applications/__main__.py) to a package layout:

applications/__main__.py contains the original implementation.

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

class cli.setup.applications.DefaultsGenerator(roles_dir: Path, output_file: Path, verbose: bool, timeout: float)

Bases: object

log(message: str)
run()
test_empty_config_file_adds_empty_defaults()

If a role has vars/main.yml and config/main.yml exists but is an empty file (or only whitespace), the generator must still emit an empty-dict entry for that application_id.

test_empty_config_mapping_adds_empty_defaults()

If a role has vars/main.yml and config/main.yml exists but contains an empty mapping ({}), the generator must still emit an empty-dict entry for that application_id.

class cli.setup.applications.DictRenderer(verbose: bool = False, timeout: float = 10.0)

Bases: object

Resolves placeholders in the form << path >> within nested dictionaries, supporting hyphens, numeric list indexing, and quoted keys via [‘key’] or [“key”].

PATTERN = re.compile('<<\\s*(?P<path>[^\\s>]+)\\s*>>')
TOKEN_REGEX = re.compile('(?P<key>[\\w\\-]+)|\\[\'(?P<qkey>[^\']+)\'\\]|\\[\\"(?P<dkey>[^\\"]+)\\"\\]|\\[(?P<idx>\\d+)\\]')
find_unresolved(data: Any) Set[str]

Return all paths of unresolved << placeholders in data.

render(data: Dict[str, Any] | List[Any]) Dict[str, Any] | List[Any]
class cli.setup.applications.LookupModule(loader: _dataloader.DataLoader | None = None, templar: _template.Templar | None = None, **kwargs)

Bases: LookupBase

run(terms, variables=None, **kwargs)

When the playbook specifies a lookup, this method is run. The arguments to the lookup become the arguments to this method. One additional keyword argument named variables is added to the method call. It contains the variables available to ansible at the time the lookup is templated. For instance:

"{{ lookup('url', 'https://toshio.fedorapeople.org/one.txt', validate_certs=True) }}"
would end up calling the lookup plugin named url’s run method like this::

run([’https://toshio.fedorapeople.org/one.txt’], variables=available_variables, validate_certs=True)

Lookup plugins can be used within playbooks for looping. When this happens, the first argument is a list containing the terms. Lookup plugins can also be called from within playbooks to return their values into a variable or parameter. If the user passes a string in this case, it is converted into a list.

Errors encountered during execution should be returned by raising AnsibleError() with a message describing the error.

Any strings returned by this method that could ever contain non-ascii must be converted into python’s unicode type as the strings will be run through jinja2 which has this requirement. You can use:

from ansible.module_utils.common.text.converters import to_text
result_string = to_text(result_string)
class cli.setup.applications.Path(*args, **kwargs)

Bases: 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 by prepending the current working directory. No normalization or symlink resolution is performed.

Use resolve() to get the canonical path to a file.

chmod(mode, *, follow_symlinks=True)

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

classmethod cwd()

Return a new path pointing to the current working directory (as returned by os.getcwd()).

exists()

Whether this path exists.

expanduser()

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

glob(pattern)

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

group()

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.

classmethod home()

Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).

is_block_device()

Whether this path is a block device.

is_char_device()

Whether this path is a character device.

is_dir()

Whether this path is a directory.

is_fifo()

Whether this path is a FIFO.

is_file()

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_mount()

Check if this path is a POSIX mount point

is_socket()

Whether this path is a socket.

Whether this path is a symbolic link.

iterdir()

Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.

lchmod(mode)

Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.

Make the target path a hard link pointing to this path.

Note this function does not make this path a hard link to target, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link.

Deprecated since Python 3.10 and scheduled for removal in Python 3.12. Use hardlink_to() instead.

lstat()

Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.

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 by this path and return a file object, as the built-in open() function does.

owner()

Return the login name of the file owner.

read_bytes()

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

read_text(encoding=None, errors=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)

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.

samefile(other_path)

Return whether other_path is the same or not as this file (as returned by os.path.samefile()).

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.

write_bytes(data)

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

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

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

cli.setup.applications.load_yaml_file(path: Path) dict