--- # The home-server project produces a multi-purpose setup using Ansible. # Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license. # Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing. ### UPSTREAM BEGIN ⇒ ### - name: pull prerequisites from upstream include_role: name=etckeeper.inc allow_duplicates=true tasks_from=upstream.yml vars: msg: PostgreSQL ### ⇐ UPSTREAM BEGIN ### - name: install software package: name: "{{item}}" state: present with_items: - postgresql - postgresql-old-upgrade - python-psycopg2 ### UPSTREAM END ⇒ ### - name: merge upstream include_role: name=etckeeper.inc allow_duplicates=true tasks_from=merge.yml vars: msg: PostgreSQL ### ⇐ UPSTREAM END ### - name: ensure ownership of postgresql directory file: path: /var/lib/postgres state: directory owner: postgres group: postgres - name: init PostgreSQL cluster command: > bash -c "initdb --locale {{locales_default}} -E UTF8 -D /var/lib/postgres/data -A md5 --pwfile <(echo \"$PGPASSWORD\")" environment: PGPASSWORD: "{{pgpassword}}" become: true become_user: postgres args: creates: /var/lib/postgres/data/* notify: - restart postgresql.service - name: allow local peer authent to PostgreSQL lineinfile: path: /var/lib/postgres/data/pg_hba.conf regexp: '^local.*peer\s*$' line: 'local all postgres peer' insertafter: '^#\s*TYPE\s+DATABASE\s' notify: - restart postgresql.service - name: include custom settings lineinfile: path: /var/lib/postgres/data/postgresql.conf line: "include '/etc/postgresql.conf'" insertafter: EOF notify: - restart postgresql.service - name: send custom settings copy: src: files/postgresql.conf dest: /etc/postgresql.conf owner: root group: postgres mode: 0640 notify: - restart postgresql.service - name: make sure /etc/systemd/system/postgresql.service.d exists file: path: /etc/systemd/system/postgresql.service.d state: directory mode: 0755 - name: override postgresql.service settings copy: content: | [Unit] After=systemd-tmpfiles-setup.service dest: /etc/systemd/system/postgresql.service.d/shared_sockets.conf mode: 0644 # TODO: https://www.postgresql.org/docs/current/static/creating-cluster.html - name: enable PostgreSQL systemd: daemon_reload: true name: postgresql.service enabled: true ### LOCAL COMMIT ⇒ ### - name: commit local changes include_role: name=etckeeper.inc allow_duplicates=true tasks_from=local.yml vars: msg: PostgreSQL ### ⇐ LOCAL COMMIT ### - meta: flush_handlers