我有适用于虚拟机的Ansible playbook。 plyabook正在安装Postgresql DB,在postgresql.conf
和pg_hba.conf
中设置连接参数。但现在我想使用REPLICATION
模块创建一个postgresql_user
角色的新用户。但是在执行此操作时收到错误:
fatal: [10.0.15.20]: 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": "replicador",
"no_password_changes": false,
"password": null,
"port": "5432",
"priv": null,
"role_attr_flags": "REPLICATION",
"state": "present",
"user": "replicador"
},
"module_name": "postgresql_user"
},
"msg": "unable to connect to database: could not connect to server: No such file or directory\n\tIs the server running locally and accepting\n\tconnections on Unix domain socket \"/var/run/postgresql/.s.PGSQL.5432\"?\n"
}
我唯一能找到的是我需要使用
become: yes
become_user: postgres
然而它没有改变任何东西
这是我的安全任务:
- name: create repication user
become: yes
become_user: postgres
postgresql_user:
state: present
name: replicador
encrypted: no
role_attr_flags: REPLICATION
postgresql.conf
listen_addresses = '*'
pg_hba.conf
host all all all trust
答案 0 :(得分:2)
判断你的错误postgres试图通过unix socket而不是tcp one连接到服务器。您应该将以下字符串添加到pg_hba.conf
local all all trust
信任所有unix套接字连接或尝试将login_host: 127.0.0.1
指定为postgresql_user角色。那部分实际上很奇怪,因为根据文档,login_host默认为localhost。
并且还要确保您的数据库真正运行,以防您在游戏手册中错过了该部分。