pyinfra-dev / pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://pyinfra.com
MIT License
3.85k stars 374 forks source link

files.line grep inserts wrong regex #1019

Open JustScreaMy opened 11 months ago

JustScreaMy commented 11 months ago

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

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 `-vv` and `--debug`.
This is grep generated by the files.line operation
`sh -c 'grep -e '"'"'^.*.+PasswordAuthentication.+.*$'"'"' /etc/ssh/sshd_config`
Fizzadar commented 9 months ago

Yep this looks wrong, thanks for reporting I'll fix this up!