【发布时间】:2014-11-03 06:09:01
【问题描述】:
我在 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 的对等身份验证明显有效时,为什么这会失败?
【问题讨论】:
-
您必须以
pgsql用户身份运行ansible 模块吗?例如,将:sudo: true和sudo_user: pgsql添加到您的命令中 -
您最终找到解决方案了吗?
标签: postgresql authentication freebsd ansible ansible-playbook