在Anisble上,如何根据主机/服务使用不同的postgresql.conf文件?

问题描述 投票:0回答:1

我正在运行两个不同的服务器,每个服务器都有不同的postgres用例,因此,我希望每个postgres服务都在不同的配置上运行(在postgresql.conf中定义)。

当前的ansible设置如下所示,其中postgresql是role

postgresql
├── handlers
│   └── main.yml
├── tasks
│   └── main.yml
└── templates
    ├── pg_hba.conf
    └── postgresql.conf

我的目标是了解执行此操作的最佳实践,而不必给postgresql.conf文件指定其他名称(如果可能)

postgresql ansible ansible-inventory
1个回答
0
投票

我将以这种方式注册需要在清单中使用的文件:

all:
  children:
    postgress:
      hosts:
        host1:
          postgress_conf: postgresql.conf
        host2:
          postgress_conf: pg_hba.conf

然后使用剧本copy任务中的变量:

copy
© www.soinside.com 2019 - 2024. All rights reserved.