首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >书写Augeas透镜

书写Augeas透镜
EN

Stack Overflow用户
提问于 2013-11-21 04:12:28
回答 2查看 692关注 0票数 0

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

代码语言:javascript
复制
auth = true

Augeas有一个蒙戈透镜,但是它只适用于augeas > 1.0

我完全卡在Augeas0.9,因为它是最新的版本在epel回购,我无法编译 augeas从github。

作为一项工作,我正在尝试写我自己的augeas镜头,它将在augeas 0.9上工作

到目前为止,我所拥有的是

代码语言:javascript
复制
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

当我尝试使用木偶类型将镜头应用到/etc/mongodb.conf时,我会得到一个错误:“迭代镜头匹配得比它应该的要少”。

代码语言:javascript
复制
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

镜头怎么了?

我如何从命令行测试镜头并将木偶从等式中取出?

EN

回答 2

Stack Overflow用户

发布于 2013-11-21 09:22:06

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

您应该能够重新构建包,或者等待CentOS为您完成此任务。

票数 1
EN

Stack Overflow用户

发布于 2015-07-15 07:43:56

我和augeas和傀儡也有过类似的问题。每次应用更改似乎都会随着错误Could not evaluate: Save failed with return code false而结束。结果发现这是一个语法问题。我有:

代码语言:javascript
复制
set spec[user = '%somegroup']/host_group/command/tag  NOPASSWD

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20112311

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档