open-future-belgium / postgresql Goto Github PK
View Code? Open in Web Editor NEWAnsible PostgreSQL
License: MIT License
Ansible PostgreSQL
License: MIT License
TASK: [patrik.uytterhoeven.PostgreSQL-For-RHEL6x | Install | Add PostgreSQL repository] ***
changed: [host27.example.org]
TASK: [patrik.uytterhoeven.PostgreSQL-For-RHEL6x | Install | Make sure CentOS & RHEL dependencies are installed] ***
failed: [host27.example.org] => {"changed": false, "failed": true, "rc": 0, "results": []}
msg: No Package matching 'python-psycopg2' found available, installed or updated
FATAL: all hosts have already failed -- aborting
can we add update_cache by default?
I updated to a newer version of CentOS 7 and also the latest stable version of Ansible and suddenly this playbook stopped working for creating users/databases.
Eventually I tracked it down to this playbook sets Postgres to listen on Unix socket /tmp/.s.PGSQL.5432
but the Ansible modules that handle Postgres user/db creation default to /var/run/postgresql/.s.PGSQL.5432
I haven't dug into it to check if Ansible changed where it looks, or if it gets the info from an underlying OS config which might have changed when I updated my CentOS 7 image.
The simple change is to enable listening on Unix socket /var/run/postgresql/.s.PGSQL.5432
by default.
https://github.com/Open-Future-Belgium/PostgreSQL/blob/master/tasks/RedHat.yml#L3
Why is libselinux required for installing/managing postgres?
I don't see it listed as a dependency anywhere in the ansible postgres modules docs nor do I see it referenced elsewhere in this role.
Most postgresql.conf changes don't need a restart, just a reload. And a reload is much safer.
To avoid a restart except where essential, there are a few approaches.
One is documented at http://www.postgresql.org/message-id/[email protected]
My thought was to have postgresql.conf only include postgresql_needs_restart.conf and postgresql_needs_reload.conf. postgresql_needs_restart.conf would include the parameters mentioned in the above email thread.
If postgresql.conf or postgresql_needs_restart.conf changes, the restart postgresql handler is fired as now. But if postgresql_needs_reload.conf changes, a new reload postgresql handler is fired.
I'm happy to implement this but thought I'd see what your thoughts were first on whether it's a sensible approach or if there's anything I've missed.
I recently started getting ERROR: block is not a legal parameter in an Ansible task or handler
. It looks like a recent commit added the block
parameter which only works with ansible 2.0. I'm just checking to see if this was a conscious change to drop support for earlier ansible versions, and if so, to request that the docs be updated to say that. Thanks!
task
- name: restart tmpfiles service
command: systemd-tmpfiles --create
when: ansible_distribution_major_version == '7'
reports "changed" every ansible run
The config template has parameters that were introduced in 9.3:
LOG: unrecognized configuration parameter "unix_socket_directories" in file "/var/lib/pgsql/9.2/data/postgresql.conf" line 59
LOG: unrecognized configuration parameter "wal_sender_timeout" in file "/var/lib/pgsql/9.2/data/postgresql.conf" line 183
LOG: unrecognized configuration parameter "wal_receiver_timeout" in file "/var/lib/pgsql/9.2/data/postgresql.conf" line 200
LOG: unrecognized configuration parameter "lock_timeout" in file "/var/lib/pgsql/9.2/data/postgresql.conf" line 360
FATAL: configuration file "/var/lib/pgsql/9.2/data/postgresql.conf" contains errors
Works pretty fine with psql 9.4 on CentOS 7.2, but not with 9.5
Following error while running the playbook:
RUNNING HANDLER [patrik.uytterhoeven.PostgreSQL-For-RHEL6x : restart postgresql] ***
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Job for postgresql-9.5.service failed because the control process exited with error code. See \"systemctl status postgresql-9.5.service\" and \"journalctl -xe\" for details.\n"}
to retry, use: --limit @playbooks/database/main.retry
PLAY RECAP *********************************************************************
localhost : ok=23 changed=15 unreachable=0 failed=1
systemctl status postgresql-9.5.service
โ postgresql-9.5.service - PostgreSQL 9.5 database server
Loaded: loaded (/etc/systemd/system/postgresql-9.5.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2016-04-13 07:51:19 CEST; 14s ago
Process: 6342 ExecStart=/usr/pgsql-9.5/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=1/FAILURE)
Process: 6336 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Apr 13 07:51:18 nlihmoodle01.hosting.local systemd[1]: Starting PostgreSQL 9.5 database server...
Apr 13 07:51:18 nlihmoodle01.hosting.local pg_ctl[6342]: **LOG: unrecognized configuration parameter "checkpoint_segments" in file "/var/lib/pgsql/9.5/data/postgresql.conf" line 161**
Apr 13 07:51:18 nlihmoodle01.hosting.local pg_ctl[6342]: **FATAL: configuration file "/var/lib/pgsql/9.5/data/postgresql.conf" contains errors**
Apr 13 07:51:19 nlihmoodle01.hosting.local pg_ctl[6342]: pg_ctl: could not start server
Apr 13 07:51:19 nlihmoodle01.hosting.local pg_ctl[6342]: Examine the log output.
Apr 13 07:51:19 nlihmoodle01.hosting.local systemd[1]: postgresql-9.5.service: control process exited, code=exited status=1
Apr 13 07:51:19 nlihmoodle01.hosting.local systemd[1]: Failed to start PostgreSQL 9.5 database server.
Apr 13 07:51:19 nlihmoodle01.hosting.local systemd[1]: Unit postgresql-9.5.service entered failed state.
Apr 13 07:51:19 nlihmoodle01.hosting.local systemd[1]: postgresql-9.5.service failed.
Playbook:
roles:
- patrik.uytterhoeven.PostgreSQL-For-RHEL6x
vars:
postgresql_version: 9.5
postgresql_admin_user: "postgres"
postgresql_default_auth_method: "trust"
NOTIFIED: [patrik.uytterhoeven.PostgreSQL-For-RHEL6x | restart postgresql] ****
failed: [192.168.1.17] => {"failed": true}
msg: Stopping postgresql-9.3 service: [ OK ]
Starting postgresql-9.3 service: [FAILED]
# grep FATAL pgstartup.log
2015-07-18 21:40:00 UTC FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": No such file or directory
because template renders
# grep -i unix_socket postgresql.conf
unix_socket_directories = '/tmp,/var/run/postgresql/'
and there's no such dir
# ll /var/run/postgresql
ls: cannot access /var/run/postgresql: No such file or directory
I just can't take ansible seriously because of that stuff.
Seems nobody cares at all about testing and such.
Every single role that I tried to use from galaxy had fatal problems. Sigh.
Yes, I can just to redefine postgresql_unix_socket_directories but come on - isn't it suppose to work by default?
I would suggest you to use test-kitchen or something.
task
- name: Initialise Postgresql Database if it is not
command: service postgresql{{ join_char | default("-")}}{{ postgresql_version }} initdb {{postgresql_cluster_name}}
silently fails for 9.4 with message
cat /var/lib/pgsql/9.4/pgstartup.log
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
initdb: invalid locale name "data"
but it works with 9.3
Are those
# {{ ansible_managed }}
really necessary ?
They cause PostgreSQL restarts every time.
In defaults there's
postgresql_env:
LC_ALL: "{{ postgresql_locale }}"
LC_LCTYPE: "{{ postgresql_locale }}"
what is it for?
I've failed to find any mentions of it elsewhere in role.
Hello!
I'm using requirements.yml to install roles and it would be great if your role could be referenced with branch or tag. Thus one can be sure that backward-incompatible changes in master won't affect users.
Don't create a zabbix database when user does not specify any databases.
task
- name: Initialise Postgresql Database if it is not
command: service postgresql{{ join_char | default("-")}}{{ postgresql_version }} initdb {{postgresql_cluster_name}}
when: data_dir.stat.exists == false and ansible_distribution_major_version == '6'
produces this warning in /var/lib/pgsql/9.3/pgstartup.log
initdb: invalid locale name "data"
initdb: invalid locale name "data"
initdb: invalid locale name "data"
initdb: invalid locale name "data"
initdb: invalid locale name "data"
initdb: invalid locale name "data"
Distribution's repo files should contain a line exclude=postgresql*
so that dependencies resolve to proper repository. Source: https://wiki.postgresql.org/wiki/YUM_Installation
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.