Information Technology Reference
In-Depth Information
template " #{ document_root } /index.html" ddo
source 'index.html.erb'
mode '0644'
variables (
:message => node [ 'motd' ][ 'message' ] ,
:port => node [ 'apache' ][ 'port' ]
)
end
end
Generate the template file templates/default/index.html.erb , using the appropriate command
line for your Chef development setup.
Chef Development Kit:
$ chef generate template index.html
Chef Client - Linux/Mac OS X:
$ touch templates/default/index.html.erb
Chef Client - Windows:
$ touch templates\default\index.html.erb
Create the file templates/default/index.html.erb as shown in Example 15-9 . We are using the
short variable instance forms we defined in the variables() attribute of the template re-
source. Also, for some variety, we left one of them as the standard form:
node["ipaddress"] . You can mix and match these forms as you like.
Example 15-9. chefdk/chef-zero/apache/templates/default/index.hmtl.erb
<html>
<html>
<body>
<body>
<h1>
</h1>
< %= node["ipaddress"] %>: < %= @port %>
</body>
<h1> < %= @message %> </h1>
</body>
</html>
</html>
Generate one more template file, templates/default/custom.erb , which will be used as an
apache configuration file.
Chef Development Kit:
Search WWH ::




Custom Search