From 66d92ea4d45950b41340bad2f2c65764c4ffb11f Mon Sep 17 00:00:00 2001 From: Matthew Fennell Date: Thu, 8 Feb 2024 20:11:20 +0000 Subject: Use apt module instead of package I tried to create a fresh nonprod deployment today on continuous.staging.nonprod.chat.fennell.dev. However, the first step failed because the apt command could not find borgmatic. The solution was to run apt update before running apt install. Unfortunately, ansible's package module does not have an option for this. Therefore, although I would have liked to stick with "package" (to keep it general and away from the specific of using "apt" as a package manager), I have switched back to using the apt module so that the step can succeed without any manual intervention on fresh install. --- playbook.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/playbook.yaml b/playbook.yaml index 94137d3..583bf79 100644 --- a/playbook.yaml +++ b/playbook.yaml @@ -7,8 +7,14 @@ - name: Ensure XMPP server is set up hosts: xmpp_server tasks: + # We specifically use apt instead of the more general package module here, + # because we want to ensure the cache is updated before we try and install + # anything. This is needed because, on a freh Debian install on AWS + # Lightsail (as of 2024-02-08), nothing was returned after running apt + # search borgmatic. Updating the cache before running apt install solved + # this issue, but the package module does not support this functionality. - name: Ensure required packages are installed - ansible.builtin.package: + ansible.builtin.apt: name: - borgmatic # Backups - certbot # SSL certificates @@ -21,6 +27,7 @@ - python3-psycopg2 # Used by ansible postgres role - ufw # Firewall state: present + update_cache: true become: true - name: Ensure required ports with ufw applications are open community.general.ufw: -- cgit v1.2.3