--- - name: Init PostgreSQL ansible.builtin.command: | initdb -D /var/lib/postgres/data args: creates: /var/lib/postgres/data/PG_VERSION become: true become_user: postgres - name: Start and enable postgres ansible.builtin.systemd_service: name: postgresql.service state: started enabled: true - name: Setup postgres become: true become_user: postgres block: - name: Create cmsuser community.postgresql.postgresql_user: name: cmsuser password: "{{ password }}" environment: PGOPTION: '-c password_encryption=scram-sha-256' - name: Create cmsdb community.postgresql.postgresql_db: db: cmsdb owner: cmsuser - name: Configure privileges community.postgresql.postgresql_privs: db: cmsdb role: cmsuser privs: ALL objs: ALL_IN_SCHEMA - name: Check is CMS DB initialized community.postgresql.postgresql_table: db: cmsdb table: admins become: true become_user: postgres check_mode: true notify: CMS init DB - name: Flush handlers ansible.builtin.meta: flush_handlers