【问题标题】:Best method to run Postgrres queries with Ansible?使用 Ansible 运行 Postgres 查询的最佳方法?
【发布时间】:2022-09-22 22:30:52
【问题描述】:

我有一个通过一系列 Ansible 角色部署的大型应用程序。配置应用程序的最后一部分是一系列 Postgres DB 查询。

查询如下所示:

update inboxdb.T_CONFIGURATION_VALUE set value=\'file:/usr/local/app/Keystore\' where SAK_CONFIGURATION_KEY = (select SAK_CONFIGURATION_KEY from inboxdb.T_CONFIGURATION_KEY where keyname=\'lifeimage.x509.keystorePath\');
update inboxdb.T_CONFIGURATION_VALUE set value=\'file:/usr/local/app/Keystore\' where SAK_CONFIGURATION_KEY = (select SAK_CONFIGURATION_KEY from inboxdb.T_CONFIGURATION_KEY where keyname=\'lifeimage.x509.keystorePath2\');
insert into inboxdb.t_tier (sak_tier, name, tier_position) values (4, \'tier3\', 4);
insert into inboxdb.t_storage_provider (sak_storage_provider, dtype, name, context_path, sak_tier, version) values (4, \'VOLUME\', \'provider4\', \'/cloudapp_vol1\', 4, 0);
update inboxdb.t_tier set tier_position = 0 where sak_tier = 4;
update inboxdb.t_tier set tier_position = 3 where sak_tier = 1;

使用 Ansible 将这些查询应用于特定数据库的最佳方法是什么?

    标签: linux postgresql ansible


    【解决方案1】:

    Ansible 方法是使用专用模块

    可以控制系统资源,如服务、包或文件(实际上是任何东西),或处理执行系统命令。

    因此建议使用postgresql_query module – Run PostgreSQL queries

    更多文档

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-30
      • 2012-02-29
      • 1970-01-01
      • 2012-09-30
      • 1970-01-01
      • 1970-01-01
      • 2011-08-31
      • 1970-01-01
      相关资源
      最近更新 更多