Skip to content

Instantly share code, notes, and snippets.

@jlgreer
Created April 23, 2012 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlgreer/2472899 to your computer and use it in GitHub Desktop.
Save jlgreer/2472899 to your computer and use it in GitHub Desktop.
# Testing version - not yet part of library
bundle agent template_std_flipclass(file, prefix, fileserver, mode, owner, group, class) {
files:
"$(file).template"
copy_from => copy_std("$(prefix)$(file).template",
"$(fileserver)", "false", "timestamp"),
perms => mode_owner_group("$(mode)", "$(owner)", "$(group)"),
action => actionsettings_fix_inform("inform");
"$(file)"
perms => mode_owner_group("$(mode)", "$(owner)", "$(group)"),
create => "true",
edit_line => expand_variables("$(file).template"),
# Using the full-featured body here because we need to empty the file
# client-side first.
classes => if_repaired("$(class)"),
edit_defaults => editsettings("timestamp", "true", "50K"),
action => actionsettings_fix_inform("inform");
}
@filler
Copy link

filler commented Apr 23, 2012

fwict, this doesnt work:

varnish.cf

methods:
    "template_etc_varnish_default_vcl"
      usebundle => template_std_flipclass("/etc/varnish/default.vcl", "$(prefix)", "$(fileserver)", "0644", "root", "root", "varnish_restart");

commands:
  varnish_restart::
    "/etc/init.d/varnish restart"
      contain => container_std("root", true),
      action  => actionsettings_fix_inform_noisylogs("inform");

library.cf:

bundle agent template_std_flipclass(file, prefix, fileserver, mode, owner, group, class) {

files:

  "$(file).template"
    copy_from    => copy_std("$(prefix)$(file).template",
      "$(fileserver)", "false", "timestamp"),
    perms        => mode_owner_group("$(mode)", "$(owner)", "$(group)"),
    action       => actionsettings_fix_inform("inform");

  "$(file)"
    perms         => mode_owner_group("$(mode)", "$(owner)", "$(group)"),
    create        => "true",
    edit_line     => expand_variables("$(file).template"),
    # Using the full-featured body here because we need to empty the file
    # client-side first.
    classes       => if_repaired("$(class)"),
    edit_defaults => editsettings("timestamp", "true", "50K"),
    action        => actionsettings_fix_inform("inform");

}

cf-agent run:

cf3>    =========================================================
cf3>    files in bundle template_std_flipclass (1)
cf3>    =========================================================
cf3> 
cf3> 
cf3>     .........................................................
cf3>     Promise handle: 
cf3>     Promise made by: /etc/varnish/default.vcl.template
cf3>     .........................................................
cf3> 
cf3>  -> Copy file /etc/varnish/default.vcl.template from /var/cfengine/masterfiles/dcsunix/varnish/pub/etc/varnish/default.vcl.template check
cf3>  -> /etc/varnish/default.vcl.template wasn't at destination (copying)
cf3>  -> Copying from localhost:/var/cfengine/masterfiles/dcsunix/varnish/pub/etc/varnish/default.vcl.template
cf3>  -> Copy of regular file succeeded /var/cfengine/masterfiles/dcsunix/varnish/pub/etc/varnish/default.vcl.template to /etc/varnish/default.vcl.template.cfnew
cf3>  ?? Final verification of transmission ...
cf3>  -> New file /etc/varnish/default.vcl.template.cfnew transmitted correctly - verified
cf3>  -> Object /etc/varnish/default.vcl.template had permission 600, changed it to 644
cf3>  -> Updated file from localhost:/var/cfengine/masterfiles/dcsunix/varnish/pub/etc/varnish/default.vcl.template
cf3> Performance(Copy(localhost:/var/cfengine/masterfiles/dcsunix/varnish/pub/etc/varnish/default.vcl.template > /etc/varnish/default.vcl.template)): time=0.0067 secs, av=0.0067 +/- 0.0316
cf3> Existing connection just became free...
cf3>  -> Handling file existence constraints on /etc/varnish/default.vcl.template
cf3>  -> File permissions on /etc/varnish/default.vcl.template as promised
cf3> 
cf3>     .........................................................
cf3>     Promise handle: 
cf3>     Promise made by: /etc/varnish/default.vcl
cf3>     .........................................................
cf3> 
cf3>  -> Using literal pathtype for /etc/varnish/default.vcl
cf3>  -> File "/etc/varnish/default.vcl" exists as promised
cf3>  -> Handling file existence constraints on /etc/varnish/default.vcl
cf3>  -> File permissions on /etc/varnish/default.vcl as promised
cf3>  -> Handling file existence constraints on /etc/varnish/default.vcl
cf3>  -> File permissions on /etc/varnish/default.vcl as promised
cf3>  -> Build file model from a blank slate (emptying)
cf3>  -> Handling file edits in edit_line bundle expand_variables
cf3> 
cf3>       * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
cf3>       BUNDLE expand_variables( {'/etc/varnish/default.vcl.template'} )
cf3>       * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
cf3> 
cf3> Initiate variable convergence...
cf3>     ? Augment scope expand_variables with templatefile (s)
cf3>      ??  Private class context
cf3> 
cf3> 
cf3>       = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3>       insert_lines in bundle expand_variables
cf3>       = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3> 
cf3> 
cf3>     .........................................................
cf3>     Promise handle: 
cf3>     Promise made by: /etc/varnish/default.vcl.template
cf3>     .........................................................
cf3> 
cf3>  -> Inserting the promised line "# Under cfengine control!" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "#" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# This is a basic VCL configuration file for varnish.  See the vcl(7)" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# man page for details on VCL syntax and semantics." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# " into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# access control" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "include "acls.vcl";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# backend definitions" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "include "backends.vcl";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# cookie management" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "include "cookies.vcl";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# content to deal with differently" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "include "blacklist.vcl";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# Respond to incoming requests." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "sub vcl_recv {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Quick pre-flight to verify varnish function" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (req.request == "GET" && req.url ~ "^/varnishping$") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    error 200 "alive";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Allow PURGEs from those in ACLs ; others error out" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (req.request == "PURGE") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    if (!client.ip ~ purge) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      error 405 "Not allowed.";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    return(lookup);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Never cache POST requests.  Ever." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (req.request == "POST") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    return(pipe);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Dont serve cache to those coming in with wordpress cookies" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Coming in with other cookies get cookies stripped + served cache." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (req.http.cookie) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    if (req.http.cookie ~ "(wordpress_logged_in_)") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      return(pass);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    } else { " into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      unset req.http.cookie;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Drop any cookies sent to Wordpress." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "#  if ( req.http.Cookie ~ "wordpress_[^=]+=") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "#    return(pass);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "#  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Allow the backend to serve up stale content if it is responding slowly." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (!req.backend.healthy) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    # Use anonymous, cached pages if all backends are down." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    unset req.http.Cookie;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      if (req.http.X-Forwarded-Proto == "https") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "        set req.http.X-Forwarded-Proto = "http";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set req.grace = 30m;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  } else {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set req.grace = 15s;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Do not cache these paths." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (req.url ~ "^/REVISION$" ||" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      req.url ~ "^/feed.*$" ||" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      req.url ~ "^/wp-login.*$" ||" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      req.url ~ "^/wp-admin.*$") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    return (pass);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # normalize accept-encoding to account for different browsers" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # see: https://www.varnish-cache.org/trac/wiki/VCLExampleNormalizeAcceptEncoding" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (req.http.Accept-Encoding) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    if (req.http.Accept-Encoding ~ "gzip") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      set req.http.Accept-Encoding = "gzip";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    } elsif (req.http.Accept-Encoding ~ "deflate") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      set req.http.Accept-Encoding = "deflate";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    } else {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      # unknown algorithm  " into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "      unset req.http.Accept-Encoding;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "}" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# Code determining what to do when serving items from the Apache servers." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "sub vcl_fetch {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Unless request url is wp-login or wp-admin" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # drop any cookies Wordpress tries to send back to the client." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (!(req.url ~ "wp-(login|admin)")) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    unset beresp.http.set-cookie;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Don't allow static files to set cookies." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (req.url ~ "(?i)\.(png|gif|jpeg|jpg|ico|swf|css|js)(\?[a-z0-9]+)?$") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    # beresp == Back-end response from the web server." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    unset beresp.http.set-cookie;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    return(deliver);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  else if (beresp.http.Cache-Control) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    unset beresp.http.Expires;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (beresp.status == 301) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set beresp.ttl = 1h;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    return(deliver);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Set time-to-live" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  set beresp.ttl = 120s;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Allow items to be stale if needed." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  set beresp.grace = 1h;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# this doesnt work?" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "#  if (beresp.status == 500) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "#    set beresp.grace = 60s;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "#    return(restart);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "#  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # add extra diagnostic headers to your response indicating why something was a cache hit or miss" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Varnish determined the object was not cacheable" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (beresp.ttl <= 0s) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set beresp.http.X-Varnish-Cacheable = "NO:Not Cacheable";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # You don't wish to cache content for logged in users" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  } elsif (req.http.Cookie ~ "(wordpress_logged_in_|PHPSESS)") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set beresp.http.X-Varnish-Cacheable = "NO:Got Session";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    return(hit_for_pass);  " into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # You are respecting the Cache-Control=private header from the backend" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  } elsif (beresp.http.Cache-Control ~ "private") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set beresp.http.X-Varnish-Cacheable = "NO:Cache-Control=private";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    return(hit_for_pass);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Varnish determined the object was cacheable" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  } else {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set beresp.http.X-Varnish-Cacheable = "YES";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  return(deliver);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "}" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "# Called before a cached object is delivered to the client" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "sub vcl_deliver {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # If we hit cache, return X-Header that we did" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (obj.hits > 0) {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set resp.http.X-Varnish-Cache = "HIT";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set resp.http.X-Varnish-Hits = obj.hits;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  } else {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    set resp.http.X-Varnish-Cache = "MISS";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl af
ter locator
cf3>  -> Inserting the promised line "  # Strip away some extraneous headers" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Apache Version Red Hat, PHP Version, Varnish Version" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  unset resp.http.X-Varnish;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  unset resp.http.Via;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  unset resp.http.X-Powered-By;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  unset resp.http.Server;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  set resp.http.X-Served-By = server.hostname;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Do it for the lulz" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  set resp.http.X-Yale = "Boola, boola.";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "}" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "sub vcl_hit {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (req.request == "PURGE") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    purge;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    error 200 "Purged.";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "}" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "sub vcl_miss {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  if (req.request == "PURGE") {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    purge;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "    error 200 "Purged";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  }" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "}" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "sub vcl_error {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Return a sorry page when Varnish hits an error." into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # 302 clients to that sorry.its vhost @ elsinore" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  set obj.http.Location = "http://sorry.its.yale.edu/";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  set obj.status = 302;" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  return(deliver);" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "}" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "sub vcl_pipe {" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # Force the connection to be closed afterwards so subsequent reqs don't use pipe" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  # https://www.varnish-cache.org/trac/ticket/849" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "  set bereq.http.connection = "close";" into /etc/varnish/default.vcl after locator
cf3>  -> Inserting the promised line "}" into /etc/varnish/default.vcl after locator
cf3>      ??  Private class context
cf3> 
cf3> 
cf3>       = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3>       insert_lines in bundle expand_variables
cf3>       = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3> 
cf3> 
cf3>     .........................................................
cf3>     Promise handle: 
cf3>     Promise made by: /etc/varnish/default.vcl.template
cf3>     .........................................................
cf3> 
cf3>  -> This promise has already been verified
cf3>      ??  Private class context
cf3> 
cf3> 
cf3>       = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3>       insert_lines in bundle expand_variables
cf3>       = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3> 
cf3> 
cf3>     .........................................................
cf3>     Promise handle: 
cf3>     Promise made by: /etc/varnish/default.vcl.template
cf3>     .........................................................
cf3> 
cf3>  -> This promise has already been verified
cf3>  -> Edited file /etc/varnish/default.vcl
cf3>  ?> defining promise result class varnish_restart
cf3>  -> Handling file existence constraints on /etc/varnish/default.vcl
cf3>  -> File permissions on /etc/varnish/default.vcl as promised
cf3> 
cf3>      +  Private classes augmented:
cf3> 
cf3>      -  Private classes diminished:
cf3> 
cf3> 
cf3> 

@filler
Copy link

filler commented Apr 24, 2012

derp. this seems to work. tested on a non-erroring bundle. ;)

rdj:dcsunix silkey$ svn di ../../inputs/common/library.cf 
Index: ../../inputs/common/library.cf
===================================================================
--- ../../inputs/common/library.cf  (revision 51)
+++ ../../inputs/common/library.cf  (working copy)
@@ -849,7 +849,28 @@
     action        => actionsettings_fix_inform("inform");

 }
+# Testing version - not yet part of library
+bundle agent template_std_flipclass(file, prefix, fileserver, mode, owner, group, class) {

+files:
+
+  "$(file).template"
+    copy_from    => copy_std("$(prefix)$(file).template",
+      "$(fileserver)", "false", "timestamp"),
+    perms        => mode_owner_group("$(mode)", "$(owner)", "$(group)"),
+    action       => actionsettings_fix_inform("inform");
+
+  "$(file)"
+    perms         => mode_owner_group("$(mode)", "$(owner)", "$(group)"),
+    create        => "true",
+    edit_line     => expand_variables("$(file).template"),
+    # Using the full-featured body here because we need to empty the file
+    # client-side first.
+    classes       => if_repaired("$(class)"),
+    edit_defaults => editsettings("timestamp", "true", "50K"),
+    action        => actionsettings_fix_inform("inform");
+
+}
 ################################################################################
 #
 # Package management bodies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment