apt_policy module – Get status of apt package
Note
This module is part of the ufrmath.computer_labs collection (version 1.0.0).
To install it, use: ansible-galaxy collection install git+https://github.com/guillod/computer_labs.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: ufrmath.computer_labs.apt_policy.
New in ufrmath.computer_labs 1.0.0
Synopsis
Get status of a package through apt returning informations similar to the command apt-cache policy.
Requirements
The below requirements are needed on the host that executes this module.
python-apt (python 2)
python3-apt (python 3)
Parameters
Parameter |
Comments |
|---|---|
A package name, like |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Can run in check_mode and return changed status prediction without modifying target |
|
Support: full |
Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
|
Platform: debian |
Target OS/families that can be operated against |
Examples
- name: Get status of libpam-systemd package
ufrmath.computer_labs.apt_policy:
name: libpam-systemd
register: apt_status
- name: Display all versions
debug:
msg: "{{ apt_status.versions }}"
- name: Display installed version
debug:
msg: "{{ apt_status.installed }}"
- name: Check if installed version is from security
debug:
msg: "{{ apt_status.installed | json_query(query) | length > 0 }}"
vars:
query: "origins[?ends_with(archive,'-security')]"
- name: Check if a specific version is in security
debug:
msg: "{{ apt_status.versions | json_query(query) | length > 0 }}"
vars:
query: "[?version=='{{ version }}'].origins[] | [?ends_with(archive,'-security')]"
version: "245.4-4ubuntu3.15"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Candidate version together with their origins. Returned: always Sample: |
|
Installed version together with their origins. Returned: always Sample: |
|
List of versions together with their origins. Returned: always Sample: |
Collection links
Repository (Sources) Administrator documentation User documentation