mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-09 01:44:03 -07:00
win_lineinfile backrefs bug fix and updated examples. (#20926)
* Bug Fix for win_lineinfile and updated examples. - changed $backrefs to a bool so it works with true/false/yes/no. This also fixes idempotency. - Updated Docs with an example of using backrefs. * Made suggested updates and converted two more parameters to "bool" * Updated the Exception message - Now contains the Windows Exception message as well as a custom message to help point in the right direction of a failed write. * Updated Exception Handling - Added Exception checks for Creating and removing the temporary files. - Changed the ErrorAction on the copy tmpfile and remove tmp file to "Stop" to cause the exception handler to catch all errors so we can fail gracefully every time.
This commit is contained in:
parent
52960ff7d0
commit
54de41309f
2 changed files with 67 additions and 43 deletions
|
@ -147,4 +147,11 @@ EXAMPLES = r'''
|
|||
path: C:\temp\testfile.txt
|
||||
line: Line added to file
|
||||
newline: unix
|
||||
|
||||
# Update a line using backrefs
|
||||
- win_lineinfile:
|
||||
path: C:\temp\example.conf
|
||||
backrefs: yes
|
||||
regexp: '(^name=)'
|
||||
line: '$1JohnDoe'
|
||||
'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue