1

I want to do something along the lines of:

set /files/etc/exports/dir[. = '/export/home'][client = '10.0.0.0/8'] /export/home
set /files/etc/exports/dir[. = '/export/home'][client = '10.0.0.0/8']/client 10.0.0.0/8

What happens if I run the above is that the second command creates yet another new node, without any dir value set. My challenge is that /export/home share is not a unique dir, as clients are added on new lines for readability. I need both dir and client search options to find a unique node.

How can I reference the (maybe) newly created node in command 1, such that the end result is:

/export/home 10.0.0.0/8()
Jon Skarpeteig
  • 951
  • 2
  • 14
  • 29

1 Answers1

1

Augeas have something called defnode which do a set command and store the resulting node in the variable specified.

Solution to my problem:

defnode newdir /files/etc/exports/dir[. = '/export/home' and client = '10.0.0.0/8'] /export/home
set $newdir/client 10.0.0.0/8
set $newdir/client/option[1] rw
set $newdir/client/option[2] async
set $newdir/client/option[3] no_subtree_check

*Edit: Changed ][ to and for better readability

Jon Skarpeteig
  • 951
  • 2
  • 14
  • 29
  • 1
    That is indeed the best option. As a note, it is better to use `[a and b]` than `[a][b]`. – raphink Nov 26 '13 at 17:51
  • It's not only a matter of readability, it's a different logic. `[a][b]` selects first the nodeset that matches `[a]`, and then selects another sub-nodeset from it that matches `[b]`; while `[a and b]` only does one matching, on the `[a and b]` condition. – raphink Dec 03 '13 at 18:46