Coder Social home page Coder Social logo

Comments (7)

sir-sukhov avatar sir-sukhov commented on May 10, 2024 1

observed one more thing to do with this role for PGDATA change on Ubuntu 18.04
it's due to handler.
correct [steps] to change PGDATA during first installation seems to be:
[install postgres] -> [change config] -> [restart postgres] -> [create database]

but Ansible plays handler after all tasks, so it works like that:
[install postgres] -> [change config] -> [create database] -> [restart postgres]

thus, database I tried to create appeared in the output of "\d" psql command only after applying this role twice.

workaround seems to be "- meta: flush_handlers" inside tasks/main.yml

- include_tasks: configure.yml
- include_tasks: initialize.yml
- meta: flush_handlers

and I also changed handler to make it sleep in systemd:

---
- name: make postgres restart
  service:
    name: "{{ postgresql_daemon }}"
    state: "{{ postgresql_restarted_state }}"
    sleep: 5
  listen: "restart postgresql"

- name: wait for 5 seconds
  wait_for: timeout=5
  delegate_to: localhost
  listen: "restart postgresql"

from ansible-role-postgresql.

anroots avatar anroots commented on May 10, 2024

Kindof hackish way of doing it using the role's own methods: define a variable.

postgresql_global_config_options:
  - option: data_directory
    value: "/external_disk/postgres/10"

from ansible-role-postgresql.

sir-sukhov avatar sir-sukhov commented on May 10, 2024

It's worth to mention that both steps are mandatory, thus:

postgresql_data_dir: /external_disk/postgres/10
postgresql_global_config_options:
  - option: data_directory
    value: "/external_disk/postgres/10"

from ansible-role-postgresql.

dgptamayo avatar dgptamayo commented on May 10, 2024

I tried setting the variables mentioned above but the default systemd manifest file for postgresql (/usr/lib/systemd/system/postgresql.service) still use the default PGDATA value:

# Location of database directory
Environment=PGDATA=/var/lib/pgsql/data

Probably the easiest way to fix this is to overwrite the default systemd file by creating a new one in /etc/systemd/system/postgresql.service

from ansible-role-postgresql.

apneef avatar apneef commented on May 10, 2024

when using this ansible role,
came to the same conclusion that when you specifiy
postgresql_data_dir in your ansible file,
Postgresql installation still uses /var/lib/postgresql/ af main folder.
So i added 1 option in the main.yml file

This is my ansible script:

    vars:
      postgresql_data_dir: '/opt/postgresql/{{ __postgresql_version }}/main'
    vars_files:
      - "./group_vars/vault.yml"

    become: yes
    roles:
      - ansible-role-postgresql

in the main.yml in the role i added

- option: data_directory value: '{{ postgresql_data_dir }}'

in the section:

postgresql_global_config_options:
  - option: unix_socket_directories
    value: '{{ postgresql_unix_socket_directories | join(",") }}'
  - option: data_directory
    value: '{{ postgresql_data_dir }}'

This will always change the data_directory. Even if it is not used.
Beacause in variables.yml the following is defined:

  set_fact:
    postgresql_data_dir: "{{ __postgresql_data_dir }}"
  when: postgresql_data_dir is not defined

from ansible-role-postgresql.

stale avatar stale commented on May 10, 2024

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

from ansible-role-postgresql.

stale avatar stale commented on May 10, 2024

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

from ansible-role-postgresql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.