Windows 中的 Ansible 文件处理/blockinfile 模块

问题描述 投票:0回答:2

我想通过 ansible 更新 Windows 文件中的多行文本块。使用过blockinfile 但它仅适用于 Linux 机器。该模块有其他选择吗?或者还有其他方法可以做到这一点吗?有 win_lineinfile 但我还有大约 20 行要添加。 非常感谢任何帮助!!

windows ansible ansible-2.x ansible-module
2个回答
0
投票

目前还没有模块允许在 Windows 主机上写入行块。

您可能需要使用 win_shell 模块和 Powershell 的 Out-File cmdlet 作为解决方法


0
投票

我打包了 Marcus Watkins 命运多舛的 2019 PR 来添加

win_blockinfile
,你现在可以从 Ansible Galaxy 获取它。

https://galaxy.ansible.com/ui/repo/published/randrej/windows/

© www.soinside.com 2019 - 2024. All rights reserved.