--- - name: Install python library ansible.builtin.package: name: python3-psycopg2 state: present update_cache: true - name: Install postgresql ansible.builtin.package: name: postgresql state: present update_cache: true - name: Put hba configuration files ansible.builtin.copy: src: "files/pg_hba.conf" dest: "/etc/postgresql/{{ postgres_pg_version }}/main/pg_hba.conf" mode: "0o640" notify: Restart postgres - name: Create backup dir ansible.builtin.file: path: /srv/backup/pgsql owner: postgres group: postgres state: directory mode: "0o755" - name: Cron backup script ansible.builtin.cron: user: postgres minute: "0" hour: "4" name: PG Backup job: "/usr/bin/pg_dumpall | gzip -c > /srv/backup/pgsql/all.dbs.gz"