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

Can't change postgres_version #145

Closed
GoodBoy962 opened this issue Sep 2, 2020 · 10 comments
Closed

Can't change postgres_version #145

GoodBoy962 opened this issue Sep 2, 2020 · 10 comments
Labels

Comments

@GoodBoy962
Copy link

Adding var postgresql_version: "12" doesn't change actual version which was installed in VM with Ubuntu 18.

@JakeCooper
Copy link

JakeCooper commented Sep 3, 2020

Also noticed this on Debian 10

roles/postgres.yml

---
- name: Install Postgres
  become: yes
  become_method: sudo
  include_role:
    name: geerlingguy.postgresql
  vars:
    postgresql_version: "12"

@europ
Copy link

europ commented Sep 29, 2020

@geerlingguy is it possible to specify a custom psql version that will be installed via this ansible role?

Problem

This role does not support installing custom PSQL version to the destination platform.

Notes

---------------------------------------
postgresql_version: [OS-specific]
postgresql_data_dir: [OS-specific]
postgresql_bin_path: [OS-specific]
postgresql_config_path: [OS-specific]
postgresql_daemon: [OS-specific]
postgresql_packages: [OS-specific]
---------------------------------------

OS-specific variables that are set by include files in this role's vars
directory. These shouldn't be overridden unless you're using a version
of PostgreSQL that wasn't installed using system packages.

The default PSQL version is defined in ./vars/<OS>-<version>.yml, e.g.:
https://github.com/geerlingguy/ansible-role-postgresql/blob/master/vars/RedHat-7.yml#L2

Example

Platform:

  • CentOS-7
    • includes systemd
    • includes sshd
    • container (setup)

Playbook:

---
- hosts: container # src: https://hub.docker.com/r/europ/docker-centos-sshd-systemd
  gather_facts: true
  tasks:
    - block: # workaround, see https://stackoverflow.com/a/56558842
        - name: PSQL installation and configuration
          include_role:
            name: geerlingguy.postgresql
          vars:
            postgresql_users:
              - name: abc
                password: abc
            postgresql_databases:
              - name: xyz
            postgresql_version: "10.4" # override psql-9.2 with custom version (psql-10.4)
      become: true

Result:

psql -V
# psql (PostgreSQL) 9.2.24

@yodatak
Copy link

yodatak commented Oct 24, 2020

Same for me on debian 10 ....

@MystaMax
Copy link

MystaMax commented Nov 11, 2020

Hello. I'm not 100% sure of this but if you specify a different version of PostgreSQL using postgresql_version, you need to configure the rest of the postgres_ variables. Otherwise, it will use the defaults from ./vars/<OS>-<version>.yml for the variables you did not define and will conflict with the version you wish to install.

For example, in my CentOS 6 test environment, I wanted to install PostgreSQL v9.6. That version of PostgreSQL is not in the standard CentOS repositories. The highest version of PostgreSQL in the standard CentOS repositories is I believe v8.4. These playbooks by Jeff only use the default repositories. Verify that the version of PostgreSQL you wish to install is in the repositories enabled on your server. In my case, I had to install the official PostgreSQL v9.6 yum repositories before configuring the role:

- name: Install PostgreSQL 9.6 Repository
  yum_repository:
    name: postgresql96
    baseurl: https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-$releasever-$basearch
    enabled: True
    file: postgresql96
    description: PostgreSQL 9.6 for RHEL/CentOS $releasever - $basearch
    gpgcheck: False

I added the following variables to ./vars/main.yml NOTE: This file did not exist and had to be created. Also, note the variables below only work on RHEL-based distributions. These will be different for Debian-based distributions.

postgres_users_no_log: false # not needed; enabled for troubleshooting
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
postgresql_packages:
  - postgresql96
  - postgresql96-libs
  - postgresql96-server

Once you have all these variables defined, it will hopefully work for you as well.

@Data-drone
Copy link

note for postgresql 10, you need to add the right repo in first

@stam
Copy link

stam commented Jan 8, 2021

For me it also blindly installs postgres 13 when postgresql_version: 12 is specified

@fnzv
Copy link

fnzv commented Jan 10, 2021

The version is not changing because it's hardoded there for example:

@aviatrix
Copy link

I've created #156 , hopefully it gets approved and merged. Meanwhile it can be used with ansible-galaxy install aviatrix.postgresql

@stale
Copy link

stale bot commented Apr 14, 2021

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 Apr 14, 2021
@stale
Copy link

stale bot commented May 15, 2021

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 May 15, 2021
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

8 participants