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

Support for Customizing the HAProxy Feature Version #672

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions add-blobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -eux

source ./src/meta-info/blobs-versions.env
BLOBS_TMP_DIR=".blobs"

mkdir -p "$BLOBS_TMP_DIR"

function down_add_blob {
BLOBS_GROUP=$1
FILE=$2
URL=$3
if [ ! -f "blobs/${BLOBS_GROUP}/${FILE}" ];then
echo "Downloads resource from the Internet ($URL -> $BLOBS_TMP_DIR/$FILE)"
curl -L "$URL" --output "$BLOBS_TMP_DIR/$FILE"
echo "Adds blob ($BLOBS_TMP_DIR/$FILE -> $BLOBS_GROUP/$FILE), starts tracking blob in config/blobs.yml for inclusion in packages"
bosh add-blob "$BLOBS_TMP_DIR/$FILE" "$BLOBS_GROUP/$FILE"
fi
}

# down_add_blob "haproxy" "haproxy-${HAPROXY_1_8_VERSION}.tar.gz" "$HAPROXY_1_8_URL"
# down_add_blob "haproxy" "haproxy-${HAPROXY_1_9_VERSION}.tar.gz" "$HAPROXY_1_9_URL"

down_add_blob "haproxy" "haproxy-${HAPROXY_2_8_VERSION}.tar.gz" "$HAPROXY_2_8_URL"
down_add_blob "haproxy" "haproxy-${HAPROXY_2_9_VERSION}.tar.gz" "$HAPROXY_2_9_URL"

down_add_blob "haproxy" "haproxy-${HAPROXY_3_0_VERSION}.tar.gz" "$HAPROXY_3_0_URL"

down_add_blob "haproxy" "hatop-${HATOP_VERSION}" "$HATOP_URL"
down_add_blob "haproxy" "lua-${LUA_VERSION}.tar.gz" "$LUA_URL"
down_add_blob "haproxy" "pcre2-${PCRE2_VERSION}.tar.gz" "$PCRE2_URL"
down_add_blob "haproxy" "socat-${SOCAT_VERSION}.tar.gz" "$SOCAT_URL"
down_add_blob "keepalived" "keepalived-${KEEPALIVED_VERSION}.tar.gz" "$KEEPALIVED_URL"

echo "Download blobs into blobs/ based on config/blobs.yml"
bosh sync-blobs

echo "Upload previously added blobs that were not yet uploaded to the blobstore. Updates config/blobs.yml with returned blobstore IDs."
bosh upload-blobs
14 changes: 13 additions & 1 deletion jobs/haproxy/spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ name: haproxy

description: "The HAProxy server can be used to terminate SSL in front of the Routers. Each HAProxy instance should point to multiple Routers."

# LTS - Long Term Support
# STS - Short Term Support
packages:
- haproxy
# - haproxy-1.8 # LTS
# - haproxy-1.9 # STS
- haproxy-2.8 # LTS
- haproxy-2.9 # STS
- haproxy-3.0 # LTS
- ttar

templates:
Expand Down Expand Up @@ -39,6 +45,12 @@ consumes:
optional: true

properties:
ha_proxy.haproxy_feature_version:
description: |
You can select an HAProxy feature version by specifying the 'major.minor' version number, one of several HAProxy packages included in this release.
This release has been tested only with the default HAProxy feature version.
Use other version lines with raw configurations at your own risk.
default: '2.8' # LTS
ha_proxy.pre_start_script:
description: |
This script will be appended to the pre-start script and run before the job starts.
Expand Down
8 changes: 3 additions & 5 deletions jobs/haproxy/templates/haproxy_wrapper.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash
#
#!/bin/bash -e

set -e

export PATH=$PATH:/var/vcap/packages/haproxy/bin:/var/vcap/packages/ttar/bin
export HAPROXY_FEATURE_VERSION='<%= p("ha_proxy.haproxy_feature_version") -%>'
export PATH="$PATH:/var/vcap/packages/haproxy-$HAPROXY_FEATURE_VERSION/bin:/var/vcap/packages/ttar/bin"
CONFIG=/var/vcap/jobs/haproxy/config/haproxy.config
PID_FILE=/var/vcap/sys/run/haproxy/haproxy.pid
DRAIN_LOCK=/var/vcap/sys/run/haproxy/drain.lock
Expand Down
36 changes: 25 additions & 11 deletions jobs/haproxy/templates/pre-start.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
#!/bin/bash -e

export HAPROXY_FEATURE_VERSION='<%= p("ha_proxy.haproxy_feature_version") -%>'
mkdir -p /var/vcap/jobs/haproxy/errorfiles

create_or_update_link() {
local target="$1"
local link="$2"

if [ -L "$link" ]; then
if [ "$(readlink "$link")" != "$target" ]; then
echo "Updating symbolic link..."
sudo ln -sf "$target" "$link"
fi
else
if [ -e "$link" ]; then
echo "Removing existing file and creating a new symbolic link..."
sudo rm "$link"
else
echo "Creating new symbolic link..."
sudo ln -s "$target" "$link"
fi
fi
}


<% p('ha_proxy.custom_http_error_files', {}).each do |status_code, http_content| -%>

cat > <%= "/var/vcap/jobs/haproxy/errorfiles/custom#{status_code}.http" %> << EOF
<%= http_content %>
EOF
<% end -%>

if [ ! -e /usr/bin/python ] && [ -e /usr/bin/python3 ]; then
sudo ln -s /usr/bin/python3 /usr/bin/python
fi

if [ ! -e /usr/local/bin/hatop ]; then
sudo ln -s /var/vcap/packages/haproxy/hatop-wrapper /usr/local/bin/hatop
fi

if [ ! -e /usr/local/bin/socat ]; then
sudo ln -s /var/vcap/packages/haproxy/bin/socat /usr/local/bin/socat
fi
create_or_update_link /usr/bin/python3 /usr/bin/python
create_or_update_link "/var/vcap/packages/haproxy-$HAPROXY_FEATURE_VERSION/hatop-wrapper" /usr/local/bin/hatop
create_or_update_link "/var/vcap/packages/haproxy-$HAPROXY_FEATURE_VERSION/bin/socat" /usr/local/bin/socat

<%- if_p("ha_proxy.pre_start_script") do |script| -%>
# ha_proxy.pre_start_script {{{
Expand Down
15 changes: 15 additions & 0 deletions packages/haproxy-1.8/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# abort script on failures
set -euxo pipefail

source meta-info/blobs-versions.env
mkdir "${BOSH_INSTALL_TARGET}/bin"

source packaging-tools/installation.sh

install_hatop "$BOSH_INSTALL_TARGET" "$HATOP_VERSION"
install_lua "$BOSH_INSTALL_TARGET" "$LUA_VERSION"
install_pcre2 "$BOSH_INSTALL_TARGET" "$PCRE2_VERSION"
install_socat "$BOSH_INSTALL_TARGET" "$SOCAT_VERSION"

install_haproxy "$BOSH_INSTALL_TARGET" "$HAPROXY_1_8_VERSION"
4 changes: 3 additions & 1 deletion packages/haproxy/spec → packages/haproxy-1.8/spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
name: haproxy
name: haproxy-1.8
files:
- meta-info/blobs-versions.env
- packaging-tools/installation.sh
- haproxy/haproxy-*.tar.gz
- haproxy/pcre2-*.tar.gz
- haproxy/socat-*.tar.gz
Expand Down
15 changes: 15 additions & 0 deletions packages/haproxy-1.9/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# abort script on failures
set -euxo pipefail

source meta-info/blobs-versions.env
mkdir "${BOSH_INSTALL_TARGET}/bin"

source packaging-tools/installation.sh

install_hatop "$BOSH_INSTALL_TARGET" "$HATOP_VERSION"
install_lua "$BOSH_INSTALL_TARGET" "$LUA_VERSION"
install_pcre2 "$BOSH_INSTALL_TARGET" "$PCRE2_VERSION"
install_socat "$BOSH_INSTALL_TARGET" "$SOCAT_VERSION"

install_haproxy "$BOSH_INSTALL_TARGET" "$HAPROXY_1_9_VERSION"
11 changes: 11 additions & 0 deletions packages/haproxy-1.9/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: haproxy-1.9
files:
- meta-info/blobs-versions.env
- packaging-tools/installation.sh
- haproxy/haproxy-*.tar.gz
- haproxy/pcre2-*.tar.gz
- haproxy/socat-*.tar.gz
- haproxy/lua-*.tar.gz
- haproxy/hatop-*
- hatop-wrapper
15 changes: 15 additions & 0 deletions packages/haproxy-2.8/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# abort script on failures
set -euxo pipefail

source meta-info/blobs-versions.env
mkdir "${BOSH_INSTALL_TARGET}/bin"

source packaging-tools/installation.sh

install_hatop "$BOSH_INSTALL_TARGET" "$HATOP_VERSION"
install_lua "$BOSH_INSTALL_TARGET" "$LUA_VERSION"
install_pcre2 "$BOSH_INSTALL_TARGET" "$PCRE2_VERSION"
install_socat "$BOSH_INSTALL_TARGET" "$SOCAT_VERSION"

install_haproxy "$BOSH_INSTALL_TARGET" "$HAPROXY_2_8_VERSION"
11 changes: 11 additions & 0 deletions packages/haproxy-2.8/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: haproxy-2.8
files:
- meta-info/blobs-versions.env
- packaging-tools/installation.sh
- haproxy/haproxy-*.tar.gz
- haproxy/pcre2-*.tar.gz
- haproxy/socat-*.tar.gz
- haproxy/lua-*.tar.gz
- haproxy/hatop-*
- hatop-wrapper
15 changes: 15 additions & 0 deletions packages/haproxy-2.9/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# abort script on failures
set -euxo pipefail

source meta-info/blobs-versions.env
mkdir "${BOSH_INSTALL_TARGET}/bin"

source packaging-tools/installation.sh

install_hatop "$BOSH_INSTALL_TARGET" "$HATOP_VERSION"
install_lua "$BOSH_INSTALL_TARGET" "$LUA_VERSION"
install_pcre2 "$BOSH_INSTALL_TARGET" "$PCRE2_VERSION"
install_socat "$BOSH_INSTALL_TARGET" "$SOCAT_VERSION"

install_haproxy "$BOSH_INSTALL_TARGET" "$HAPROXY_2_9_VERSION"
11 changes: 11 additions & 0 deletions packages/haproxy-2.9/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: haproxy-2.9
files:
- meta-info/blobs-versions.env
- packaging-tools/installation.sh
- haproxy/haproxy-*.tar.gz
- haproxy/pcre2-*.tar.gz
- haproxy/socat-*.tar.gz
- haproxy/lua-*.tar.gz
- haproxy/hatop-*
- hatop-wrapper
15 changes: 15 additions & 0 deletions packages/haproxy-3.0/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# abort script on failures
set -euxo pipefail

source meta-info/blobs-versions.env
mkdir "${BOSH_INSTALL_TARGET}/bin"

source packaging-tools/installation.sh

install_hatop "$BOSH_INSTALL_TARGET" "$HATOP_VERSION"
install_lua "$BOSH_INSTALL_TARGET" "$LUA_VERSION"
install_pcre2 "$BOSH_INSTALL_TARGET" "$PCRE2_VERSION"
install_socat "$BOSH_INSTALL_TARGET" "$SOCAT_VERSION"

install_haproxy "$BOSH_INSTALL_TARGET" "$HAPROXY_3_0_VERSION"
11 changes: 11 additions & 0 deletions packages/haproxy-3.0/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: haproxy-3.0
files:
- meta-info/blobs-versions.env
- packaging-tools/installation.sh
- haproxy/haproxy-*.tar.gz
- haproxy/pcre2-*.tar.gz
- haproxy/socat-*.tar.gz
- haproxy/lua-*.tar.gz
- haproxy/hatop-*
- hatop-wrapper
72 changes: 0 additions & 72 deletions packages/haproxy/packaging

This file was deleted.

7 changes: 4 additions & 3 deletions packages/keepalived/packaging
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# abort script on any command that exits with a non zero value
set -e -x

source meta-info/blobs-versions.env

# Copy common utils
mkdir -p ${BOSH_INSTALL_TARGET}/common
cp -a ${BOSH_COMPILE_TARGET}/common/* ${BOSH_INSTALL_TARGET}/common

KEEPALIVED_VERSION=2.2.8 # https://keepalived.org/software/keepalived-2.2.8.tar.gz
tar xzvf keepalived/keepalived-${KEEPALIVED_VERSION}.tar.gz
cd keepalived-${KEEPALIVED_VERSION}/
tar xzvf keepalived/keepalived-${KEEPALIVED_VER}.tar.gz
cd keepalived-${KEEPALIVED_VER}/

#compile keepalive
./configure --prefix=${BOSH_INSTALL_TARGET}
Expand Down
1 change: 1 addition & 0 deletions packages/keepalived/spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ name: keepalived
dependencies: []

files:
- meta-info/blobs-versions.env
- common/utils.sh
- keepalived/keepalived-*.tar.gz
Loading