Package: ansible
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 7157
Maintainer: Ansible, Inc. <[email protected]>
Architecture: all
Version: 2.0.0.2-1ppa~trusty
Depends: python, python-support (>= 0.90), python-jinja2, python-yaml, python-paramiko, python-httplib2, python-six, python-crypto (>= 2.6), python-setuptools, sshpass
Conffiles:
/etc/ansible/hosts 1564b951dc7c8511c6f9ee842653c541
/etc/ansible/ansible.cfg 248f57c4cb0f11fe8fd5f39b12ac8205
Description: A radically simple IT automation platform
A radically simple IT automation platform that makes your applications and
systems easier to deploy. Avoid writing scripts or custom code to deploy and
update your applications— automate in a language that approaches plain English,
using SSH, with no agents to install on remote systems.
Homepage: http://ansible.github.com/
Nothing, to my knowledge. I will update this if I learn otherwise.
I've been on IRC for around an hour now trying to solve why I'm getting an error.
There is nothing else in my playbook aside from variable names. This is on a clean, fresh container. I can psql -U postgres fine, so this has to be something with ansible.
- name: Install PostgreSQL and related packages
apt: name={{ item }} state=present update_cache=yes
with_items:
- postgresql
- postgresql-contrib
- python-psycopg2
- name: Create new database user
become_user: postgres
postgresql_user: name=apples role_attr_flags=SUPERUSER,CREATEROLE,CREATEDB,REPLICATION
To have it access the database and create a user.
<postgres-dev.domain.com> ESTABLISH SSH CONNECTION FOR USER: root
<postgres-dev.domain.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/tmp/ansible-ssh-%h-%p-%r postgres-dev.domain.com 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python'
fatal: [postgres-dev.domain.com]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"db": "", "encrypted": false, "expires": null, "fail_on_user": true, "login_host": "", "login_password": "", "login_unix_socket": "", "login_user": "postgres", "name": "rooted", "no_password_changes": false, "password": null, "port": "5432", "priv": null, "role_attr_flags": "SUPERUSER,CREATEROLE,CREATEDB,REPLICATION", "state": "present", "user": "rooted"}, "module_name": "postgresql_user"}, "msg": "unable to connect to database: FATAL: Peer authentication failed for user \"postgres\"\n"}
I'm sorry I wasted your time having to read this. I was missing become: yes
For posterity, if you are creating a new db or a new user, you must become the postgres
user. I was trying to do this as root and I kept getting the error. Working example below.
- name: make events database
postgresql_db:
name: events
become: true
become_user: postgres
- name: make www-data postgresql user
postgresql_user:
db: events
name: www-data
password: "{{ psql_password }}"
priv: ALL
become: true
become_user: postgres
I am using Ansible 2.6.2 and it still does not work for me
Most helpful comment
For posterity, if you are creating a new db or a new user, you must become the
postgres
user. I was trying to do this as root and I kept getting the error. Working example below.