Skip to content

Commit

Permalink
Merge pull request Oefenweb#133 from drwahl/cachesection
Browse files Browse the repository at this point in the history
Add support for haproxy caching
  • Loading branch information
tersmitten authored Nov 30, 2021
2 parents 3a3aea1 + 3ac29dd commit d838814
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,18 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
* `haproxy_letsencrypt_ocsp_deploy_job.month`: [default: `*`]: Month of the year the job should run (e.g `1-12`, `*`, `*/2`)
* `haproxy_letsencrypt_ocsp_deploy_job.weekday`: [default: `*`]: Day of the week that the job should run (e.g. `0-6` for Sunday-Saturday, `*`)

* `haproxy_cache`: [default: `[]`]: Caching declarations
* `haproxy_cache.{n}.name`: [default: [required]]: The name of the cache
* `haproxy_cache.{n}.total_max_size`: [default: []]: Max size (in MB) of the cache
* `haproxy_cache.{n}.max_object_size`: [default: []]: Max size (in MB) of any single object in the cache
* `haproxy_cache.{n}.max_age`: [default: []]: Max age (in seconds) to hold an item in cache

* `haproxy_program`: [default: `[]`]: Program declarations
* `haproxy_program.{n}.name`: [default: [required]]: The name of the program
* `haproxy_program.{n}.command`: [default: `[]`]: Command to execute
* `haproxy_program.{n}.option`: [default: `[]`]: Options to enable
* `haproxy_program.{n}.no_option`: [default: `[]`]: Options to inverse/disable

## Dependencies

None
Expand Down
14 changes: 14 additions & 0 deletions templates/etc/haproxy/cache.cfg.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% if cache is defined %}
{% for cache in haproxy_cache %}
cache {{ cache.name }}
{% if cache.total_max_size is defined %}
total-max-size {{ cache.total_max_size }}
{% endif %}
{% if cache.max_object_size is defined %}
max-object-size {{ cache.max_object_size }}
{% endif %}
{% if cache.max_age is defined %}
max-age {{ cache.max_age }}
{% endif %}
{% endfor %}
{% endif %}
4 changes: 4 additions & 0 deletions templates/etc/haproxy/haproxy.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ defaults

{% include 'resolvers.cfg.j2' %}

{% include 'program.cfg.j2' %}

{% include 'listen.cfg.j2' %}

{% include 'cache.cfg.j2' %}

{% include 'frontend.cfg.j2' %}

{% include 'backend.cfg.j2' %}
14 changes: 14 additions & 0 deletions templates/etc/haproxy/program.cfg.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% if haproxy_program is defined %}
{% for program in haproxy_program %}
program {{ program.name }}
{% if program.command is defined %}
command {{ program.command }}
{% endif %}
{% for option in program.option | default([]) %}
option {{ option }}
{% endfor %}
{% for option in program.no_option | default([]) %}
no option {{ option }}
{% endfor %}
{% endfor %}
{% endif %}

0 comments on commit d838814

Please sign in to comment.