如何使用ansible遍历文件中的每一行? [英] How do I loop over each line inside a file with ansible?

查看:29
本文介绍了如何使用ansible遍历文件中的每一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找类似于 with_items: 的东西,但它可以从文件中获取项目列表,而不必将其包含在剧本文件中.

I am looking for something that would be similar to with_items: but that would get the list of items from a file instead of having to include it in the playbook file.

我怎样才能在ansible中做到这一点?

How can I do this in ansible?

推荐答案

我设法找到了一个简单的替代方案:

I managed to find an easy alternative:

- debug: msg="{{item}}"
  with_lines: cat files/branches.txt

这篇关于如何使用ansible遍历文件中的每一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆