繁体   English   中英

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

[英]On Ansible, how do I use different postgresql.conf files depending on the host/service?

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

当前 ansible 设置如下 postgresql,其中 postgresql 是一个role

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

我的目标是了解这样做的最佳做法是什么,而不必为postgresql.conf文件(如果可能)提供不同的名称。

您可以通过以下方式定义清单中需要使用的文件:

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

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

- hosts: postgress

  tasks:
    - copy:
        src: templates/{{ postgress_conf }}
        dest: /etc/postgresql/x.x/main/postgresql.conf

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM