PostgreSQL 9.5 or Higher installation on Ubuntu 14.04 LTS

117 views
Skip to first unread message

Shyam Yenna

unread,
Jan 27, 2017, 11:53:52 AM1/27/17
to Ansible Project
I am trying to install PostgreSQL 9.5 version on Ubuntu 14.04 LTS using ansible 2.2.1 version playbook tasks. According to my workflow design  add apt key, add apt repository and later install postgresql packages. But dependencies packages are broken due to version difference. How to overcome this issue i am unable to find below packages in default os packages. I appreciate your help.



Thanks
Shyam
Auto Generated Inline Image 1

Johannes Kastl

unread,
Jan 27, 2017, 2:22:25 PM1/27/17
to ansible...@googlegroups.com
Please show the exact playbook and the actual error messages.

Did you add the update_cache option to the apt installation task?

Johannes

signature.asc

Shyam Yenna

unread,
Jan 29, 2017, 10:05:23 AM1/29/17
to Ansible Project
Johannes,
 
       Thanks for getting back to me quickly. Please find my playbook steps

- name: PostgreSQL | Add PostgreSQL repository apt-key
  apt_key:
    id:         "{{ postgresql_apt_key_id }}"
    url:        "{{ postgresql_apt_key_url }}"
    state:      present
  register: key_result

- name: PostgreSQL | Add PostgreSQL repository
  apt_repository:
    repo:       "{{ postgresql_apt_repository }}"
    state:      present
    update_cache: true
    filename:   "postgres"
  when: key_result.changed
  register: repoadd

- name: PostgreSQL | Add PostgreSQL repository preferences
  template:
    src:        "pgdg.pref.j2"
    dest:       "/etc/apt/preferences.d/apt_postgresql_org_pub_repos_apt.pref"
    backup:     yes

- name: PostgreSQL | Make sure the dependencies are installed
  apt:
    name:               "{{ item }}"
    state:              present
    update_cache:       true
  with_items:   ['python-psycopg2', 'python-pycurl', 'locales', 'sysstat', 'libpq5']

- name: PostgreSQL | Install PostgreSQL
  apt:
    name:               "{{ item }}"
    state:              present
    update_cache:       true
  environment:          "{{ postgresql_env }}"
  when: repoadd.changed
  with_items:
    - "postgresql-common"
    - "postgresql-{{ postgresql_version }}"
    - "postgresql-client-{{ postgresql_version }}"
    - "postgresql-contrib-{{ postgresql_version }}"


Thanks
Shyam

Johannes Kastl

unread,
Jan 29, 2017, 11:19:31 AM1/29/17
to ansible...@googlegroups.com
On 29.01.17 16:05 Shyam Yenna wrote:

> - name: PostgreSQL | Make sure the dependencies are installed
> apt:
> name: "{{ item }}"
> state: present
> update_cache: true
> with_items: ['python-psycopg2', 'python-pycurl', 'locales', 'sysstat',
> 'libpq5']

Does this step return an error?

> - name: PostgreSQL | Install PostgreSQL
> apt:
> name: "{{ item }}"
> state: present
> update_cache: true
> environment: "{{ postgresql_env }}"
> when: repoadd.changed
> with_items:
> - "postgresql-common"
> - "postgresql-{{ postgresql_version }}"
> - "postgresql-client-{{ postgresql_version }}"
> - "postgresql-contrib-{{ postgresql_version }}"

What is the actual error message?

From your playbook it could be lots of things, from missing variables
to whatever. Hard to say.

Johannes

signature.asc

Shyam Yenna

unread,
Jan 30, 2017, 10:54:58 AM1/30/17
to Ansible Project
I posted exact error message in my first mail for below step.


Does this step return an error?

> - name: PostgreSQL | Install PostgreSQL
>   apt:
>     name:               "{{ item }}"
>     state:              present
>     update_cache:       true
>   environment:          "{{ postgresql_env }}"
>   when: repoadd.changed
>   with_items:
>     - "postgresql-common"
>     - "postgresql-{{ postgresql_version }}"
>     - "postgresql-client-{{ postgresql_version }}"
>     - "postgresql-contrib-{{ postgresql_version }}"



Unable to install package as depends are not met. Technically i have added repository of postgresql 9.5, still i get dependencies not match with exact version number to proceed on installation.


Thanks
Shyam

Dick Davies

unread,
Jan 30, 2017, 1:52:03 PM1/30/17
to ansible list
The error looks a lot like apt-get is unable to find the packages
you want. Until you fix that I don't think there's much Ansible can
do, it's just asking apt-get to install the packages you specify.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/625a3516-1316-497b-b2d6-a143177af313%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dick Visser

unread,
Jan 30, 2017, 4:46:22 PM1/30/17
to ansible...@googlegroups.com
Correct.
Something is off with your custom apt-get repositories. Fix that manually first, but without adding potentially complicating factors like Ansible to the mix. Once you've established your steps actually work, only then comes the time to add Ansible.

Depending on your environment it might be less hassle to apt-get dist-upgrade to Ubuntu 16.04 which already has PG 9.5.

Dick


To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAK5eLPR0EPCmBVeQzhzK_CJ_9x5H956nEzjH-bx3E%3DOudwZ4qw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.
--
Sent from Gmail Mobile

Shyam Yenna

unread,
Jan 30, 2017, 5:31:00 PM1/30/17
to Ansible Project
Thanks for all replies...

I understood clearly error.
 
My point here is to get a workaround solution to install postgresql 9.5 repository on ubuntu 14.04 LTS. As PostgreSQL repository package is not providing depend packages in repository and i am unsuccessful in installing packages like postgresql-common >=158 & libpq5 >=9.5.5 on Ubuntu 14.04 LTS.

I appreciate for all your valuable feedbacks

Thanks
Shyam

Dick Visser

unread,
Jan 31, 2017, 3:56:36 AM1/31/17
to ansible...@googlegroups.com
On 30 January 2017 at 22:31, Shyam Yenna <write...@gmail.com> wrote:
> Thanks for all replies...
>
> I understood clearly error.
>
> My point here is to get a workaround solution to install postgresql 9.5
> repository on ubuntu 14.04 LTS. As PostgreSQL repository package is not
> providing depend packages in repository and i am unsuccessful in installing
> packages like postgresql-common >=158 & libpq5 >=9.5.5 on Ubuntu 14.04 LTS.


I just tried your playbook on an existing Ubuntu 14.04 host. You
didn't supply any vars so I made an estimate guess:

vars:
postgresql_apt_key_id: ACCC4CF8
postgresql_apt_key_url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
postgresql_apt_repository: deb
http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
postgresql_version: "9.5"


The only thing I had no clue about was the template tasks with
"pgdg.pref.j2" so I left that out.
After remove a few 'when' statements it worked a treat, all
dependencies got installed without a problem.

You might need to revise the conditionals in your playbook - I think
there are a bit too many of them.

Dick

--
Dick Visser
Sr. System & Network Engineer
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs

Shyam Yenna

unread,
Jan 31, 2017, 2:16:45 PM1/31/17
to Ansible Project
Thanks Dick...

I really appreciate all your help.

--shyam
Reply all
Reply to author
Forward
0 new messages