2

Usually I do :

sudo -su postgres
psql
\password
\q

to change postgres password. Now I want to automate this step using ansible.

1 Answer 1

6

Ansible postgresql_user module will help to set/reset the database user password. Here is the sample

- name: pd reset database user
  become: yes
  become_method: sudo
  become_user: postgres
  postgresql_user: 
    db: test
    name: test
    password: ""

For Reference, here is ansible link: https://docs.ansible.com/ansible/latest/collections/community/postgresql/postgresql_user_module.html#ansible-collections-community-postgresql-postgresql-user-module

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.