Hi,
I'm trying to use this role to install PostgresSQL 9.6 on Centos 7.
It's fine doing 9.2 which is in the base repos but I cannot work out how to configure it to use the PostgresSQL YUM repository in order to get 9.6.
What is the value that needs to go in the postgresql_enablerepo
variable?
I can only find the repository rpms e.g. https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
When I set:
postgresql_enablerepo: "https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm"
It results in the error:
"Error setting/accessing repos: Error getting repository data for https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm, repository not found"
Can you see what I am doing wrong?
Thanks
I _think_ I have answered this myself.
I ran:
yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
Then looking in /etc/yum.repos.d/pgdg-96-centos.repo
I found the name pgdg96
. Setting postgresql_enablerepo
to this resulted in postgresql96-libs
being pulled from pgdg96
but everything else (postgresql
, postgresql-contrib
etc) still coming from updates
.
So I followed the instructions at https://wiki.postgresql.org/wiki/YUM_Installation to exclude postgresql*
from base
and updates
.
I then re-ran the playbook with the role and got 9.6 installed.
To do this in Ansible I added these pre_tasks:
- ini_file:
path: /etc/yum.repos.d/CentOS-Base.repo
option: exclude
value: postgresql*
section: "{{ item }}"
with_items:
- base
- updates
- yum:
name: https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
state: present
Is this the right way to do it or am I working around my own ineptitude?
Thanks
Hi @worldofchris, I ran into the same issue trying to install PostgreSQL 9.6 on CentOS 7 and your approach got me started down the correct road. However, I still ran into some problems because Postgres is not being installed from system packages. After several unsuccessful attempts, I noticed the section in the README that addresses using non-system packages and came up with the following:
- hosts: all
gather_facts: true
pre_tasks:
- name: make selinux permissive
selinux:
policy: targeted
state: permissive
become: yes
- name: install PostgreSQL 9.6 repository
yum:
name: https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
state: present
become: yes
tasks:
- name: install system packages
yum:
name: "{{ item }}"
state: installed
with_items:
- "@Development tools"
become: yes
roles:
- role: geerlingguy.postgresql
postgresql_enablerepo: "pgdg96"
postgresql_version: 9.6
postgresql_data_dir: /var/lib/pgsql/9.6/data
postgresql_bin_path: /usr/pgsql-9.6/bin
postgresql_config_path: /var/lib/pgsql/9.6/data
postgresql_daemon: postgresql-9.6.service
postgresql_packages:
- postgresql96
- postgresql96-server
- postgresql96-libs
- postgresql96-contrib
- postgresql96-devel
become: yes
It turns out that you have to be very specific about the version-specific variables but it all seems to work now and I did not have to make any changes to CentOS-Base.repo. Hopefully this helps you out.
thanks @worldofchris @matthiase both helped me considerably!
Awesome help. This should be documented in a wiki or something
If someone wants to get PostgreSQL 10 running with ansible role, I managed to get it working with the following playbook:
- hosts: all
pre_tasks:
- name: install PostgreSQL 10 repository
yum:
name: https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7.5-x86_64/pgdg-redhat10-10-2.noarch.rpm
state: present
become: yes
tasks:
roles:
- role: geerlingguy.postgresql
postgresql_enablerepo: "pgdg10"
postgresql_version: 10
postgresql_data_dir: /var/lib/pgsql/10/data
postgresql_bin_path: /usr/pgsql-10/bin
postgresql_config_path: /var/lib/pgsql/10/data
postgresql_daemon: postgresql-10.service
postgresql_packages:
- postgresql10
- postgresql10-server
- postgresql10-libs
- postgresql10-contrib
- postgresql10-devel
become: yes
- hosts: db
pre_tasks:
- name: install repository PostgresQL
yum:
name: https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
state: present
become: yes
become: yes
vars_files:
- /home/sane/ansible_roles/pg/geerlingguy.postgresql/defaults/main.yml
roles:
- role: geerlingguy.postgresql
postgresql_enablerepo: "pgdg11"
postgresql_version: 11
postgresql_data_dir: /var/lib/pgsql/11/data
postgresql_bin_path: /usr/pgsql-11/bin
postgresql_config_path: /var/lib/pgsql/11/data
postgresql_daemon: postgresql-11.service
postgresql_packages:
- postgresql11
- postgresql11-server
- postgresql11-libs
- postgresql11-contrib
- postgresql11-devel
become: yes
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.
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.
Most helpful comment
Hi @worldofchris, I ran into the same issue trying to install PostgreSQL 9.6 on CentOS 7 and your approach got me started down the correct road. However, I still ran into some problems because Postgres is not being installed from system packages. After several unsuccessful attempts, I noticed the section in the README that addresses using non-system packages and came up with the following:
It turns out that you have to be very specific about the version-specific variables but it all seems to work now and I did not have to make any changes to CentOS-Base.repo. Hopefully this helps you out.