Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cache Section to HAProxy config #582

Open
jjarokergc opened this issue Sep 18, 2023 · 1 comment
Open

Add Cache Section to HAProxy config #582

jjarokergc opened this issue Sep 18, 2023 · 1 comment

Comments

@jjarokergc
Copy link

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

@matejzero
Copy link

I also have a case where I would like to implement haproxy cache. I can try and make a PR if that's ok?

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

No branches or pull requests

3 participants