Feature: make files.blockinfile more consistent with Ansible
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- ansible, python
- Domain
- devops, infrastructure
Research direction
Start by reviewing issue #1477 and the existing files.line, files.blockinfile, files.template, and files.directory operations, along with the linked Ansible lineinfile documentation. Resolve whether an alias and parameter harmonization are wanted, then define a concrete compatibility scope; the issue is done when those decisions and the resulting changes are agreed and implemented.
Written by the indexing model from the issue text.
Description
Following the comments in #1477, for files.line this issue summarizes the differences between pyinfra and Ansible and proposes changes.
Summaries and proposals for blockinfile and template will follow if this is useful.
The first question is whether or not to add files.lineinfile as an alias for files.line and if so, whether or not to deprecate files.line ? The second question is if the alias is added, are the parameter names harmonized in the newly added alias as given the differences visible in the table below, the difference in names seems to be a good hint things are not identical.
Opinions ?
The third question is how do the parameters compare. The table below compares pyinfra's files.line to Ansible's lineinfile and proposes updates to files.line. Ansible's parameter aliases have been ignored in the analysis.
| Ansible | pyinfra | Purpose | Proposal |
|---|---|---|---|
attributes |
none | file system attributes for chattr |
do not add [1] |
backrefs |
interpolate_variables |
populate references in line from values found by regex |
exists |
backup |
backup |
whether to backup the file | exists |
create |
none | controls whether file created if it doesn't exist | add [2] |
encoding |
none | character set in which file is encoded | do not add [1] |
| none | ensure_newline |
ensure the appended line is on a new line | n/a |
| none | escape_regex_characters |
escape regex characters from the matching line | n/a |
firstmatch |
none | used with insertafter/before | do not add [3] |
| none | flags |
flags to be passed to sed | n/a |
group |
none | filesystem group for chown |
add [4] |
insertafter |
none | where to insert the line | do not add [3] |
insertbefore |
none | where to insert the line | do not add [3] |
line |
replace |
the line/template to insert/replace | exists |
mode |
none | the filesystem permissions | add [4] |
owner |
none | filesystem owner for chown |
add [4] |
path |
path |
file to modify | exists |
regex |
line |
the pattern to look for | exists |
search_string |
line |
the literal string to look for | do not add [5] |
selevel |
none | the SELinux MLS/MCS | do not add [1] |
serole |
none | the SELinux role | do not add [1] |
setype |
none | the SELinux type | do not add [1] |
seuser |
none | the SELinux seuser | do not add [1] |
state |
present |
whether the line should be present or not | no change - most (all ?) other pyinfra operations use present |
unsafe_writes |
none | whether unsafe writes are permitted if necessary | do not add [1] |
validate |
none | the validation command to run after the file is updated | do not add [1] |
[1] none of the operations in pyinfra have these attributes so any change should be made pyinfra-wide and not only in these three operations
[2] should save some repeated checking
[3] defer as this likely would require awk and thus complexity similar to that found in files.blockinfile
[4] should save some extra operation invocations and files.directory already supports this
[5] use line and escape_regex_characters to get the same result
- Dominant language
- Python
- Stars
- 6k
- Forks
- 548
- Avg merge
- 7d 17h
- Merged PRs (30d)
- 13
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pyinfra-dev/pyinfra
-
facts new feature operations
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pyinfra-dev/pyinfra#1896 ·
-
bug facts operations
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pyinfra-dev/pyinfra#1869 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
pyinfra-dev/pyinfra#1235 · 2 comments · 2 reactions ·
-
bug operations
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
pyinfra-dev/pyinfra#1219 · 2 comments · 2 reactions ·
-
operations spec
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pyinfra-dev/pyinfra#1207 · 2 comments ·
All issues in pyinfra-dev/pyinfra
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100