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
Please show the exact playbook and the actual error messages.
Did you add the update_cache option to the apt installation task?
Johannes
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
- 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
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
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.
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
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
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
Thanks Dick…
I really appreciate all your help.
–shyam