-1

I'm working to add postgresql user named odoo in remote node (docker container) with ansible knowing that I'm trying to follow the manual installation:

$sudo apt-get install postgresql-9.6
$sudo su postgres
$cd
$createuser -s odoo

and this is my code

    - name: Instalation of postgresql-9.6 server 
      apt: 
        name: postgresql-9.6
        state: latest 

    - name: Ensure the PostgreSQL service is running 
      service: name=postgresql state=started enabled=yes


    - name: Create odoo user
      become_user: postgres 
      postgresql_user: 
        state: present
        login_user: postgres
        name: odoo 
        password: odoo 
        role_attr_flags: "SUPERUSER,CREATEDB"
        priv: "CONNECT/products:ALL" 
after running i faced this error
PLAY [My Odoo] ***************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************
ok: [172.17.0.5]

TASK [Postgresql : Instalation of postgresql-9.6 server] *********************************************************************************************
ok: [172.17.0.5]

TASK [Postgresql : Ensure the PostgreSQL service is running] *****************************************************************************************
ok: [172.17.0.5]

TASK [Postgresql : Create odoo user] *****************************************************************************************************************
fatal: [172.17.0.5]: FAILED! => {"changed": false, "msg": "privileges require a database to be specified"}
    to retry, use: --limit @/home/fedora/Desktop/ansible-test/playbook.retry

PLAY RECAP *******************************************************************************************************************************************
172.17.0.5                 : ok=3    changed=0    unreachable=0    failed=1 

Can you help me resolving this?

Mohamed Chaawa
  • 918
  • 1
  • 9
  • 23
iyadhalaoui
  • 341
  • 1
  • 4
  • 5

1 Answers1

0

You've specified a priv option, but haven't specified a database, which should be affected by your config. In your specific case, since you just want to create a user you should omit priv: to have something like

- name: Create odoo user
  become_user: postgres 
  postgresql_user: 
    state: present
    login_user: postgres
    name: odoo 
    password: odoo 
    role_attr_flags: "SUPERUSER,CREATEDB"
Andrew
  • 3,912
  • 17
  • 28
  • this time as you say I eliminated the priv option but I have another error: – iyadhalaoui Mar 22 '19 at 11:18
  • fatal: [172.17.0.5]: FAILED! => {"changed": false, "msg": "unable to connect to database: FATAL: Peer authentication failed for user \"postgres\"\n"} – iyadhalaoui Mar 22 '19 at 11:18
  • that means that you haven't configured ident authentication in you pg_hba, check https://stackoverflow.com/questions/2942485/psql-fatal-ident-authentication-failed-for-user-postgres – Andrew Mar 24 '19 at 19:28
  • I replaced the peer authentication method of postgres by trust and it worked well, thank you for your reply – iyadhalaoui Mar 26 '19 at 14:28