--- - name: create pgpass file template: src: pgpass.j2 dest: ~/.pgpass mode: 0600 - name: create temporary password file template: src: pgpass_temp.j2 dest: ~/.pgpass_temp mode: 0600 - name: setup database cluster command: initdb --pwfile ~/pgpass.temp --auth=scram-sha-256 -E UTF8 -D ~/opt/postgresql/data/ - name: delete temporary password file file: path: ~/.pgpass_temp state: absent - name: update port lineinfile: path: ~/opt/postgresql/data/postgresql.conf regexp: '^port =' line: port = {{ postgres_port }} - name: update unix socket directories lineinfile: path: ~/opt/postgresql/data/postgresql.conf regexp: '^unix_socket_directories' line: unix_socket_directories = '/home/{{ uberspace_user }}/tmp' # comma-separated list of directories