Skip to content

Add Cache Section to HAProxy config #582

@jjarokergc

Description

@jjarokergc

I am currently testing the module (and maybe overlooking something obvious) but there does not appear to be a way to manage the HAProxy 'cache' section.

Use Case

The 'cache' section is a main configuration option for haproxy. It should be managed explicitly.

Describe the Solution You Would Like

class { 'haproxy':
  cache => {
    'cache_name' => 'mycache',
    'total-max-size' => '4095'
   'max-object-size' => '10000'
   'max-age' => '30'
  }

Describe Alternatives You've Considered

The following works OK, but the indentation is wrong in haproxy.cfg. An alternative would be to adjust the 'custom_fragment' to eliminate the extra tab.

  class { 'haproxy':
  ...
    custom_fragment  => "cache mycache \n\t total-max-size 4095 \n\t max-object-size 10000 \n\t max-age 30",
  ...
  }

The above produces haproxy.cfg:

global
  chroot  /var/lib/haproxy
  daemon  
  group  haproxy
  log  127.0.0.1:514 local0
  ...

defaults
  log  global
  ...
  stats  enable

# Note the indentation here.  This is accepted by haproxy, but is not the standard formatting
  cache mycache 
         total-max-size 4095 
         max-object-size 10000 
         max-age 30

listen ...
  ...

Additional Context

https://www.haproxy.com/blog/accelerate-your-apis-by-using-the-haproxy-cache

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions