1

I am searching for example of file which could be passed to the augeas:

augeas --f example/file

So far my file looks like this:

 set /files/etc/hosts/01/ipaddr 127.0.2.1
 set /files/etc/hosts/01/alias[1] testy
 set /files/etc/hosts/01/alias[2] test
 save

And if I pass the file to the augeas it tells me this:

 error: Failed to execute command
 saving failed (run 'print /augeas//error' for details)

Obviously, I did what the command line told me:

 janipav@janipav:~$ print /augeas//error
 Warning: unknown mime-type for "/augeas//error" -- using "application/octet-stream"
 Error: no such file "/augeas//error"

So, I am pretty much stuck here. Googling did not provide me anything, so I hope to find answer here. Thanks

Pavel Janicek
  • 14,128
  • 14
  • 53
  • 77
  • Note that the command `print /augeas//error` is something that should be done inside of augeas, not at the shell. If you had done that instead of your `save` command, or right before the `save` command, then augeas would show you what the error messages were. – Brad Knowles Apr 22 '15 at 22:27

1 Answers1

1

The canonical node is mandatory for hosts entries with the Hosts.lns lens, so you need:

set /files/etc/hosts/01/ipaddr 127.0.2.1
set /files/etc/hosts/01/canonical localhost2
set /files/etc/hosts/01/alias[1] testy
set /files/etc/hosts/01/alias[2] test
save

Note that this change is not idempotent, it will create a new entry at every run.

raphink
  • 3,625
  • 1
  • 28
  • 39