diff --git a/spec/defines/tripleo_profile_base_neutron_wrappers_haproxy_spec.rb b/spec/defines/tripleo_profile_base_neutron_wrappers_haproxy_spec.rb index 0b1717fce..817e11159 100644 --- a/spec/defines/tripleo_profile_base_neutron_wrappers_haproxy_spec.rb +++ b/spec/defines/tripleo_profile_base_neutron_wrappers_haproxy_spec.rb @@ -52,7 +52,7 @@ describe 'tripleo::profile::base::neutron::wrappers::haproxy' do /set -x/ ) is_expected.to contain_file('/usr/local/bin/haproxy').with_content( - /CMD="ip netns exec.*\/usr\/sbin\/haproxy -Ds/ + /.*haproxy -Ds.*haproxy -Ws.*/ ) end end @@ -78,7 +78,7 @@ describe 'tripleo::profile::base::neutron::wrappers::haproxy' do /^NAME=neutron-haproxy-/ ) is_expected.to contain_file('/usr/local/bin/haproxy').with_content( - /CMD='\/usr\/sbin\/haproxy -Ds'/ + /.*haproxy -Ds.*haproxy -Ws.*/ ) end end diff --git a/templates/neutron/haproxy.epp b/templates/neutron/haproxy.epp index bd80bfa89..26239cd9d 100644 --- a/templates/neutron/haproxy.epp +++ b/templates/neutron/haproxy.epp @@ -19,12 +19,13 @@ ARGS="$@" # --dhcp-hostsfile=/var/lib/neutron/dhcp/317716b8-919a-4a6f-8db1-78128ec3b100/host ... NETNS=$(ip netns identify) NAME=neutron-haproxy-${NETNS} +HAPROXY_CMD='$(if [ -f /usr/sbin/haproxy-systemd-wrapper ]; then echo "/usr/sbin/haproxy -Ds"; else echo "/usr/sbin/haproxy -Ws"; fi)' <%- if $container_cli == 'docker' { -%> CLI='docker' -CMD="ip netns exec ${NETNS} /usr/sbin/haproxy -Ds" +CMD="ip netns exec ${NETNS} "'$HAPROXY' <%- } elsif $container_cli == 'podman' { -%> CLI="nsenter --net=/run/netns/${NETNS} --preserve-credentials -m -t 1 podman" -CMD='/usr/sbin/haproxy -Ds' +CMD='$HAPROXY' <%- } else { -%> CLI='echo noop' CMD='echo noop' @@ -54,4 +55,4 @@ $CLI run --detach \ -u root \ --name $NAME \ <%=$image_name%> \ - $CMD $ARGS + /bin/bash -c "HAPROXY=\"$HAPROXY_CMD\"; exec $CMD $ARGS"