run:

  - replace:
      filename: "/etc/postgresql/15/main/postgresql.conf"
      from: /#?full_page_writes *=.*/
      to: "full_page_writes = off"

  - replace:
      filename: "/etc/postgresql/15/main/postgresql.conf"
      from: /#?fsync *=.*/
      to: "fsync = off"

  - exec:
      background: true
      # use fast shutdown for pg
      stop_signal: INT
      cmd: HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/15/bin/postmaster -D /etc/postgresql/15/main

  - exec:
      background: true
      cmd: exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf

  # give db a few secs to start up
  - exec: "sleep 5"

  - exec: su postgres -c 'psql -c "ALTER USER discourse WITH SUPERUSER;"'
