木偶插入失败的镜头和包括指定

如果我在资源中指定镜头和incl,augeas插入命令会引发错误。 我还没有真正find有类似问题的人。 当我包含下面的资源时,它会引发无用的错误

$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, } 

我已经尝试了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) 

我发现,没有插入命令,它工作正常(虽然没有设置命令它甚至在augtool抱怨畸形的子节点抱怨)。 用–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]"] 

没有镜头和incl选项它工作正常,但我需要能够指定这些。 我只是刚刚开始使用augeas,但我不能find与augeas使用木偶相关的文档。 我不得不猜测等效的augtool命令。

incl参数是文件系统中的文件的path,而不是在Augeas树中,因此必须从incl参数中删除/files

因为你把/files放在incl参数中,所以Augeas找不到parsing的文件,而ins试图插入一个不存在的path之前,这是一个错误。