1

我正在尝试使用 Augeas 资源来设置ServerNamehttpd.conf喜欢的...

# configure Apache HTTP server
augeas { 'ServerName':
    context => '/files/etc/httpd/conf/httpd.conf',
    changes => "set ServerName ${controller_name}",
} ->

...但我收到此错误:

[Debug: Augeas[ServerName](provider=augeas): Opening augeas with root /, lens path , flags 32^[[0m
[Debug: Augeas[ServerName](provider=augeas): Augeas version 1.2.0 is installed^[[0m
[Debug: Augeas[ServerName](provider=augeas): Will attempt to save and only run if files changed^[[0m
[Debug: Augeas[ServerName](provider=augeas): sending command 'set' with params ["/files/etc/httpd/conf/httpd.conf/ServerName", "svl-ost-centos.cisco.com"]^[[0m
[Debug: Augeas[ServerName](provider=augeas): Put failed on one or more files, output from /augeas//error:^[[0m
[Debug: Augeas[ServerName](provider=augeas): /augeas/files/etc/httpd/conf/httpd.conf/error = put_failed^[[0m
[Debug: Augeas[ServerName](provider=augeas): /augeas/files/etc/httpd/conf/httpd.conf/error/path = /files/etc/httpd/conf/httpd.conf^[[0m
[Debug: Augeas[ServerName](provider=augeas): /augeas/files/etc/httpd/conf/httpd.conf/error/lens = /opt/puppet/share/augeas/lenses/dist/httpd.aug:88.10-.44:^[[0m
[Debug: Augeas[ServerName](provider=augeas): /augeas/files/etc/httpd/conf/httpd.conf/error/message = Malformed child node 'ServerName'^[[0m
[Debug: Augeas[ServerName](provider=augeas): Closed the augeas connection^[[0m
[Error: /Stage[main]/Wrapcontroller/Augeas[ServerName]: Could not evaluate: Saving failed, see debug^[[0m

我在这里做错了什么?

4

1 回答 1

1

镜头中的指令Httpd.lns不是节点标签。相反,树应该是这样的:

/directive = "ServerName"
/directive/arg = "${controller_name}"

使用 Puppet 实现这一目标的方法是:

augeas { 'ServerName':
    context => '/files/etc/httpd/conf/httpd.conf',
    changes => [
      'set directive[.="ServerName"] "ServerName"',
      "set directive[.="ServerName"]/arg '${controller_name}'",
    ],
}
于 2015-12-04T22:05:37.573 回答