try onlyif => "match alias include usb-storage"
it may be
"match alias[*] include usb-storage"
-- bk
Ok.. lets try this (lutter knows this voodoo better)
"match *[alias ='usb-storage'] size = 0 "
-- bk
ok.. I think this is it in augtool:
match /files/etc/modprobe.conf/*[.="foo"]
so.. in the plugin you can do
'match /files/etc/modprobe.conf/*[.="foo"] size = 0'
-- bk
more specific matching:
match /files/etc/modprobe.conf/alias[.="foo"]
Can you please send me your target modprobe.conf file?
-- bk
Can you please send me your target modprobe.conf file?> The problem with modprobe.conf is that it is more like:
>
> command args
>
> than
>
> key value
>
>
> key value usually has unique keys, but command args doesn't.
>
> It's kind of weird A lot of those commands work on something else, say
> /etc/hosts, or /etc/fstab, something that is key value, but just not working
> on /etc/modprobe.conf.
-- bk
It's not voodoo, it's XPath ;)
> "match *[alias ='usb-storage'] size = 0 "
That almost works, though shouldn't that second '=' be '==' ? (and maybe
we should make the augeas provider use '=' there, too, for consistency)
I would write this as
augeas { "usb-storage":
context => "/files/etc/modprobe.conf",
changes => [ "set alias[last()+1] usb-storage",
"set alias[last()]/modulename off",
],
onlyif => "match alias[.='usb-storage'] size == 0'
}
The fact that the modprobe.conf format is 'command args' with differing
meanings of the args for the various commands doesn't matter too much -
it just leads to different tree structures for those commands. For
example for the command 'alias NAME MODULE' the tree structure is
alias = 'NAME'
modulename = 'MODULE'
IOW, the name of the alias becomes the value of the 'alias' node, and
the name of the module is put as the value of a node labelled
'modulename'.
David
I believe you need
/files/etc/modprobe.conf/alias[.='usb-storage']