Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

postgresql.yml un able to connect to server #126

Open
essanpupil opened this issue Aug 25, 2015 · 7 comments
Open

postgresql.yml un able to connect to server #126

essanpupil opened this issue Aug 25, 2015 · 7 comments

Comments

@essanpupil
Copy link

hello, when i execute postgressql.yml, i got the following result:

failed: [trustme] => {"failed": true}
msg: unable to connect to database: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

FATAL: all hosts have already failed -- aborting

my ansible version is: 1.9.2
my remote host is: ubuntu server 14.04 32 bit (inside virtual box)

Is there anything wrong, and how do i fix it?
thanks

@varnav
Copy link
Contributor

varnav commented Aug 25, 2015

Which example you are talking about?

@essanpupil
Copy link
Author

I try this example:
ansible-examples/language_features/postgresql.yml

@gregdek
Copy link
Contributor

gregdek commented Aug 26, 2015

@essanpupil post the full output, may help to figure out the issue.

@essanpupil
Copy link
Author

Sorry, i'm too busy with my other problems. So here is my complete output:

pupil@DreamRunner:~/ansible_training$ ansible-playbook install_config_postgre.yml -K
SUDO password: 

PLAY [trustme] **************************************************************** 

TASK: [ensure apt cache is up to date] **************************************** 
ok: [trustme]

TASK: [ensure packages are installed] ***************************************** 
ok: [trustme] => (item=postgresql,libpq-dev,python-psycopg2)

PLAY [trustme] **************************************************************** 

TASK: [ensure database is created] ******************************************** 
failed: [trustme] => {"failed": true}
msg: unable to connect to database: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/pupil/install_config_postgre.retry

trustme                    : ok=2    changed=0    unreachable=0    failed=1 

and here is my .yml file

---
- hosts: trustme
  sudo: yes
  gather_facts: no

  tasks:
  - name: ensure apt cache is up to date
    apt: update_cache=yes
  - name: ensure packages are installed
    apt: name={{item}}
    with_items:
          - postgresql
          - libpq-dev
          - python-psycopg2


- hosts: trustme
  sudo: yes
  sudo_user: postgres
  gather_facts: no

  vars:
    dbname: scam_db
    dbuser: django
    dbpassword: katarahasia

  tasks:
  - name: ensure database is created
    postgresql_db: name={{dbname}}

  - name: ensure user has access to database
    postgresql_user: db={{dbname}} name={{dbuser}} password={{dbpassword}} priv=ALL

  - name: ensure user does not have unnecessary privilege
    postgresql_user: name={{dbuser}} role_attr_flags=NOSUPERUSER,NOCREATEDB

i hope this helps

@jaywink
Copy link

jaywink commented Oct 31, 2015

This happens to me as well, same symptoms, same versions.

@lowks
Copy link

lowks commented May 31, 2016

This happens to me too.

@jaywink
Copy link

jaywink commented Jun 2, 2016

To overcome this, I've added these two tasks to my roles which use Ubuntu 14.04, which seems to suffer from this problem.

- name: Locale patch for postgres
  lineinfile: dest=/etc/default/locale line='LANGUAGE="en_US:en"' state=present
- name: Locale patch for postgres
  lineinfile: dest=/etc/default/locale line='LC_ALL="en_US.UTF-8"' state=present

It's not .... ideal, but for my stuff it does the job. If done before installing postgresql via apt, it will install properly. I believe this is the problem described in full.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants