【问题标题】:augeas in puppet does not change filepuppet 中的 augeas 不会更改文件
【发布时间】:2016-07-06 07:23:59
【问题描述】:

我想使用 Puppet 的 Augeas 管理 carbon.conf 文件的内容。我以前在 Puppet 中使用过 Augeas 来管理 xml 文件,效果很好。

但是,这一次应用 puppet 目录时,carbon.conf 文件没有任何反应。日志中也没有错误。 这是我在 puppet 清单文件中的代码:

augeas { 'cache config':
  notify  => Service[carbon-cache],
  incl    => '/opt/graphite/conf/carbon.conf',
  context => '/cache',
  lens    => 'Carbon.lns',
  changes => [
    "set UDP_RECEIVER_PORT 2013",
    "set LINE_RECEIVER_PORT 2013",
    "set PICKLE_RECEIVER_PORT 2014",
  ];
}

在调试日志中我可以看到以下内容:

Debug: Augeas[cache config](provider=augeas): Opening augeas with root /, lens path /var/lib/puppet/lib/augeas/lenses, flags 64
Debug: Augeas[cache config](provider=augeas): Augeas version 1.0.0 is installed
Debug: Augeas[cache config](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[cache config](provider=augeas): sending command 'set' with params ["/cache/UDP_RECEIVER_PORT", "2013"]
Debug: Augeas[cache config](provider=augeas): sending command 'set' with params ["/cache/LINE_RECEIVER_PORT", "2013"]
Debug: Augeas[cache config](provider=augeas): sending command 'set' with params ["/cache/PICKLE_RECEIVER_PORT", "2014"]
Debug: Augeas[cache config](provider=augeas): Skipping because no files were changed
Debug: Augeas[cache config](provider=augeas): Closed the augeas connection

我在这里错过了什么?

我还注意到,当从命令行使用augtool 时,ls /files/ 命令仅列出以下文件夹

augtool> ls /files/
etc/ = (none)
usr/ = (none)
boot/ = (none)

我也希望在这里看到/opt...

【问题讨论】:

    标签: puppet graphite augeas


    【解决方案1】:

    上下文需要包含您想要的相对路径的基本节点的完整路径。在您的情况下,我猜您希望上下文为 /files/opt/graphite/conf/carbon.conf/cache

    【讨论】:

    • 谢谢,我想我不太了解上下文参数的 puppet 参考文档Optional context path. This value is prepended to the paths of all changes if the path is relative. If the incl parameter is set, defaults to /files + incl; otherwise, defaults to the empty string.
    • 一般情况下,在 Augeas 中,以/ 开头的路径是绝对路径,所以/cache 肯定不是您想要使用的。
    猜你喜欢
    • 1970-01-01
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-29
    • 1970-01-01
    • 2015-10-26
    • 2015-08-18
    相关资源
    最近更新 更多