Ansible:如何从查找文件创建变量

不受欢迎

我们有许多csv文件,其中包含各种配置的查找数据。

#eg of lookup file csv
hostname,ip,country,type,port
atlanta1,1.2.3.4,US,ui,8080
toronto1,1.2.3.5,CA,ui,8080
toronto2,1.2.3.9,CA,db,8000
another3,1.2.3.6,UK,db,8000

我们需要填充复杂的连接变量,然后将其用于其他剧本中,

# Eg. concatenated variables  http:{{hostname}}:{{port}} from above lookup csv file
ui_cluster = http://atlanta1:8080;http://toronto1:8080
db_cluster = http://atlanta1:8000;http://toronto1:8000

..最后,级联变量在最终的剧本中使用

#configurations in final customer template
my_build_script_UIcluster= {{ui_cluster}}
my_build_script_DBcluster= {{db_cluster}}

我想使用从上面的查找创建的变量,以在模板中使用。如何做到这一点或最佳方法?

缺口

include_csv模块https://github.com/mkouhei/ansible-role-includecsv听起来就像你在找什么。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章