ANXS / postgresql

Fairly full featured Ansible role for Postgresql.
http://anxs.io/
MIT License
850 stars 573 forks source link

Add support for PostgreSQL-11 on Ubuntu 18.04 #384

Closed irionr closed 5 years ago

irionr commented 5 years ago

Add support for PostgreSQL11 with Ubuntu18.04. Updated minor version for PostgreSQL-9.6 and PostgreSQL-10.

thbar commented 5 years ago

Thanks @irionr! Do you know roughly what it would take to support Ubuntu 16.04 as well?

gclough commented 5 years ago

@irionr, can this be updated to support all OS's that the current role supports please?

irionr commented 5 years ago

Hi, I don't have the time to do it now. Maybe I'll do it after 23 november.

Cheers, Florin

Il giorno lun 5 nov 2018, 13:23 Greg Clough notifications@github.com ha scritto:

@irionr https://github.com/irionr, can this be updated to support all OS's that the current role supports please?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ANXS/postgresql/pull/384#issuecomment-435855979, or mute the thread https://github.com/notifications/unsubscribe-auth/AhQZYLFLUd3t53Qs8z5L6VjbJbIFY4Mvks5usC29gaJpZM4XyAqv .

Rylon commented 5 years ago

Hi @gclough I have a local fork of the repo and have applied this PR (along with #395) and tested in the following Vagrant environments. I don't think any of the errors found are to do with the pull request, they appear to be existing errors.

bionic64 (Ubuntu 18.04)

postgres@vagrant-ubuntu-bionic64:~$ psql
psql (11.2 (Ubuntu 11.2-1.pgdg18.04+1))
Type "help" for help.

postgres=#

xenial64 (Ubuntu 16.04)

postgres@vagrant-ubuntu-xenial64:~$ psql
psql (11.2 (Ubuntu 11.2-1.pgdg16.04+1))
Type "help" for help.

postgres=# 

trusty64 (Ubuntu 14.04)

Shows the following error which doesn't seem to be related to this PR, perhaps this is currently broken anyway?

TASK [postgresql : PostgreSQL | Update systemd | Debian] ***********************
fatal: [ubuntu-trusty]: FAILED! => {"changed": false, "cmd": "systemctl daemon-reload", "msg": "[Errno 2] No such file or directory", "rc": 2}

If I proceed to start the service manually it works:

root@vagrant-ubuntu-trusty64:~# /etc/init.d/postgresql start
 * Starting PostgreSQL 11 database server                                                                [ OK ] 
root@vagrant-ubuntu-trusty64:~# su -l postgres
postgres@vagrant-ubuntu-trusty64:~$ psql
psql (11.2 (Ubuntu 11.2-1.pgdg14.04+1))
Type "help" for help.

postgres=#

For Debian you specify Debian v8 and v9 on your README, but the Vagrantfile specified Jessie and Wheezy, which is v7 and v8, so I tested it with v7, v8 and v9 to be sure.

stretch64 (Debian 9)

postgres@vagrant-debian-stretch64:~$ psql
psql (11.2 (Debian 11.2-1.pgdg90+1))
Type "help" for help.

postgres=#

jessie64 (Debian 8)

vagrant@vagrant-debian-jessie64:~$ sudo su -l postgres
postgres@vagrant-debian-jessie64:~$ psql
psql (11.2 (Debian 11.2-1.pgdg80+1))

wheezy64 (Debian 7)

Fails due to wrong/malformed Apt source:

TASK [postgresql : PostgreSQL | Add PostgreSQL repository | apt] ***************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: , E:Some index files failed to download. They have been ignored, or old ones used instead.
fatal: [debian-wheezy]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 113, in <module>\n  File \"<stdin>\", line 105, in _ansiballz_main\n  File \"<stdin>\", line 48, in invoke_module\n  File \"/tmp/ansible_apt_repository_payload_xf0nkv/__main__.py\", line 550, in <module>\n  File \"/tmp/ansible_apt_repository_payload_xf0nkv/__main__.py\", line 542, in main\n  File \"/usr/lib/python2.7/dist-packages/apt/cache.py\", line 418, in update\n    raise FetchFailedException(e)\napt.cache.FetchFailedException: W:Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/wheezy-pgdg/Release  Unable to find expected entry '11/binary-amd64/Packages' in Release file (Wrong sources.list entry or malformed file)\n, E:Some index files failed to download. They have been ignored, or old ones used instead.\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

CentOS 6

Fails due to the following errors:

TASK [postgresql : PostgreSQL | Setup service users profile | yum] *************
fatal: [centos-6]: FAILED! => {"msg": "The conditional check 'postgresql_service_user_pgsql_profile' failed. The error was: error while evaluating conditional (postgresql_service_user_pgsql_profile): 'postgresql_service_user_pgsql_profile' is undefined\n\nThe error appears to have been in '/Users/ryan/code/ansible/roles/postgresql/tasks/install_yum.yml': line 37, column 9, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n      - name: PostgreSQL | Setup service users profile | yum\n        ^ here\n"}

I found several tasks referencing when: postgresql_service_user_pgsql_profile but the variable doesn't seem to be defined anywhere, so I changed the condition to when: postgresql_service_user_pgsql_profile is defined and re-run the playbook.

This then resulted in the following error:

TASK [postgresql : PostgreSQL | Reload all conf files] *************************
fatal: [centos-6]: FAILED! => {"changed": false, "msg": "\n/var/lib/pgsql/11/data is missing. Use \"service postgresql-11 initdb\" to initialize the cluster first.\n[FAILED]\r\n"}

If I run the initialisation it all works:

[root@vagrant-centos-6 ~]# service postgresql-11 initdb
Initializing database:                                     [  OK  ]
[root@vagrant-centos-6 ~]# /etc/init.d/postgresql-11 restart
Stopping postgresql-11 service:                            [  OK  ]
Starting postgresql-11 service:                            [  OK  ]
[root@vagrant-centos-6 ~]# su -l postgres
-bash-4.1$ psql
psql (11.2)
Type "help" for help.

postgres=# 

CentOS7

Also fails due to the following error:

TASK [postgresql : PostgreSQL | Setup service users profile | yum] *************
fatal: [centos-7]: FAILED! => {"msg": "The conditional check 'postgresql_service_user_pgsql_profile' failed. The error was: error while evaluating conditional (postgresql_service_user_pgsql_profile): 'postgresql_service_user_pgsql_profile' is undefined\n\nThe error appears to have been in '/Users/ryan/code/ansible/roles/postgresql/tasks/install_yum.yml': line 37, column 9, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n      - name: PostgreSQL | Setup service users profile | yum\n        ^ here\n"}

I found several tasks referencing when: postgresql_service_user_pgsql_profile but the variable doesn't seem to be defined anywhere, so I changed the condition to when: postgresql_service_user_pgsql_profile is defined and re-run the playbook, which then worked:

[vagrant@vagrant-centos-7 ~]$ sudo su -l postgres
-bash-4.2$ psql
psql (11.2)
Type "help" for help.
gclough commented 5 years ago

Hi @irionr . I took and old PR of mine #333 and refreshed it into #405. This is now merged, so the role supports v11. That supersedes this, so I hope you don't mind if I close it?

Getting Ubuntu 18.04 support would be nice, but I think it would make more sense to branch the current master and add it to there as a new PR. Could you do that?

Cheers, Greg.