pyinfra
pyinfra copied to clipboard
files.line grep inserts wrong regex
Describe the bug
Using files.line to replace single line produces incorrect fact, so the line is never replaced and therefore automatically inserted at the end of the file
To Reproduce
- Operation code & usage
from pyinfra.operations import files
files.line(
name="Disable password login",
path="/etc/ssh/sshd_config",
line="PasswordAuthentication .+",
replace="PasswordAuthentication no"
)
Expected behavior
This code should match line containing PasswordAuthentication yes and replace in with PasswordAuthentication no
Meta
- Consider including output with
-vvand--debug. This is grep generated by the files.line operationsh -c 'grep -e '"'"'^.*.+PasswordAuthentication.+.*$'"'"' /etc/ssh/sshd_config
Yep this looks wrong, thanks for reporting I'll fix this up!