Make 98-undercloud-setup rerunnable

This patch makes 98-undercloud-setup rerunnable, and drops the check for
the $OK_FILE so that the script is rerun every time "openstack
undercloud install" is executed.

This makes it such the installer can be rerun and the configuration from
undercloud.conf is always applied, without having to do things such as
manual db cleanup or hackery.

The neutron network and subnet are updated as long as the cidr is the
same.  Neutron does not allow updating a subnet cidr, so in the case
where the cidr is different, the network/subnet will be deleted and
recreated.

Note that as part of testing update the local_ip setting, I discovered
that bind_host for glance-registry was unset in the puppet hieradata,
causing glance registry to bind to 0.0.0.0. That has been fixed here as
well.

Change-Id: I7a8daa334ceb7f69fb28fe7cfc456aa1bf81e119
This commit is contained in:
James Slagle
2015-09-10 09:08:30 -04:00
parent 801428e3b4
commit fb7954193d
3 changed files with 58 additions and 21 deletions

View File

@@ -28,6 +28,7 @@ class { '::mysql::server':
'open_files_limit' => '-1',
},
},
restart => true
}
# FIXME: this should only occur on the bootstrap host (ditto for db syncs)

View File

@@ -72,6 +72,7 @@ glance_protocol: http
glance_notifier_strategy: noop
glance_log_file: ''
glance::api::database_connection: mysql://glance:{{UNDERCLOUD_GLANCE_PASSWORD}}@{{LOCAL_IP}}/glance
glance::registry::bind_host: {{LOCAL_IP}}
glance::registry::keystone_password: {{UNDERCLOUD_GLANCE_PASSWORD}}
glance::registry::database_connection: mysql://glance:{{UNDERCLOUD_GLANCE_PASSWORD}}@{{LOCAL_IP}}/glance
glance::registry::identity_uri: "%{hiera('keystone_identity_uri')}"

View File

@@ -4,10 +4,6 @@ set -eux
OK_FILE=/opt/stack/.undercloud-setup
if [ -f $OK_FILE ]; then
exit
fi
source /root/tripleo-undercloud-passwords
source /root/stackrc
@@ -38,24 +34,63 @@ NETWORK_GATEWAY=$(os-apply-config --key neutron.network_gateway --type netaddres
METADATA_SERVER=$UNDERCLOUD_IP
PHYSICAL_NETWORK=ctlplane
NETWORK_JSON=$(mktemp)
NETWORK_JSON_DATA='{"physical":{}}'
NETWORK_JSON_DATA=$(jq '.physical = .physical + {
"gateway": "'$NETWORK_GATEWAY'",
"metadata_server": "'$UNDERCLOUD_IP'",
"cidr": "'$NETWORK_CIDR'",
"allocation_start": "'$DHCP_START'",
"allocation_end": "'$DHCP_END'",
"name": "'$PHYSICAL_NETWORK'",
}' <<< $NETWORK_JSON_DATA)
if [ -n "${UNDERCLOUD_NAMESERVER:-}" ]; then
NETWORK_JSON_DATA=$(jq '.physical = .physical + {
"nameserver": "'$UNDERCLOUD_NAMESERVER'",
}' <<< $NETWORK_JSON_DATA)
net_create=1
ctlplane_id=$(neutron net-list -f csv -c id -c name --quote none | tail -n +2 | grep ctlplane | cut -d, -f 1)
subnet_ids=$(neutron subnet-list -f csv -c id --quote none | tail -n +2)
subnet_id=
for subnet_id in $subnet_ids; do
network_id=$(neutron subnet-show -f value -c network_id $subnet_id)
if [ "$network_id" = "$ctlplane_id" ]; then
break
fi
done
if [ -n "$subnet_id" ]; then
cidr=$(neutron subnet-show $subnet_id -f value -c cidr)
# If the cidr's are equal, we can get by with just a network update
if [ "$cidr" = "$NETWORK_CIDR" ]; then
net_create=0
neutron subnet-update $subnet_id \
--allocation-pool start=$DHCP_START,end=$DHCP_END \
--gateway $NETWORK_GATEWAY \
--host-route destination=169.254.169.254/32,nexthop=$METADATA_SERVER
else
echo "New cidr $NETWORK_CIDR does not equal old cidr $cidr"
echo "Will attempt to delete and recreate subnet $subnet_id"
fi
fi
if [ "$net_create" -eq "1" ]; then
# Delete the subnet and network to make sure it doesn't already exist
if neutron subnet-list | grep start; then
neutron subnet-delete $(neutron subnet-list | grep start | awk '{print $2}')
fi
if neutron net-show ctlplane; then
neutron net-delete ctlplane
fi
NETWORK_JSON=$(mktemp)
NETWORK_JSON_DATA='{"physical":{}}'
NETWORK_JSON_DATA=$(jq '.physical = .physical + {
"gateway": "'$NETWORK_GATEWAY'",
"metadata_server": "'$UNDERCLOUD_IP'",
"cidr": "'$NETWORK_CIDR'",
"allocation_start": "'$DHCP_START'",
"allocation_end": "'$DHCP_END'",
"name": "'$PHYSICAL_NETWORK'",
}' <<< $NETWORK_JSON_DATA)
if [ -n "${UNDERCLOUD_NAMESERVER:-}" ]; then
NETWORK_JSON_DATA=$(jq '.physical = .physical + {
"nameserver": "'$UNDERCLOUD_NAMESERVER'",
}' <<< $NETWORK_JSON_DATA)
fi
jq . > $NETWORK_JSON <<< $NETWORK_JSON_DATA
setup-neutron -n $NETWORK_JSON
rm $NETWORK_JSON
fi
jq . > $NETWORK_JSON <<< $NETWORK_JSON_DATA
setup-neutron -n $NETWORK_JSON
rm $NETWORK_JSON
# Delete initial flavors
for flavor in m1.tiny m1.small m1.medium m1.large m1.xlarge; do