You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

  1. ---
  2. - name: Create database and enable access and all necessary extensions
  3. become_user: postgres
  4. block:
  5. - name: Create database
  6. community.postgresql.postgresql_db:
  7. name: "{{ item }}"
  8. owner: tildes
  9. - name: Enable extensions
  10. community.postgresql.postgresql_ext:
  11. name: "{{ extension }}"
  12. db: "{{ item }}"
  13. loop: "{{ extensions }}"
  14. # since the "outer" loop by include_tasks is already using the `item` variable,
  15. # this will use `extension` for the loop inside here
  16. loop_control:
  17. loop_var: extension
  18. - name: Add database to pg_hba.conf
  19. community.postgresql.postgresql_pg_hba:
  20. dest: /etc/postgresql/{{ postgresql_version }}/main/pg_hba.conf
  21. databases: "{{ item }}"
  22. users: tildes
  23. contype: local
  24. method: trust
  25. notify:
  26. - Reload postgresql
  27. - name: Add database to pgbouncer.ini
  28. become_user: root
  29. lineinfile:
  30. path: /etc/pgbouncer/pgbouncer.ini
  31. line: "{{ item }} ="
  32. insertafter: "^\\[databases\\]$"
  33. firstmatch: true
  34. notify:
  35. - Reload pgbouncer