Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you install from PostgresSQL YUM repository #38

Closed
worldofchris opened this issue Mar 1, 2018 · 8 comments
Closed

How do you install from PostgresSQL YUM repository #38

worldofchris opened this issue Mar 1, 2018 · 8 comments
Labels

Comments

@worldofchris
Copy link

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

@worldofchris
Copy link
Author

worldofchris commented Mar 1, 2018

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

@matthiase
Copy link

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.

@madeinoz67
Copy link

thanks @worldofchris @matthiase both helped me considerably!

@po5i
Copy link

po5i commented Oct 19, 2018

Awesome help. This should be documented in a wiki or something

@maksimluzik
Copy link

maksimluzik commented Dec 13, 2018

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

@thesanedenis
Copy link

thesanedenis commented Jul 20, 2019

- 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                        

@stale
Copy link

stale bot commented Mar 6, 2020

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.

@stale stale bot added the stale label Mar 6, 2020
@stale
Copy link

stale bot commented Apr 5, 2020

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.

@stale stale bot closed this as completed Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants