Skip to content

LineInFile: New resource proposal #29

@wildmichael

Description

@wildmichael

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 (like InsertBefore, 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 (if Ensure = 'Present').
  • Text: The line to insert (if Ensure = 'Present')
  • Regex: The regular expression to find the line to modify. If Ensure = 'Present' the regular expression should match the state before and after modification to ensure idempotence. If Ensure = '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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedThe issue is up for grabs for anyone in the community.resource proposalThe issue is proposing a new resource in the resource module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions