Embedded Ruby (ERB) template file in Chef

A cookbook template is going to be an Embedded Ruby (ERB) template that is used to generate files for us. These templates are going to be great ways to insert Ruby expressions and statements into a native file format.

Example of inclusion:

template /var/www/index.html do
  source 'index.html.erb'
  end
These are comparable to Jinja2 template files in Ansible where the Ruby content is inserted in a specific ERB tags.

An Embedded Ruby (ERB) file is going to be a template file that allows us to build the code in its native file format, but after this we can also insert any Ruby expressions and statements into this ERB file between specifically formatted tags.

Example of ERB file template:

<% if (25+25) == 100 %>
25 + 25 = <%= 25+25 %>
<% else %>
Wrong math
<% end %>