Skip to content

Commit

Permalink
feat(stats): support multiple sockets
Browse files Browse the repository at this point in the history
This is useful to implement sockets with different access levels.
The existing stats pillar is left in tact.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
  • Loading branch information
tacerus committed Feb 6, 2024
1 parent 42b603b commit 2f0d729
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions haproxy/templates/haproxy.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ global
{%- if salt['pillar.get']('haproxy:global:daemon', 'no') == True %}
daemon
{%- endif %}
{%- for socket, socket_config in salt['pillar.get']('haproxy:global:stats_sockets', {}).items() %}
stats socket {{ socket }} mode {{ socket_config.get('mode', '0600') }} level {{ socket_config.get('level', 'user') }} user {{ socket_config.get('user', 'haproxy') }} group {{ socket_config.get('group', 'haproxy') }}
{%- endfor %}
{%- if salt['pillar.get']('haproxy:global:stats:enable', 'no') == True %}
{%- set socketpath = salt['pillar.get']('haproxy:global:stats:socketpath', '/tmp/ha_stats.sock') %}
{%- set mode = salt['pillar.get']('haproxy:global:stats:mode', '660') %}
Expand Down
13 changes: 13 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ haproxy:
# yamllint disable-line rule:line-length
# Optional extra bind parameter, for example to set the owner/group on the socket file
extra: user haproxy group haproxy
# alternative way of defining stats sockets, useful if multiple are are desired
stats_sockets:
/run/haproxy/stats-ro:
# the defaults
level: user
mode: 600
user: haproxy
group: haproxy
/run/haproxy/stats-rw:
# custom example
level: admin
mode: 660
group: sysadmins
# yamllint disable-line rule:line-length
ssl-default-bind-ciphers: "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384"
ssl-default-bind-options: "no-sslv3 no-tlsv10 no-tlsv11"
Expand Down
8 changes: 8 additions & 0 deletions test/salt/pillar/default.sls
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ haproxy:
# yamllint disable-line rule:line-length
# Optional extra bind parameter, for example to set the owner/group on the socket file
extra: user haproxy group haproxy
stats_sockets:
/run/haproxy/stats-operator:
level: operator
mode: 660
group: wheel
/run/haproxy/stats-admin:
level: admin
mode: 600
# yamllint disable-line rule:line-length
ssl-default-bind-ciphers: "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384"
ssl-default-bind-options: "no-sslv3 no-tlsv10 no-tlsv11"
Expand Down

0 comments on commit 2f0d729

Please sign in to comment.