diff options
author | Matthew Fennell <matthew@fennell.dev> | 2024-02-08 20:11:20 +0000 |
---|---|---|
committer | Matthew Fennell <matthew@fennell.dev> | 2024-02-08 20:11:20 +0000 |
commit | 66d92ea4d45950b41340bad2f2c65764c4ffb11f (patch) | |
tree | 1dee70516e132cd7f378538af1d5ca1ff994e69d | |
parent | c2b6f14ff3c02db76c4dee93dc28b47b7d7d0d6a (diff) |
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.
-rw-r--r-- | playbook.yaml | 9 |
1 files changed, 8 insertions, 1 deletions
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: |