Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
CentOS7 master node bootstrap changes
Browse files Browse the repository at this point in the history
Updates to bootstrap_admin_node:
* workaround for dracut setting the same IP address to
  multilple interfaces if they exist
* redirect output to log file

Update to ks.template:
* bootstrap_admin_node to be started as 'run-once' logon script
* drop script that modifies 'issues' file because it
  supports substitution of some parameters out of the box

Blueprint: master-on-centos7

Is NOT compatible with CentOS6 master node

Change-Id: I2feae7055b382adb0ec13a8744e3d9c9ddca16d8
  • Loading branch information
teselkin committed Dec 4, 2015
1 parent fda7c87 commit 2a5b896
Show file tree
Hide file tree
Showing 3 changed files with 295 additions and 289 deletions.
108 changes: 98 additions & 10 deletions iso/bootstrap_admin_node.sh
@@ -1,4 +1,8 @@
#!/bin/bash
mkdir -p /var/log/puppet
exec > >(tee -i /var/log/puppet/bootstrap_admin_node.log)
exec 2>&1

FUEL_RELEASE=$(grep release: /etc/fuel/version.yaml | cut -d: -f2 | tr -d '" ')

function countdown() {
Expand Down Expand Up @@ -49,21 +53,93 @@ function get_ethernet_interfaces() {
done
}

# Get value of a key from ifcfg-* files
# Usage:
# get_ifcfg_value NAME /etc/sysconfig/network-scripts/ifcfg-eth0
function get_ifcfg_value {
local key=$1
local path=$2
local value=''
if [[ -f ${path} ]]; then
value=$(awk -F\= "\$1==\"${key}\" {print \$2}" ${path})
value=${value//\"/}
fi
echo ${value}
}

# Workaround to fix dracut network configuration approach:
# Bring down all network interfaces which have the same IP
# address statically configured as 'primary' interface
function ifdown_ethernet_interfaces {
local adminif_ipaddr
local if_config
local if_name
local if_ipaddr

adminif_ipaddr=$(get_ifcfg_value IPADDR /etc/sysconfig/network-scripts/ifcfg-${ADMIN_INTERFACE})
for if_config in $(find /etc/sysconfig/network-scripts -name 'ifcfg-*' ! -name 'ifcfg-lo'); do
if_name=$(get_ifcfg_value NAME $if_config)
if [[ "${if_name}" == "${ADMIN_INTERFACE}" ]]; then
continue
fi
if_ipaddr=$(get_ifcfg_value IPADDR $if_config)
if [[ "${if_ipaddr}" == "${adminif_ipaddr}" ]]; then
echo "Interface '${if_name}' uses the same ip '${if_ipaddr}' as admin interface '${ADMIN_INTERFACE}', removing ..."
ifdown ${if_name}
rm -f ${if_config}
fi
done
}

# Check if interface name is valid by checking that
# a config file with NAME equal to given name exists.
function ifname_valid {
local adminif_name=$1
local if_name
local if_config
for if_config in $(find /etc/sysconfig/network-scripts -name 'ifcfg-*' ! -name 'ifcfg-lo'); do
if_name=$(get_ifcfg_value NAME $if_config)
if [[ "${if_name}" == "${adminif_name}" ]]; then
return 0
fi
done
return 1
}


# LANG variable is a workaround for puppet-3.4.2 bug. See LP#1312758 for details
export LANG=en_US.UTF8
# Be sure, that network devices have been initialized
udevadm trigger --subsystem-match=net
udevadm settle
# Take the very first ethernet interface as an admin interface
ADMIN_INTERFACE=$(get_ethernet_interfaces | sort -V | head -1)
export ADMIN_INTERFACE

showmenu="no"
# Import bootstrap_admin_node.conf if exists
if [ -f /etc/fuel/bootstrap_admin_node.conf ]; then
. /etc/fuel/bootstrap_admin_node.conf
echo "Applying admin interface '$ADMIN_INTERFACE'"
source /etc/fuel/bootstrap_admin_node.conf
fi

# Set defaults to unset / empty variables
# Although eth0 is not always valid it's a good well-known default
# If there is no such interface it will fail to pass ifname_valid
# check and will be replaced.
ADMIN_INTERFACE=${ADMIN_INTERFACE:-'eth0'}
showmenu=${showmenu:-'no'}

# Now check that ADMIN_INTERFACE points to a valid interface
# If it doesn't fallback to getting the first interface name
# from a list of all available interfaces sorted alphabetically
if ! ifname_valid $ADMIN_INTERFACE; then
# Take the very first ethernet interface as an admin interface
ADMIN_INTERFACE=$(get_ethernet_interfaces | sort -V | head -1)
fi

echo "Applying admin interface '$ADMIN_INTERFACE'"
export ADMIN_INTERFACE

echo "Bringing down ALL network interfaces except '${ADMIN_INTERFACE}'"
ifdown_ethernet_interfaces
systemctl restart network

echo "Applying default Fuel settings..."
set -x
fuelmenu --save-only --iface=$ADMIN_INTERFACE
Expand Down Expand Up @@ -92,8 +168,13 @@ if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then
fi

# Enable sshd
chkconfig sshd on
service sshd start
systemctl enable sshd
systemctl start sshd

# Enable iptables
systemctl enable iptables.service
systemctl start iptables.service


if [ "$wait_for_external_config" == "yes" ]; then
wait_timeout=3000
Expand Down Expand Up @@ -226,6 +307,11 @@ if [ $? -ge 4 ];then
fail
fi

# Sync time
systemctl stop ntpd
systemctl start ntpdate || echo "Failed to synchronize time with 'ntpdate'"
systemctl start ntpd

rmdir /var/log/remote && ln -s /var/log/docker-logs/remote /var/log/remote

dockerctl check || fail
Expand All @@ -239,7 +325,7 @@ fi
cat > /etc/yum.repos.d/mos${FUEL_RELEASE}-updates.repo << EOF
[mos${FUEL_RELEASE}-updates]
name=mos${FUEL_RELEASE}-updates
baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos6-fuel/updates/x86_64/
baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos\$releasever-fuel/updates/x86_64/
gpgcheck=0
skip_if_unavailable=1
EOF
Expand All @@ -248,7 +334,7 @@ EOF
cat > /etc/yum.repos.d/mos${FUEL_RELEASE}-security.repo << EOF
[mos${FUEL_RELEASE}-security]
name=mos${FUEL_RELEASE}-security
baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos6-fuel/security/x86_64/
baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos\$releasever-fuel/security/x86_64/
gpgcheck=0
skip_if_unavailable=1
EOF
Expand Down Expand Up @@ -290,3 +376,5 @@ fuel notify --topic "${level}" --send $(echo "${message}" | tr '\r\n' ' ')
# advice how to treat this.

echo "Fuel node deployment complete!"
# Sleep for agetty autologon
sleep 3

0 comments on commit 2a5b896

Please sign in to comment.