+
Skip to content

Feature: Deleting lines from configuration files #545

@kraileth

Description

@kraileth

Description
Comtrya has gained a lot of nice features over the past few years, but it being a configuration management utility... well, eventually being able to modify actual configuration files, is pretty crucial.

Deleting lines from a (text) file might be a good first action. The examples here are meant to start a discussion on the topic.

Additional information
Here's three cases with examples below:

  1. Removing all lines that are exact matches of 'sendmail_enable="NO"' in the /etc/rc.conf file.
  2. Removing all lines that start with 'sendmail_enable', which would remove both the line of the previous example as well as 'sendmail_enable="YES"' (and a lot of other thinkable combinations, too, of course), effectively resetting a machine to the system default.
  3. Removing all lines which contain 'sendmail', also getting rid of entries like 'sendmail_msp_queue_enable="YES" and the like.
  4. (or 3b actually) Removing all the commented out lines in default configurations (those can be dozens to hundreds) is somewhat common task in system administration.

Manifest Example

actions:
  - action: lineinfile.delete
    target: /etc/rc.conf
    pattern: sendmail_enable="NO"
    mode: exact

- action: lineinfile.delete
    target: /etc/rc.conf
    pattern: sendmail_enable
    mode: startswith

  - action: lineinfile.delete
    target: /etc/rc.conf
    pattern: sendmail
    mode: contains

  - action: lineinfile:delete
    target: /usr/local/etc/nginx.conf
    pattern: #
    mode: contains

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载