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服務啓動任務之後移動它並且它工作。謝謝! –