Skip to content

Commit

Permalink
Add HAProxy statistics optional configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
grkvlt committed Dec 21, 2016
1 parent fa1be19 commit b5e5212
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions common/catalog/common/haproxy.bom
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ brooklyn.catalog:
description: |
Extra bind configuration such as TLS certificate paths
type: string
- name: haproxy.stats.enable
label: "Enable HAProxy Statistics"
description: |
Whether HAProxy should serve statistics information page
type: boolean
default: false
- name: haproxy.stats.port
label: "HAProxy Statistics Port"
description: |
Port that HAProxy should serve statistics on
type: integer
default: 7000
- name: haproxy.stats.password
label: "HAProxy Statistics Password"
description: |
Password for 'admin' user on HAProxy statistics service
type: string
default: "p4ssw0rd"

brooklyn.config:
haproxy.bind.options:
Expand All @@ -63,6 +81,9 @@ brooklyn.catalog:
HAPROXY_PORT: $brooklyn:config("haproxy.port")
HAPROXY_PROTOCOL: $brooklyn:config("haproxy.protocol")
HAPROXY_BIND_OPTIONS: $brooklyn:config("haproxy.bind.options")
HAPROXY_STATS_ENABLE: $brooklyn:config("haproxy.stats.enable")
HAPROXY_STATS_PORT: $brooklyn:config("haproxy.stats.port")
HAPROXY_STATS_PASSWORD: $brooklyn:config("haproxy.stats.password")

install.command: |
sudo yum install -y gcc make openssl-devel wget util-linux
Expand Down Expand Up @@ -96,11 +117,26 @@ brooklyn.catalog:
default_backend servers
mode ${mode}
EOF
if [ "${HAPROXY_STATS_ENABLE}" == "true" ]; then
cat >> stats.conf <<-EOF
listen statistics
mode http
bind *:${HAPROXY_STATS_PORT}
log global
maxconn 16
stats enable
stats uri /
stats refresh 30s
stats show-node
stats realm HAProxy
stats auth admin:${HAPROXY_STATS_PASSWORD}
EOF
fi
echo "backend servers" > servers.conf

launch.command: |
haproxy -f haproxy.conf -f servers.conf -c &&
haproxy -D -f haproxy.conf -f servers.conf -sf $(cat ${PID_FILE})
haproxy -f haproxy.conf -f servers.conf -f stats.conf -c &&
haproxy -D -f haproxy.conf -f servers.conf -f stats.conf -sf $(cat ${PID_FILE})

brooklyn.initializers:
- type: org.apache.brooklyn.core.effector.ssh.SshCommandEffector
Expand Down

0 comments on commit b5e5212

Please sign in to comment.