LineInFile: New resource proposal #29
Labels
help wanted
The issue is up for grabs for anyone in the community.
resource proposal
The issue is proposing a new resource in the resource module.
Description
Many file formats do not match the pre-made assumptions of this module. E.g. the
KeyValuePairFile
resource almost matches my current requirement, however in my case the key and value should be separated by a colon, not an equal sign. This resource would be more general as it would allow the user to specify the line contents (Text
) and a regex to determine whether the line is already present. The proposal is modeled after the lineinfile module in Ansible, however in a simplified form. More options (likeInsertBefore
,InsertAfter
,FirstMatch
,Backrefs
,Backup
, etc) could be added if deemed necessary.Proposed properties
Path
: The file to modify.Create
: Whether the file should be created if not present (ifEnsure = 'Present'
).Text
: The line to insert (ifEnsure = 'Present'
)Regex
: The regular expression to find the line to modify. IfEnsure = 'Present'
the regular expression should match the state before and after modification to ensure idempotence. IfEnsure = 'Absent'
it will be used to determine whether the line needs to be removed. Only the last found instance will be modified.Special considerations or limitations
None that I could see.
The text was updated successfully, but these errors were encountered: