ansible-examples
ansible-examples copied to clipboard
postgresql.yml un able to connect to server
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
Which example you are talking about?
I try this example:
ansible-examples/language_features/postgresql.yml
@essanpupil post the full output, may help to figure out the issue.
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
This happens to me as well, same symptoms, same versions.
This happens to me too.
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.