0
file.txt
win_lineinfile使用して、Windows上のファイルに置き換えます。検索し、次のように内容を
userName = 'ABCD'
password = 'XYZ'
Ansibleの脚本を使用して、Windows上のユーザ名とパスワードを検索および置換する方法。
file.txt
win_lineinfile使用して、Windows上のファイルに置き換えます。検索し、次のように内容を
userName = 'ABCD'
password = 'XYZ'
Ansibleの脚本を使用して、Windows上のユーザ名とパスワードを検索および置換する方法。
これは、以下のように、潜在的なwin_lineinfileモジュールを使用して行うことができます。
- name: Update file.txt
win_lineinfile:
dest='c:\file.txt' backrefs=yes state=present
regexp='^\{{ item.search_patttern }}\s*=\s*[\`\~\!\@\#\$\%\^\&\*\(\)\-\+\=\{\[\}\]\\\|\:\;\"\'\<\,\>\.\?\/\w]*'
line="{{ item.replacement }}"
with_items:
- { search_patttern: "username", replacement: "userName = \'NewUser\'" }
- { search_patttern: "password", replacement: "password = \'NewPassword\'" }