Skip to content

Commit

Permalink
Allow etcd to use internal IP
Browse files Browse the repository at this point in the history
  • Loading branch information
neelimamukiri committed Feb 16, 2017
1 parent a187094 commit 1eec478
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 26 deletions.
17 changes: 10 additions & 7 deletions install/ansible/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ error_ret() {
exit 1
}

while getopts ":n:a:im:d:v:" opt; do
while getopts ":n:a:im:d:v:s:" opt; do
case $opt in
n)
netmaster=$OPTARG
Expand All @@ -54,6 +54,9 @@ while getopts ":n:a:im:d:v:" opt; do
v)
aci_image=$OPTARG
;;
s)
cluster_store=$OPTARG
;;
:)
echo "An argument required for $OPTARG was not passed"
usage
Expand Down Expand Up @@ -82,11 +85,6 @@ if [ "$netmaster" = "" ]; then
usage
fi

cluster="etcd://$netmaster:2379"
if [ "$cluster_store" != "" ];then
cluster=$cluster_store
fi

ansible_path=./ansible
env_file=install/ansible/env.json

Expand All @@ -96,8 +94,13 @@ netmaster_control_if=$(grep -A10 $netmaster $contiv_config | grep -m 1 control |
node_name=$(grep $netmaster $host_inventory | awk '{print $1}' | xargs)
# Get the service VIP for netmaster for the control interface
service_vip=$(ansible $node_name -m setup $ans_opts -i $host_inventory | grep -A 100 ansible_$netmaster_control_if | grep -A 4 ipv4 | grep address | awk -F \" '{print $4}'| xargs)

if [ "$cluster_store" == "" ];then
cluster_store="etcd://$service_vip:2379"
fi

sed -i.bak "s/__NETMASTER_IP__/$service_vip/g" "$env_file"
sed -i.bak "s#__CLUSTER_STORE__#$cluster#g" "$env_file"
sed -i.bak "s#__CLUSTER_STORE__#$cluster_store#g" "$env_file"

# Copy certs
cp /var/contiv/cert.pem /ansible/roles/auth_proxy/files/
Expand Down
16 changes: 10 additions & 6 deletions install/ansible/install_swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Installer:
Usage: ./install/ansible/install_swarm.sh OPTIONS
Mandatory Options:
-f string Configuration file listing the hostnames with the control and data interfaces and optionally ACI parameters
-f string Configuration file (cfg.yml) listing the hostnames with the control and data interfaces and optionally ACI parameters
-e string SSH key to connect to the hosts
-u string SSH User
-i Install the scheduler stack
Expand All @@ -38,8 +38,8 @@ Additional Options:
Advanced Options:
-v string ACI Image (default is contiv/aci-gw:latest). Use this to specify a specific version of the ACI Image.
-n string DNS name/IP address of the host to be used as the net master service VIP.
-n string DNS name/IP address of the host to be used as the net master service VIP. This must be a host present in the cfg.yml file.
-s string URL of the cluster store to be used (for example etcd://etcd_master:2379)
Additional parameters can also be updated in install/ansible/env.json file.
Examples:
Expand All @@ -62,8 +62,8 @@ EOF

# Create the config folder to be shared with the install container.
mkdir -p "$src_conf_path"

while getopts ":f:n:a:e:im:d:v:u:c:k:" opt; do
cluster_param=""
while getopts ":f:n:a:e:im:d:v:u:c:k:s:" opt; do
case $opt in
f)
cp "$OPTARG" "$host_contiv_config"
Expand All @@ -89,6 +89,10 @@ while getopts ":f:n:a:e:im:d:v:u:c:k:" opt; do
v)
aci_image=$OPTARG
;;
s)
cluster_param="-s $OPTARG"
;;

i)
install_scheduler="-i"
;;
Expand Down Expand Up @@ -149,4 +153,4 @@ ansible_mount="-v $(pwd)/ansible:/ansible:Z"
config_mount="-v $src_conf_path:$container_conf_path:Z"
cache_mount="-v $(pwd)/contiv_cache:/var/contiv_cache:Z"
mounts="$install_mount $ansible_mount $cache_mount $config_mount"
docker run --rm $mounts $image_name sh -c "./install/ansible/install.sh $netmaster_param -a \"$ans_opts\" $install_scheduler -m $contiv_network_mode -d $fwd_mode $aci_param"
docker run --rm $mounts $image_name sh -c "./install/ansible/install.sh $netmaster_param -a \"$ans_opts\" $install_scheduler -m $contiv_network_mode -d $fwd_mode $aci_param $cluster_param"
17 changes: 10 additions & 7 deletions install/ansible/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ error_ret() {
exit 1
}

while getopts ":n:a:im:d:v:rg" opt; do
while getopts ":n:a:im:d:v:rgs:" opt; do
case $opt in
n)
netmaster=$OPTARG
Expand All @@ -57,6 +57,9 @@ while getopts ":n:a:im:d:v:rg" opt; do
v)
aci_image=$OPTARG
;;
s)
cluster_store=$OPTARG
;;
r)
reset="true"
;;
Expand Down Expand Up @@ -91,11 +94,6 @@ if [ "$netmaster" = "" ]; then
usage
fi

cluster="etcd://$netmaster:2379"
if [ "$cluster_store" != "" ];then
cluster=$cluster_store
fi

ansible_path=./ansible
env_file=install/ansible/env.json

Expand All @@ -105,8 +103,13 @@ netmaster_control_if=$(grep -A10 $netmaster $contiv_config | grep -m 1 control |
node_name=$(grep $netmaster $host_inventory | awk '{print $1}' | xargs)
# Get the service VIP for netmaster for the control interface
service_vip=$(ansible $node_name -m setup $ans_opts -i $host_inventory | grep -A 100 ansible_$netmaster_control_if | grep -A 4 ipv4 | grep address | awk -F \" '{print $4}'| xargs)

if [ "$cluster_store" == "" ];then
cluster_store="etcd://$service_vip:2379"
fi

sed -i.bak "s/__NETMASTER_IP__/$service_vip/g" "$env_file"
sed -i.bak "s#__CLUSTER_STORE__#$cluster#g" "$env_file"
sed -i.bak "s#__CLUSTER_STORE__#$cluster_store#g" "$env_file"
sed -i.bak "s/.*docker_reset_container_state.*/\"docker_reset_container_state\":$reset,/g" $env_file
sed -i.bak "s/.*docker_reset_image_state.*/\"docker_reset_image_state\":$reset_images,/g" $env_file
sed -i.bak "s/.*etcd_cleanup_state.*/\"etcd_cleanup_state\":$reset,/g" $env_file
Expand Down
16 changes: 10 additions & 6 deletions install/ansible/uninstall_swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Uninstaller:
Usage: ./install/ansible/uninstall_swarm.sh OPTIONS
Mandatory Options:
-f string Configuration file listing the hostnames with the control and data interfaces and optionally ACI parameters
-f string Configuration file (cfg.yml) listing the hostnames with the control and data interfaces and optionally ACI parameters
-e string SSH key to connect to the hosts
-u string SSH User
-i Uninstall the scheduler stack
Expand All @@ -32,10 +32,10 @@ Additional Options:
-d string Forwarding mode (“routing” or “bridge”). Default mode is “bridge”
Advanced Options:
-v string ACI Image (default is contiv/aci-gw:latest). Use this to specify a specific version of the ACI Image.
-n string DNS name/IP address of the host to be used as the net master service VIP.
-n string DNS name/IP address of the host to be used as the net master service VIP. This must be a host present in the cfg.yml file.
-r Reset etcd state and remove docker containers
-g Remove docker images
-s string URL of the cluster store to be used (for example etcd://etcd_master:2379)
Additional parameters can also be updated in install/ansible/env.json file.
Examples:
Expand All @@ -54,8 +54,8 @@ EOF

# Create the config folder to be shared with the install container.
mkdir -p "$src_conf_path"

while getopts ":f:n:a:e:im:d:v:u:rg" opt; do
cluster_param=""
while getopts ":f:n:a:e:im:d:v:u:rgs:" opt; do
case $opt in
f)
cp "$OPTARG" "$host_contiv_config"
Expand All @@ -81,6 +81,10 @@ while getopts ":f:n:a:e:im:d:v:u:rg" opt; do
v)
aci_image=$OPTARG
;;
s)
cluster_param="-s $OPTARG"
;;

i)
echo "Uninstalling docker will fail if the uninstallation is being run from a node in the cluster."
echo "Press Ctrl+C to cancel the uininstall and start it from a host outside the cluster."
Expand Down Expand Up @@ -134,4 +138,4 @@ ansible_mount="-v $(pwd)/ansible:/ansible:Z"
config_mount="-v $src_conf_path:$container_conf_path:Z"
cache_mount="-v $(pwd)/contiv_cache:/var/contiv_cache:Z"
mounts="$install_mount $ansible_mount $cache_mount $config_mount"
docker run --rm $mounts $image_name sh -c "./install/ansible/uninstall.sh $netmaster_param -a \"$ans_opts\" $uninstall_scheduler -m $contiv_network_mode -d $fwd_mode $aci_param $reset_params"
docker run --rm $mounts $image_name sh -c "./install/ansible/uninstall.sh $netmaster_param -a \"$ans_opts\" $uninstall_scheduler -m $contiv_network_mode -d $fwd_mode $aci_param $reset_params $cluster_param"

0 comments on commit 1eec478

Please sign in to comment.