--- - block: - name: Install PostgreSQL package: name: "{{ item }}" state: present with_items: "{{ __postgres_packages }}" - name: Ensure data directory exists file: path: "{{ __postgres_data_dir }}" owner: "{{ postgres_user }}" group: "{{ postgres_group }}" state: directory mode: 0700 - name: Setup custom systemd unit template: src: etc/systemd/system/postgresql.service.j2 dest: "/etc/systemd/system/{{ __postgres_daemon }}.service" mode: 0644 notify: __postgres_restart become: True become_user: root