在ansible中注册文件中的变量列表

时间:2018-05-15 09:56:06

标签: bash ansible

我有一个 / tmp / components_list 文件,内容如下:

ComponentA: '1263'
ComponentB: '989'
ComponentC: '1354'

我想根据文件的内容在ansible(没有引号)中注册变量,并在yml代码中使用它们。

因此,我需要这样的东西:

- name: Get variables from file 
  Some actions with a file /tmp/components_list

- name: Using these variables 
  shell: docker run --name component artifactory:5100/radware/Component:{{ComponentA}}

因此它应该是变量 ComponentA 中的数字。

如何使用ansible来做到这一点?谢谢!

1 个答案:

答案 0 :(得分:1)