postgresql icon indicating copy to clipboard operation
postgresql copied to clipboard

Is this role appropriate for just managing the version of psql (and libpq)?

Open boldandbusted opened this issue 7 years ago • 2 comments

Howdy. Thank you for this role! I have a question and I hope creating an issue is appropriate. I'd like to use this role to manage the client version on Ubuntu. I don't want to use it right now to do any PG server administration, though I might later. Is this a good use-case for this role - to just manage PG client library and utility versions? Or will I have to plug in "dummy" values to get it to work properly? The README.md seems to imply there are required values for a server installation, as in:

postgresql_admin_user: "postgres"'

And the defaults/main.yml does, too.

Cheers!

boldandbusted avatar Aug 02 '18 22:08 boldandbusted

@boldandbusted , I'm not sure if using this role just to manage the PostgreSQL client software is best. There is a lot of complexity in here to create/tune/patch an actual database cluster (instance), and that's a lot of baggage for something stateless like a client software install.

I'm guessing something simple like this will suffice:

- name: PostgreSQL | Make sure the CA certificates are available | apt
  apt:
    pkg: ca-certificates
    state: present

- name: PostgreSQL | Add PostgreSQL repository apt-key | apt
  apt_key:
    id: "{{ postgresql_apt_key_id }}"
    url: "{{ postgresql_apt_key_url }}"
    state: present
  when: postgresql_apt_key_url and postgresql_apt_key_id and postgresql_install_repository

- name: PostgreSQL | Add PostgreSQL repository | apt
  apt_repository:
    repo: "{{ postgresql_apt_repository }}"
    state: present
  when: postgresql_apt_repository | default('') != '' and postgresql_install_repository

- name: PostgreSQL | Add PostgreSQL repository preferences | apt
  template:
    src: etc_apt_preferences.d_apt_postgresql_org_pub_repos_apt.pref.j2
    dest: /etc/apt/preferences.d/apt_postgresql_org_pub_repos_apt.pref
  when: postgresql_apt_pin_priority and postgresql_install_repository

- name: PostgreSQL | Make sure the dependencies are installed | apt
  apt:
    pkg: "{{item}}"
    state: present
    update_cache: yes
    cache_valid_time: "{{apt_cache_valid_time | default (3600)}}"
  with_items: "{{postgresql_apt_dependencies}}"

- name: PostgreSQL | Install PostgreSQL | apt
  apt:
    name: "{{item}}"
    state: present
    update_cache: yes
    default_release: "{{postgresql_default_release | default(ansible_distribution_release + '-pgdg')}}"
    cache_valid_time: "{{apt_cache_valid_time | default (3600)}}"
  environment: "{{postgresql_env}}"
  with_items:
    - "postgresql-client-{{postgresql_version}}"
    - "postgresql-contrib-{{postgresql_version}}"

(I removed the - "postgresql-{{postgresql_version}}" item from that list... as you don't need that AFAIK)

gclough avatar Feb 25 '19 16:02 gclough

@boldandbusted ,

Does this https://github.com/ANXS/postgresql/issues/179 is what you expected

flotho avatar Oct 31 '19 23:10 flotho

Yeah feels like a dupe of #179

otakup0pe avatar Dec 06 '22 20:12 otakup0pe