apt facts¶
- class reemote.facts.apt.get_packages.Get_packages[source]¶
Bases:
objectA reemote fact that gathers installed APT packages from a Debian-based system.
When executed by the reemote framework, this operation runs the apt list –installed command on the target server. It then parses the command’s output to create a structured list of all installed packages, including their names and versions.
The final result is a list of dictionaries, which is attached to the stdout attribute of the completed process object. This operation is read-only and will always have changed=False.
Examples:
yield Get_packages()
reemote -i ~/reemote/inventory-proxmox-debian.py -s reemote/facts/apt/get_packages.py -c Get_packages
- reemote.facts.apt.get_packages.parse_apt_list_installed(output)[source]¶
Parses the output of ‘apt list –installed’ into a list of dictionaries.
This helper function processes the raw string output from the apt list –installed command. It iterates through each line, skipping the “Listing…” header and any empty lines. For each valid package line, it accurately extracts the package name and its corresponding version number.
- Parameters:
output (str) – The raw string output from the apt list –installed command.
- Returns:
- A list of dictionaries, where each dictionary
represents an installed package and contains ‘name’ and ‘version’ keys. Example: [{‘name’: ‘zlib1g’, ‘version’: ‘1:1.2.11.dfsg-2’}].
- Return type:
list[dict]
- class reemote.facts.apt.info.Info(package: str, sudo: bool = False, su: bool = False)[source]¶
Bases:
objectA class to manage package operations on a remote system using apt.
- package¶
A package name to be queried.
- Type:
str
- sudo¶
If True, the commands will be executed with sudo privileges.
- Type:
bool
- su¶
If True, the commands will be executed with su privileges.
- Type:
bool
Examples:
yield Info(package='vim')
- Usage:
This class is designed to be used in a generator-based workflow where commands are yielded for execution.
Notes
Commands are constructed based on the present, sudo, and su flags.