我正试图通过/etc/elasticsearch/elasticsearch.yml资源在傀儡清单中修改/设置augeas文件,但它不起作用。有人能解释一下我应该指定什么lens文件吗?我是否需要为这个安装一些额外的东西,还是在默认安装中包括了所需的镜头?
我试图像这样更改键值对:
key1.key2: value
eg:
cluster.name: cms-es我的代码:
augeas { "elastic_config":
context => "/files/etc/elasticsearch/elasticsearch.yml",
changes => [
"set 'network.host:' ipaddress_eth0",
"set 'cluster.name:' cms-es",
"set 'node.name:' ec2_hostname",
"set 'bootstrap.mlockall:' true",
],
}发布于 2016-04-05 21:15:44
这不是最好的解决方案,但如果您只依赖于冒号分隔的配置文件,我就有一个镜头。
在/usr/share/augeas/lens/colonvars.aug中复制和粘贴以下内容(或者使用奥吉斯模块来实现这一点)。
(*
Module: Colonvars
Parses a simple colon (:) delimited files
Author: Alex Simenduev <shamil.si@gmail.com>
About: Usage Example
(start code)
augtool> set /augeas/load/Colonvars/lens "Colonvars.lns"
augtool> set /augeas/load/Colonvars/incl "/etc/elasticsearch/elasticsearch.yml"
augtool> load
augtool> get /files/etc/elasticsearch/elasticsearch.yml/cluster.name
/files/etc/elasticsearch/elasticsearch.yml/cluster.name = elk
augtool> set /files/etc/elasticsearch/elasticsearch.yml/node.name elk-node-0
augtool> save
Saved 1 file(s)
$ grep node.name /etc/elasticsearch/elasticsearch.yml
node.name: elk-node-0
(end code)
About: License
This file is licensed under the LGPL v2+, like the rest of Augeas.
*)
module Colonvars =
let colon = del /[ \t]*:[ \t]*/ ": "
let entry = Build.key_value_line Rx.word colon (store Rx.space_in)
let lns = (Util.empty | Util.comment | entry)*下面是如何使用它(基于您的示例):
augeas { "elastic_config":
incl => "/etc/elasticsearch/elasticsearch.yml",
lens => "Colonvars.lns",
changes => [
"set network.host ipaddress_eth0",
"set cluster.name cms-es",
"set node.name ec2_hostname",
"set bootstrap.mlockall true",
]
}发布于 2016-01-22 17:08:53
Augeas当前无法编辑YAML文件,因为无法使用Augeas镜头描述YAML语法。需要对Augeas的核心进行修改,以支持这一点(以支持一致的in,这对于这种格式来说是强制性的)。
https://stackoverflow.com/questions/34951337
复制相似问题