[英]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.