Add docker daemon systemd proxy variables

add HTTPS_PROXY and NO_PROXY to docker.service.d

Change-Id: I9ab02773695fef14256ca79e68a3d3d1e52c3ff7
Closes-Bug: #1632698
This commit is contained in:
ArchiFleKs 2016-10-12 15:00:30 +02:00 committed by Kevin Lefevre
parent 846852a854
commit 2e9c364eec
1 changed files with 46 additions and 11 deletions

View File

@ -2,17 +2,23 @@
. /etc/sysconfig/heat-params
DOCKER_PROXY_CONF=/etc/systemd/system/docker.service.d/proxy.conf
DOCKER_HTTP_PROXY_CONF=/etc/systemd/system/docker.service.d/http_proxy.conf
DOCKER_HTTPS_PROXY_CONF=/etc/systemd/system/docker.service.d/https_proxy.conf
DOCKER_NO_PROXY_CONF=/etc/systemd/system/docker.service.d/no_proxy.conf
DOCKER_RESTART=0
BASH_RC=/etc/bashrc
if [ -n "$HTTP_PROXY" ]; then
cat <<EOF | sed "s/^ *//" > $DOCKER_PROXY_CONF
cat <<EOF | sed "s/^ *//" > $DOCKER_HTTP_PROXY_CONF
[Service]
Environment=HTTP_PROXY=$HTTP_PROXY
EOF
systemctl daemon-reload
systemctl --no-block restart docker.service
DOCKER_RESTART=1
if [ -f "$BASH_RC" ]; then
echo "declare -x http_proxy=$HTTP_PROXY" >> $BASH_RC
@ -22,6 +28,13 @@ EOF
fi
if [ -n "$HTTPS_PROXY" ]; then
cat <<EOF | sed "s/^ *//" > $DOCKER_HTTPS_PROXY_CONF
[Service]
Environment=HTTPS_PROXY=$HTTPS_PROXY
EOF
DOCKER_RESTART=1
if [ -f $BASH_RC ]; then
echo "declare -x https_proxy=$HTTPS_PROXY" >> $BASH_RC
else
@ -29,12 +42,34 @@ if [ -n "$HTTPS_PROXY" ]; then
fi
fi
if [ -f "$BASH_RC" ]; then
if [ -n "$NO_PROXY" ]; then
echo "declare -x no_proxy=$NO_PROXY" >> $BASH_RC
else
echo "declare -x no_proxy=$SWARM_API_IP,$ETCD_SERVER_IP,$SWARM_NODE_IP" >> $BASH_RC
fi
if [ -n "$NO_PROXY" ]; then
cat <<EOF | sed "s/^ *//" > $DOCKER_NO_PROXY_CONF
[Service]
Environment=NO_PROXY=$NO_PROXY
EOF
DOCKER_RESTART=1
else
echo "File $BASH_RC does not exist, not setting no_proxy"
cat <<EOF | sed "s/^ *//" > $DOCKER_NO_PROXY_CONF
[Service]
Environment=NO_PROXY=$SWARM_API_IP,$ETCD_SERVER_IP,$SWARM_NODE_IP
EOF
DOCKER_RESTART=1
if [ -f "$BASH_RC" ]; then
if [ -n "$NO_PROXY" ]; then
echo "declare -x no_proxy=$NO_PROXY" >> $BASH_RC
else
echo "declare -x no_proxy=$SWARM_API_IP,$ETCD_SERVER_IP,$SWARM_NODE_IP" >> $BASH_RC
fi
else
echo "File $BASH_RC does not exist, not setting no_proxy"
fi
fi
if [ "$DOCKER_RESTART" -eq 1 ]; then
systemctl daemon-reload
systemctl --no-block restart docker.service
fi