Skip to content
ANXSPublic

About

Ansible role for apt

Resources

Stars

14 stars

Watchers

6 watching

Forks

Repository files navigation

ANXS - apt

CI Status Maintenance Ansible Role License

Ansible role for managing the APT package cache, cleaning up unneeded packages and .deb files, and optionally performing system upgrades with configurable frequency and style.

Requirements & Dependencies

  • Ansible 2.13 or higher.
  • Ubuntu 20.04+ or Debian 12+.

Variables

Some commonly adjusted variables. See defaults/main.yml for the full set.

  • apt_upgrade (default false) controls whether automatic upgrades are done during the Ansible run.
    • apt_upgrade_style (default safe) controls the upgrade method. Other options are full and dist.
    • apt_upgrade_frequency (default once) affects how often the upgrade is run. Other options are always and (once per) boot.
  • apt_install_recommends / apt_install_suggests (both default to false) allow installing recommended or suggested packages.
  • apt_autoremove (default true) removes packages that are no longer needed.
  • apt_autoremove_packages (default []) marks installed manual packages as automatic before autoremove. Packages that are absent or still required are retained.
  • apt_cache_valid_time (default 3600) controls how often the APT cache is refreshed.
  • apt_unattended_upgrades (default null) preserves the distribution policy. Set it to true or false to enable or disable automatic upgrade execution explicitly.
  • apt_daily_timer_on_calendar / apt_daily_upgrade_timer_on_calendar (default null) replace the corresponding systemd timer's OnCalendar entries when set to a list.
  • apt_daily_timer_randomized_delay_sec / apt_daily_upgrade_timer_randomized_delay_sec (default null) override each timer's randomized delay.

Testing

Tests use Molecule with Docker and Testinfra. Run the full suite with make test, or target a specific platform (e.g. make test-ubuntu2404). A comprehensive matrix covering upgrade style and frequency combinations is available via make test-matrix.

The test suite verifies APT configuration, required package installation, cache validity, upgrade execution and log parsing, lock file behavior across frequency modes, and OS-specific log format handling. Tests run across all supported Linux distributions.

Note on AI Usage

This project has been developed with AI assistance. Contributions making use of AI generated content are welcome, however they must be human reviewed prior to submission as pull requests, or issues. All contributors must be able to fully explain and defend any AI generated code, documentation, issues, or tests they submit. Contributions making use of AI must have this explicitly declared in the pull request or issue. This also applies to utilization of AI for reviewing of pull requests.

Feedback, bug-reports, requests, ...

Are welcome!

About

Ansible role for apt

Resources

Stars

14 stars

Watchers

6 watching

Forks

Releases

Packages

Contributors

Languages