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.

44 lines
1.2 KiB

  1. ---
  2. - name: Add APT key for PostgreSQL repository
  3. apt_key:
  4. url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
  5. - name: Add PostgreSQL APT repository
  6. apt_repository:
  7. repo: deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main
  8. - name: Install PostgreSQL
  9. apt:
  10. name: postgresql-{{ postgresql_version }}
  11. - name: Remove postgresql from init.d (may conflict with systemd service)
  12. file:
  13. path: /etc/init.d/postgresql
  14. state: absent
  15. when: is_docker
  16. - name: Update rc.d to reflect init.d removal
  17. command:
  18. cmd: update-rc.d postgresql remove
  19. when: is_docker
  20. - name: Start and enable PostgreSQL meta unit service
  21. systemd_service:
  22. name: postgresql
  23. state: started
  24. enabled: true
  25. - name: Start and enable PostgreSQL cluster service
  26. systemd_service:
  27. name: postgresql@{{ postgresql_version }}-main
  28. state: started
  29. enabled: true
  30. - name: Set configuration options in postgresql.conf
  31. lineinfile:
  32. path: /etc/postgresql/{{ postgresql_version }}/main/postgresql.conf
  33. regexp: "^#?{{ item.key }} ?="
  34. line: "{{ item.key }} = {{ item.value }}"
  35. loop: "{{ _postgresql_settings | combine(postgresql_settings) | dict2items }}"
  36. notify:
  37. - Restart postgresql