User Tools

Site Tools


augeas

Augeas

this is nice tool to modify / edit file using script or puppet.

Here are the few command line reference || example.

Using with Puppet

Inbuilt lenses.

augeas { "sudoers":
  lens    => "Sudoers.lns",
  incl    => "/foo/sudoers",
  changes => "...",
}

Adding new file to modify.

   augeas { "idmapd_reg":
      lens   => "Phpvars.lns",
      incl   => "/etc/idmapd.conf",
      changes => [
         "set General/Domain 'k2patel.in'",
       ],
   }

Command line

How to use it on command line. use case may vary.<BR> Please see below for some command i use many times.

Usecase 1:

set /augeas/load/Phpvars/lens "Phpvars.lns"
set /augeas/load/Phpvars/incl "/var/www/vhosts/k2patel.in/sites/default/settings.php"
 
print /augeas/load
 
Search for your newly added stuff.
 
load

Usecase 2:

augtool -At "Simplelines.lns incl /usr/share/tomcat/conf/logging.properties"
 
/files/usr/share/tomcat/conf/logging.properties/21 = "org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO"
/files/usr/share/tomcat/conf/logging.properties/19 = "org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO"
/files/usr/share/tomcat/conf/logging.properties/17 = "org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO"

You can run 'augtool' and serch for the lenses provided in `ls /augeas/load/`

Usecase 3:

/opt/puppetlabs/puppet/bin/augtool -At "Logrotate.lns incl /etc/logrotate.d/httpd"
print
get /files/etc/logrotate.d/httpd/rule/delaycompress
rm /files/etc/logrotate.d/httpd/rule/delaycompress
set /files/etc/logrotate.d/httpd/rule/schedule monthly

Logrotate

   augeas { "apache_logrotate":
     lens    => "Logrotate.lns",
     incl    => "/etc/logrotate.d/httpd",
     changes => [
        "rm /files/etc/logrotate.d/httpd/rule/delaycompress",
        "set /files/etc/logrotate.d/httpd/rule/rotate 99999",
        "set /files/etc/logrotate.d/httpd/rule/schedule monthly",
     ],
   }
augeas.txt · Last modified: 2020/08/10 02:35 (external edit)