Comments (7)
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.
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.
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.
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.
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.
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.
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)
- Error Initializing Database HOT 4
- Installs version specified by default postgres_version variable on AlmaLinux 8.6 HOT 4
- pg_ident.conf support HOT 3
- Ansible pipeline can't find or access the Ubuntu-20.yml file HOT 1
- Ensure PostgreSQL users are present [Failed] HOT 6
- I am not able to create users and databases HOT 5
- Can't use standard playbook with single user and database
- Is there any build in backup system? HOT 3
- Fedora 37 HOT 5
- postgresql_users roles member predefined HOT 5
- Documentation for priv attribute of postgresql_users parameter HOT 3
- Would support for namimg / multiple instances be accepted? HOT 2
- On Ubuntu 22 default version of postgresql package is 15 HOT 3
- Please consider using Ansible FQCN HOT 2
- Role fails when used with AWX (Ansible Tower) without FQCN HOT 2
- RedHat 9 - wrong version number HOT 2
- postgresql_user priv is deprecated, needs to be migrated to postgresql_privs HOT 3
- Postgresql 11 is EOL since 2023-01-05 HOT 3
- Prerequisite collection 'community.postgresql' now needed? HOT 3
- versionned packages in vars HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-role-postgresql.