2

This is literally day one for me in evaluating ansible. I have been asked by the team to show how ansible can be used to solve a specific problem like update 300 databases on 300 different servers... remove 2 rows of data and add 3 new ones.

I found some posts on stackoverflow showing how you can import a file using mysql and ansible... but I'm wondering if the same thing can be done with postgres. i'm looking at the documentation for the ansible postgresql module and it doesn't have import state like mysql.

http://docs.ansible.com/ansible/postgresql_db_module.html

vs.

http://docs.ansible.com/ansible/mysql_db_module.html

Any suggestions?

Thanks.

1 Answer 1

3

It's not supported by the postgres module but there's nothing stopping you from writing a playbook to move over a dump file and import it into the database. You could even break up your dump file and template it out.

- hosts: db_hosts
  become_user: postgres
  tasks: 
  - copy: src=file.dmp dest=/home/postgres/file.dmp
  - shell: psql dbname < file.dmp

I have performed a bulk of my oracle db configuration in this manner

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

1 Comment

sweet! I'll give it a try

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.