Cookbooks
varnish
documentation
Vcl Template

Back to resource list

vcl_template

Create vcl file at /etc/varnish/backends.vcl using the template at templates/default/backends.vcl.erb and pass it some variables:

Actions

ActionDescription
:configureCreates a vcl file from a template and refreshes varnish
:unconfigureRemoves the vcl file and refreshes varnish

Properties

NameTypeDefaultDescription
vcl_nameStringresource nameThis will be the file name in the varnish vcl directory if not overridden by vcl_path
sourceString"#{::File.basename(vcl_name)}.erb"Same behavior as the template resource
cookbookStringnilBy default it uses the cookbook the resource is in
ownerString'root'
groupString'root'
modeString, Integer'0644'Follows the same behavior as the template resource
variablesHash{}Same behavior as the template resource but if the installed varnish major version can be found it is merged in at @varnish[:installed_version]
varnish_dirString'/etc/varnish'The directory to use for vcl files
vcl_pathString::File.join(varnish_dir, vcl_name)Overrides both the vcl_name and varnish_dir if this is specified

Examples

vcl_template 'backends.vcl' do
  variables(
    backends_ids: Array(1..16),
    env: 'live',
  )
end