伙计们,我想使用 ansible 实时打开文件,例如 pg_hba.conf(如 vim)并能够即时编辑它。我希望能够从 jenkins 中选择目标服务器组,读取特定节点的 pg_hba.conf 的内容,并将这些内容作为参数传递,我可以以自由格式文本进行编辑。在我按下“构建”按钮将新更改保存到节点组中之后。
2 回答
0
这是我的解决方案:
tasks:
-
name: cat the pg_file
shell: cat "{{ pg_path }}"
register: predata
- debug:
msg: "{{predata.stdout_lines|list}}"
于 2019-01-30T06:55:02.627 回答
0
您可以将其与诸如 copy、template、lineinfile、blockinfile 之类的 ansible 模块一起使用。
我认为最好的方法是使用模板模块,但有些时间 lineinfile 会为你工作(参见官方 ansible 模块文档)。
作为您问题的当前工作示例,请参阅此 git repo。
如果您有任何问题,请告诉我。
于 2019-01-28T13:41:54.923 回答