ansible 和 postgresql - 有没有办法使用 ansible 运行 .sql 文件针对 postgresql 数据库?
ansible and postgresql - is there a way to run a .sql file against postgresql database using ansible?
这实际上是我评估 ansible 的第一天。团队要求我展示如何使用 ansible 解决特定问题,例如更新 300 台不同服务器上的 300 个数据库……删除 2 行数据并添加 3 行新数据。
我在 Whosebug 上找到了一些帖子,展示了如何使用 mysql 和 ansible 导入 文件...但我想知道是否可以使用相同的东西用 postgres 完成。我正在查看 ansible postgresql 模块的文档,它没有像 mysql 这样的导入状态。
http://docs.ansible.com/ansible/postgresql_db_module.html
对比
http://docs.ansible.com/ansible/mysql_db_module.html
有什么建议吗?
谢谢。
postgres 模块不支持它,但没有什么可以阻止您编写剧本来移动转储文件并将其导入数据库。您甚至可以分解转储文件并将其模板化。
- hosts: db_hosts
become_user: postgres
tasks:
- copy: src=file.dmp dest=/home/postgres/file.dmp
- shell: psql dbname < file.dmp
我已经以这种方式执行了大量的 oracle 数据库配置
这实际上是我评估 ansible 的第一天。团队要求我展示如何使用 ansible 解决特定问题,例如更新 300 台不同服务器上的 300 个数据库……删除 2 行数据并添加 3 行新数据。
我在 Whosebug 上找到了一些帖子,展示了如何使用 mysql 和 ansible 导入 文件...但我想知道是否可以使用相同的东西用 postgres 完成。我正在查看 ansible postgresql 模块的文档,它没有像 mysql 这样的导入状态。
http://docs.ansible.com/ansible/postgresql_db_module.html
对比
http://docs.ansible.com/ansible/mysql_db_module.html
有什么建议吗?
谢谢。
postgres 模块不支持它,但没有什么可以阻止您编写剧本来移动转储文件并将其导入数据库。您甚至可以分解转储文件并将其模板化。
- hosts: db_hosts
become_user: postgres
tasks:
- copy: src=file.dmp dest=/home/postgres/file.dmp
- shell: psql dbname < file.dmp
我已经以这种方式执行了大量的 oracle 数据库配置