1

I am trying to use a Augeas resource to set the ServerName in my httpd.conf like so ...

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

... but I get this error:

[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

What am I doing wrong here?

Red Cricket
  • 9,762
  • 21
  • 81
  • 166

1 Answers1

1

Directives in the Httpd.lns lens are not node labels. Instead, the tree should look like this:

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

The way to achieve that with Puppet is:

augeas { 'ServerName':
    context => '/files/etc/httpd/conf/httpd.conf',
    changes => [
      'set directive[.="ServerName"] "ServerName"',
      "set directive[.="ServerName"]/arg '${controller_name}'",
    ],
}
raphink
  • 3,625
  • 1
  • 28
  • 39