#puppet agent –test –debug
Debug: Augeas[mcollective](provider=augeas): Opening augeas with root /, lens path , flags 32
Debug: Augeas[mcollective](provider=augeas): Augeas version 0.9.0 is installed
Debug: Augeas[mcollective](provider=augeas): Unable to optimize files loaded by context path, no glob matches
Debug: Augeas[mcollective](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[mcollective](provider=augeas): sending command ‘set’ with params [“/files/etc/mcollective/server.cfg/plugin.stomp.host”, “hosthosthost”]
Debug: Augeas[mcollective](provider=augeas): sending command ‘set’ with params [“/files/etc/mcollective/server.cfg/plugin.stomp.port”, “61613”]
Debug: Augeas[mcollective](provider=augeas): sending command ‘set’ with params [“/files/etc/mcollective/server.cfg/plugin.stomp.user”, “mcollectivemcollective”]
Debug: Augeas[mcollective](provider=augeas): sending command ‘set’ with params [“/files/etc/mcollective/server.cfg/plugin.stomp.password”, “passwordhere”]
Debug: Augeas[mcollective](provider=augeas): Skipping because no files were changed
Debug: Augeas[mcollective](provider=augeas): Closed the augeas connection
Building your own augeas lens from scratch might be very frustrating for some people because of the language. Our main goal is to enable editing any application files. Therefore we are just going to use any working augeas lens.
In this example, I will build mcollective lense for both server and client. We are going to put our lens in /usr/share/augeas/lenses instead of /usr/share/augeas/lenses/dist to avoid overwriting default lenses.
Since mcollective config files are similar to sysctl.conf config file, we just need to copy from it:
cp /usr/share/augeas/lenses/dist/sysctl.aug /usr/share/augeas/lenses/mcollective.aug
Modify the file to suit name and location of your config file.
Our mcollective.aug would then be like this:
module MCollective =
autoload xfm
let filter = incl "/etc/mcollective/server.cfg"
. incl "/etc/mcollective/client.cfg"
let eol = Util.eol
let indent = Util.indent
let key_re = /[A-Za-z0-9_.-]+/
let eq = del /[ \t]*=[ \t]*/ " = "
let value_re = /[^ \t\n](.*[^ \t\n])?/
let comment = [ indent . label "#comment" . del /[#;][ \t]*/ "# "
. store /([^ \t\n].*[^ \t\n]|[^ \t\n])/ . eol ]
let empty = Util.empty
let kv = [ indent . key key_re . eq . store value_re . eol ]
let lns = (empty | comment | kv) *
let xfm = transform lns filter
Since augtool doesn’t provide enough error log, we will use augparse to check the built lens.
#augparse mcollective.aug
Fix any error.
Note: augtool and augparse are available in augeas and augeas-devel.
Done! You can now distribute this over puppet to customize any puppet client applications config file.
However if you’d rather use any available lens without having to distribute aug file, you can do like this:
augeas { "mcollective":
context => "/files/etc/mcollective/server.cfg",
#similar to sysctl.lns
incl => "/etc/mcollective/server.cfg",
lens => "sysctl.lns",
changes => [
... bla bla bla
],
require => [ Package['mcollective'], ],
notify => Service['mcollective'],
}
]]>