--- - name: Update apt repo-cache on debian/ubuntu hosts become: true ansible.builtin.apt: update_cache: true cache_valid_time: 3600 - name: Install Required packages become: true ansible.builtin.package: name: "{{ item }}" state: 'present' with_items: - 'apt-transport-https' - 'python3-psycopg2' - name: Create directory for PostgreSQL repository key become: true ansible.builtin.file: path: "{{ item }}" state: 'directory' mode: '0755' owner: 'root' group: 'root' with_items: - '/usr/share/postgresql-common' - '/usr/share/postgresql-common/pgdg' - name: Download the PostgreSQL signing key become: true ansible.builtin.get_url: url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' dest: '/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc' checksum: 'sha256:0144068502a1eddd2a0280ede10ef607d1ec592ce819940991203941564e8e76' owner: 'root' group: 'root' mode: '0644' - name: Create Apt Repository become: true ansible.builtin.template: src: 'templates/pgdg.list.j2' dest: '/etc/apt/sources.list.d/pgdg.list' owner: 'root' group: 'root' mode: '0644' - name: Install PostgreSQL become: true ansible.builtin.apt: name: "{{ item }}" state: 'present' update_cache: true cache_valid_time: 0 install_recommends: true with_items: "{{ postgres__packages }}"