简体   繁体   English

从group_vars到另一个的ansible import / include变量定义

[英]Ansible import/include variable definition from one of the group_vars to another

I need to import all variables defined in /environments/prod/group_vars/test1 to ./environments/prod/group_vars/test2 . 我需要将/environments/prod/group_vars/test1定义的所有变量导入到./environments/prod/group_vars/test2


Suppose the content of test1 is as follows: 假设test1的内容如下:

datacenter: ashburn 

I need the same to be on test2 . 我需要在test2

似乎对于特定环境所需的公共变量,我们可以创建“ group_vars / all”文件,对于host_group相关变量,我们可以使用“ group_vars / test1”文件。

Create a new inventory group 'tests_common_vars' that has 'test1' and 'test2' as children: 创建一个具有“ test1”和“ test2”作为子级的新库存组“ tests_common_vars”:

[tests_common_vars:children]
test[1:2]

and put all the common variables in 'group_vars/tests_common_vars' 并将所有通用变量放在“ group_vars / tests_common_vars”中

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

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