[augeas-devel] Help for INI file variation

Zero Uno zerozerounouno at gmail.com
Mon Feb 24 12:11:42 UTC 2014


2014-02-22 9:44 GMT+01:00 Raphaël Pinson <raphael.pinson at camptocamp.com>:

[Comments only start with ";"]
> 1) is just a setting, like:
>
>     let comment = IniFile.comment ";" ";"

Indeed, I already got it working, even though I think I also had to remove
# from:

let comment_re    = ";"
let to_comment_re = /[^; \t\n][^;\n]*[^; \t\n]|[^; \t\n]/

[Entries can contain "@"]
> 2) shouldn't be a limitation at all.

Uhm, AFAIR parsing stopped there, until I added "@" to the entry regex:

let entry_re = ( /[A-Za-z][@#A-Za-z0-9\._-]+/ )

[Values can contain "#"]
> For 3), have a look at the PythonPaste module, which also allows for "#"
in
> values:

Thanks, I was looking at it after your suggestion, but AFAICT it allows "#"
in values by also prohibiting inline comments, which I need instead...

Anyway, while looking at it I though I could try starting customizing from
the Samba module samba.aug, and indeed it works now!
I just changed settings for comments:

let comment  = IniFile.comment ";" ";"
let sto_to_comment
             = Util.del_opt_ws " "
             . store /[^; \t\n][^;\n]*[^; \t\n]|[^; \t\n]/

Then added "@" for the entries:

let entry_re = /[A-Za-z0-9_.-][@A-Za-z0-9 _.:-]*[A-Za-z0-9_.-]/

And that's all.

[Double quotes in values]
> For 4), have a look at the Quote module (used in various lenses), which

Without any extra effort, double quotes seem to be interpreted fine when
printing values with augtool.

Now, my problem was how could I insert them when applying changes through
Puppet.
This is the solution I found (
https://groups.google.com/d/msg/puppet-users/tHMPdFiUM-U/3W9HESPhWYAJ):

augeas { 'myconf':
  context  => '/files/myfilepath',
  changes  => 'set target[. = "mysection"]/myparameter \'"my value"\'',
}

Thanks for your suggestions!
Marco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20140224/3cce1dea/attachment.htm>


More information about the augeas-devel mailing list