安装win_replace模块
代码示例:
- 通过命令行安装win_replace模块
ansible-galaxy collection install community.windows
- 将win_replace模块添加到ansible.cfg配置文件中
在[default]下面添加:
[default]
...
collections_paths=/path/to/collections
在[community.windows]下面添加:
[community.windows]
...
collections=community.windows
- 在playbook中使用win_replace模块
- name: Replace text in file
community.windows.win_replace:
path: C:\temp\file.txt
regexp: 'old text'
replace: 'new text'