Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Deleting lines from configuration files #545

Open
kraileth opened this issue Dec 30, 2024 · 0 comments
Open

Feature: Deleting lines from configuration files #545

kraileth opened this issue Dec 30, 2024 · 0 comments

Comments

@kraileth
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant