0
我有适用于虚拟机的Ansible操作手册。 plybook正在安装Postgresql DB,在postgresql.conf
和pg_hba.conf
中设置连接参数。但是现在我想使用postgresql_user
模块创建一个REPLICATION
角色的新用户。但这样做时收到错误的:无法使用Ansible创建用户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
但是它并没有改变任何东西
这里是我的ansible任务:
- name: create repication user
become: yes
become_user: postgres
postgresql_user:
state: present
name: replicador
encrypted: no
role_attr_flags: REPLICATION
和PostgreSQL设置在postgresql.conf
listen_addresses = '*'
而且pg_hba.conf
host all all all trust
即使我有应该重新启动postgresql的处理程序,并且它被触发了,但是当我尝试创建用户时,看起来没有启动它。我在postrgesql服务启动任务之后移动它并且它工作。谢谢! –