我在FreeBSD上运行PostgreSQL 9.3.FreeBSD pgsql
用作PostgreSQL的默认系统用户.我/usr/local/pgsql/data/pg_hba.conf
看起来像这样:
# TYPE DATABASE USER ADDRESS METHOD local all pgsql peer local all all md5 host all all 127.0.0.1/32 md5 host all all ::1/128 md5
使用此配置,我可以在pgsql
没有密码的情况下连接到数据库.
$ su pgsql $ psql template1 template1=# \l List of databases ...
这按预期工作.
在远程计算机上,我有一个Ansible任务在FreeBSD服务器上创建数据库.
- name: Create the postgresql database postgresql_db: name=mydatabase login_user=pgsql
执行此任务失败并显示错误Peer authentication failed for user "pgsql"
.
PLAY [web] ******************************************************************** GATHERING FACTS *************************************************************** ok: [host.example.org] TASK: [database | Create the postgresql database] ***************************** failed: [host.example.org] => {"failed": true} msg: unable to connect to database: FATAL: Peer authentication failed for user "pgsql" FATAL: all hosts have already failed -- aborting
当用户的对等身份验证pgsql
明显起作用时,为什么会失败?