This shows you the differences between two versions of the page.
augeas [2017/02/10 20:43] k2patel [Command line] |
augeas [2020/08/10 02:35] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== 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. | ||
- | <code ruby> | ||
- | augeas { "sudoers": | ||
- | lens => "Sudoers.lns", | ||
- | incl => "/foo/sudoers", | ||
- | changes => "...", | ||
- | } | ||
- | </code> | ||
- | |||
- | Adding new file to modify. | ||
- | <code ruby> | ||
- | augeas { "idmapd_reg": | ||
- | lens => "Phpvars.lns", | ||
- | incl => "/etc/idmapd.conf", | ||
- | changes => [ | ||
- | "set General/Domain 'k2patel.in'", | ||
- | ], | ||
- | } | ||
- | </code> | ||
- | |||
- | ==== 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: | ||
- | <code bash> | ||
- | 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 | ||
- | </code> | ||
- | |||
- | Usecase 2: | ||
- | <code bash> | ||
- | 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" | ||
- | </code> | ||
- | |||
- | You can run 'augtool' and serch for the lenses provided in `ls /augeas/load/` | ||
- | |||
- | Usecase 3: | ||
- | <code bash> | ||
- | /opt/puppetlabs/puppet/bin/augtool -At "Logrotate.lns incl /etc/logrotate.d/httpd" | ||
- | |||
- | 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 | ||
- | </code> | ||
- | |||
- | === Logrotate === | ||
- | <code ruby> | ||
- | 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", | ||
- | ], | ||
- | } | ||
- | </code> |