logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

cdist-type__line - Manage lines in files

Authors

       Steven Armstrong <steven-cdist--@--armstrong.cc>

Boolean Parameters

       None.

Copying

       Copyright (C) 2018 Steven Armstrong. Free use of this software is granted under  the  terms  of  the  GNU
       General Public License version 3 (GPLv3).

Description

       This cdist type allows you to add lines and remove lines from files.

Examples

          # Manage a hosts entry for www.example.com.
          __line /etc/hosts \
              --line '127.0.0.2 www.example.com'

          # Manage another hosts entry for test.example.com.
          __line hosts:test.example.com \
              --file /etc/hosts \
              --line '127.0.0.3 test.example.com'

          # Remove the line starting with TIMEZONE from the /etc/rc.conf file.
          __line legacy_timezone \
             --file /etc/rc.conf \
             --regex 'TIMEZONE=.*' \
             --state absent

          # Insert a line before another one.
          __line password-auth-local:classify \
              --file /etc/pam.d/password-auth-local \
              --line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \
              --before '^session[[:space:]]+include[[:space:]]+password-auth-ac$'

          # Insert a line after another one.
          __line password-auth-local:classify \
              --file /etc/pam.d/password-auth-local \
              --line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \
              --after '^session[[:space:]]+include[[:space:]]+password-auth-ac$'

          # Uncomment as needed and set a value in a configuration file.
          __line /etc/example.conf \
              --line 'SomeSetting SomeValue' \
              --regex '^(#[[:space:]]*)?SomeSetting[[:space:]]' \
              --state replace

Messages

added  The line was added.

       updated
              The line or its position was changed.

       removed
              The line was removed.

Name

       cdist-type__line - Manage lines in files

Optional Parameters

after  Insert the given line after this pattern.

       before Insert the given line before this pattern.

       file   If supplied, use this as the destination file.  Otherwise the object_id is used.

       line   Specifies the line which should be absent or present.

              Must  be  present,  if  state  is  'present' or 'replace'.  Ignored if regex is given and state is
              'absent'.

       regex  If state is 'present', search for this pattern and if it matches add the given line.

              If state is 'absent', ensure all lines matching the regular expression are absent.

              If state is 'replace', ensure all lines matching the regular expression are exactly 'line'.

              The regular expression is interpreted by awk's match function.

       state  'present', 'absent' or 'replace', defaults to 'present'.

       onchange
              The code to run if line is added, removed or updated.

Required Parameters

       None.

See Also

cdist-type(7)

See Also