Skip to content

Instantly share code, notes, and snippets.

@riskiwah
Created April 20, 2022 19:50
Show Gist options
  • Save riskiwah/373a8f73cb34d5877d468a324e201f8e to your computer and use it in GitHub Desktop.
Save riskiwah/373a8f73cb34d5877d468a324e201f8e to your computer and use it in GitHub Desktop.
haproxxy dataplane api
---
version: '3.9'
services:
apps:
image: riskiwah/kustomize-poc:base
haproxy1:
image: haproxytech/haproxy-debian:2.0.28
ports:
- "8080:80"
- "5555:5555"
volumes:
- ./conf:/usr/local/etc/haproxy
global
daemon
maxconn 200
log /dev/log local0
log localhost local1 notice
defaults
mode http
log global
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
retries 100
# stats socket /run/haproxy.sock mode 660 level admin expose-fd listeners
userlist haproxy-dataplaneapi
user admin insecure-password mypassword
frontend http-in
bind *:80
default_backend webservers
backend webservers
balance roundrobin
option http-server-close
option forwardfor
stats enable
stats auth admin:admin
stats uri /haproxy?stats
server apps apps:8080
program api
command /usr/bin/dataplaneapi --host 0.0.0.0 --port 5555 --haproxy-bin /usr/sbin/haproxy --config-file /usr/local/etc/haproxy/haproxy.cfg --reload-cmd "kill -SIGUSR2 1" --reload-delay 5 --userlist haproxy-dataplaneapi --log-to=file --log-file=/var/log/dataplaneapi/dataplaneapi.log --log-level=info
no option start-on-reload
---
- name: haproxy
hosts: localhost
connection: local
vars:
version: 4
tasks:
- name: init req
uri:
url: "http://localhost:5555/v2/info"
force_basic_auth: yes
user: admin
password: mypassword
method: GET
- name: update
uri:
url: "http://localhost:5555/v2/services/haproxy/configuration/raw?version={{ version }}"
force_basic_auth: yes
user: admin
password: mypassword
method: POST
body_format: raw
headers:
Content-Type: text/plain
body: "{{ lookup('file', 'proxyproxy.cfg') }}"
status_code: [200, 202]
register: __result
- name: show __result
debug:
var: __result.status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment