Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The augeas insert command is throwing an error if I specify a lens and incl in the resource. I haven't really been able to find anyone with a similar problem. When I include the following resource it throws unhelpful error that just says

$file = "/etc/ldap.conf"
$comment_style = "#comment"
$lens = "Spacevars.lns"
augeas { "${file}":
  context => "/files${file}",
  changes => [
    "ins ${comment_style} before '*[1]'",
    "set ${comment_style}[1] 'Puppet has modified this file with augeas'",
  ],  
  incl => "/files${file}",
  lens => $lens,
}

I've tried the equivalent in augtool:

# augtool --noload --noautoload
augtool> set /augeas/load/Spacevars/lens "Spacevars.lns"
augtool> set /augeas/load/Spacevars/incl "/etc/ldap.conf"
augtool> load
augtool> ins #comment before /files/etc/ldap.conf/*[1]
augtool> set /files/etc/ldap.conf/#comment[1] 'Puppet has modified this file with augeas'
augtool> save
Saved 1 file(s)

I've found that without the insert command it works fine (although without the set command it breaks even in augtool complaining about a malformed child node). Puppet's error when running this with --debug.

Debug: Augeas[/etc/ldap.conf](provider=augeas): sending command 'ins' with params ["#comment", "before", "/files/etc/ldap.conf/*[1]"]
Debug: Augeas[/etc/ldap.conf](provider=augeas): Closed the augeas connection
Error: /Stage[main]/Augeasdebug/Augeas[/etc/ldap.conf]: Could not evaluate: Error sending command 'ins' with params ["#comment", "before", "/files/etc/ldap.conf/*[1]"]/Error sending command 'ins' with params ["#comment", "before", "/files/etc/ldap.conf/*[1]"]

Without the lens and incl options it works fine, although I need to be able to specify these. I'm only just starting to use augeas, but I can't find that much relevant documentation using puppet with augeas. I had to guess the equivalent augtool commands.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The incl parameter takes the path to the file in the filesystem, not in the Augeas tree, so you must remove /files from the incl parameter.

Because you put /files in the incl parameter, Augeas cannot find the file to parse, and ins tries to insert before a non-existing path, which is an error.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.