【问题标题】:Writing an Augeas lens写一个 Augeas 镜头
【发布时间】:2013-11-21 04:12:28
【问题描述】:

我需要在 /etc/mongodb.conf 中编辑一行

auth = true

Augeas 有一个mongo lens,但它只适用于 augeas > 1.0

我完全坚持使用 augeas 0.9,因为它是 epel repo 中的最新版本,我来自 github 的 can not compile augeas。

作为一种解决方法,我正在尝试编写自己的 augeas 镜头,该镜头适用于 augeas 0.9

我目前拥有的是这个

module Spencer =

autoload xfm

let entry = key /[a-z]+/ . del /[ \t]*=[ \t]*/ "=" . store /[a-z]+/
let lns = [ entry . del "\n" "\n" ] *

test lns get "auth = false\nfoo = bar\n" = ?

let filter = incl "/etc/mongodb.conf"
let xfm = transform lns filter

当我尝试使用 puppet 类型将镜头应用到 /etc/mongodb.conf 时,我收到错误“迭代镜头匹配少于应有的情况”。

puppet apply augmongo.pp --debug --verbose  --summarize
Info: Applying configuration version '1385024927'
Debug: Augeas[auth-mongo](provider=augeas): Opening augeas with root /, lens path , flags 64
Debug: Augeas[auth-mongo](provider=augeas): Augeas version 0.9.0 is installed
Test result: /usr/share/augeas/lenses/dist/spencer.aug:8.0-.44:
  { "auth" = "false" }
  { "foo" = "bar" }

Debug: Augeas[auth-mongo](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[auth-mongo](provider=augeas): sending command 'set' with params ["/files/etc/mongodb.conf/auth", "true"]
Debug: Augeas[auth-mongo](provider=augeas): Put failed on one or more files, output from /augeas//error:
Debug: Augeas[auth-mongo](provider=augeas): /augeas/files/etc/mongodb.conf/error = put_failed
Debug: Augeas[auth-mongo](provider=augeas): /augeas/files/etc/mongodb.conf/error/pos = 1
Debug: Augeas[auth-mongo](provider=augeas): /augeas/files/etc/mongodb.conf/error/lens = /usr/share/augeas/lenses/dist/spencer.aug:6.10-.37:
Debug: Augeas[auth-mongo](provider=augeas): /augeas/files/etc/mongodb.conf/error/message = Iterated lens matched less than it should
Debug: Augeas[auth-mongo](provider=augeas): Closed the augeas connection
Error: /Stage[main]/Augmongo/Augeas[auth-mongo]: Could not evaluate: Save failed with return code false, see debug
Debug: Finishing transaction 69857417180740
Debug: Storing state
Debug: Stored state in 0.13 seconds

镜头出了什么问题?
如何从命令行测试镜头并将人偶排除在等式之外?

【问题讨论】:

  • 如果无法编译就重写镜头有点矫枉过正。其他人已经在 RH 6 上成功编译了 Augeas 1.1。

标签: mongodb puppet augeas


【解决方案1】:

RHEL 6.4 刚刚升级到 Augeas 1.0。见https://rhn.redhat.com/errata/RHSA-2013-1537.html

您应该能够重建软件包,或等待 CentOS 为您完成。

【讨论】:

    【解决方案2】:

    我在 augeas 和 puppet 上也遇到过类似的问题。每次应用更改似乎都以错误Could not evaluate: Save failed with return code false 结束。原来这是一个语法问题。我有:

    set spec[user = '%somegroup']/host_group/command/tag  NOPASSWD
    

    (注意tagNOPASSWD 之间有两个空格)。 当我用一个空格尝试相同的命令时,问题就解决了。 查看模板/镜头(spencer.aug,第 6.10-.37 行)可能会提供一些线索来找出问题所在。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-06
      • 2016-11-28
      • 2020-12-16
      相关资源
      最近更新 更多