Skip to content

Commit

Permalink
Merge pull request redhat-openstack#29 from domcleal/networking
Browse files Browse the repository at this point in the history
Ordering, Networking
  • Loading branch information
jsomara committed May 30, 2013
2 parents 54dc8a2 + 5650a5b commit bc264d8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
37 changes: 27 additions & 10 deletions bin/foreman_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ if [ ! -f /etc/redhat-release ] || \
exit 1
fi

NUM_INT=$(scl enable ruby193 "facter -p"|grep ipaddress_|grep -v _lo|wc -l)
if [[ $NUM_INT -lt 2 ]] ; then
echo "This installer needs 2 configured interfaces - only $NUM_INT detected"
exit 1
fi
PRIMARY_INT=$(route|grep default|awk ' { print ( $(NF) ) }')
SECONDARY_INT=$(scl enable ruby193 "facter -p"|grep ipaddress_|grep -Ev "_lo|$PRIMARY_INT"|awk -F"[_ ]" '{print $2;exit 0}')
SECONDARY_PREFIX=$(scl enable ruby193 "facter network_${SECONDARY_INT}" | cut -d. -f1-3) # -> 10.0.0 -> '0.0.10.in-addr.arpa',
SECONDARY_REVERSE=$(echo "$SECONDARY_PREFIX" | ( IFS='.' read a b c ; echo "$c.$b.$a.in-addr.arpa" ))
FORWARDER=$(augtool get /files/etc/resolv.conf/nameserver[1] | awk '{printf $NF}')

# start with a subscribed RHEL6 box. hint:
# subscription-manager register
# subscription-manager subscribe --auto
Expand Down Expand Up @@ -80,22 +91,29 @@ class { 'foreman':
class { 'foreman_proxy':
custom_repo => true,
dhcp => true,
dhcp_gateway => '10.0.0.1',
dhcp_range => '10.0.0.50 10.0.0.200',
dhcp_nameservers => '10.0.1.2,10.0.1.3',
dhcp_gateway => '${SECONDARY_PREFIX}.1',
dhcp_range => '${SECONDARY_PREFIX}.50 ${SECONDARY_PREFIX}.200',
dhcp_interface => '${SECONDARY_INT}',
dns => true,
dns_reverse => '0.0.10.in-addr.arpa',
dns_reverse => '${SECONDARY_REVERSE}',
dns_forwarders => ['${FORWARDER}'],
dns_interface => '${SECONDARY_INT}',
}
EOM
scl enable ruby193 "puppet apply --verbose installer.pp --modulepath=. "
popd

# reset permissions
sudo -u foreman scl enable ruby193 "cd $FOREMAN_DIR; RAILS_ENV=production rake permissions:reset"

# turn on certificate autosigning
echo '*' >> $SCL_RUBY_HOME/etc/puppet/autosign.conf

sed -i "s/foreman_hostname/$PUPPETMASTER/" foreman-params.json

# Add smart proxy
scl enable ruby193 "ruby foreman-setup.rb proxy"
scl enable ruby193 "ruby foreman-setup.rb hostgroups"

# Configure class defaults
# This is not ideal, but will work until the API v2 is ready
Expand All @@ -108,17 +126,16 @@ do
sed -i "/CHANGEME/ {s/CHANGEME/$PASSWD/;:a;n;ba}" ../puppet/modules/trystack/manifests/params.pp
done

sed -i "s/PRIMARY/$PRIMARY_INT/" ../puppet/modules/trystack/manifests/params.pp
sed -i "s/SECONDARY/$SECONDARY_INT/" ../puppet/modules/trystack/manifests/params.pp

# install puppet modules
mkdir -p $SCL_RUBY_HOME/etc/puppet/environments/production/modules
cp -r ../puppet/modules/* $SCL_RUBY_HOME/etc/puppet/environments/production/modules/
sudo -u foreman scl enable ruby193 "cd $FOREMAN_DIR; RAILS_ENV=production rake puppet:import:puppet_classes[batch]"

# reset permissions
sudo -u foreman scl enable ruby193 "cd $FOREMAN_DIR; RAILS_ENV=production rake permissions:reset"

# Configure defaults, host groups, proxy, etc

sed -i "s/foreman_hostname/$PUPPETMASTER/" foreman-params.json
scl enable ruby193 "ruby foreman-setup.rb hostgroups"

# write client-register-to-foreman script
# TODO don't hit yum unless packages are not installed
Expand Down
4 changes: 2 additions & 2 deletions puppet/trystack/manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
$nova_user_password = 'CHANGEME'

# Networking
$private_interface = 'eth1'
$public_interface = 'eth0'
$public_interface = 'PRIMARY'
$private_interface = 'SECONDARY'
$fixed_network_range = inline_template("<%= scope.lookupvar('::network_${private_interface}') + '/' + scope.lookupvar('::netmask_${private_interface}') %>")
$floating_network_range = inline_template("<%= scope.lookupvar('::network_${public_interface}') + '/' + scope.lookupvar('::netmask_${public_interface}') %>")
$pacemaker_priv_floating_ip = inline_template("<%= scope.lookupvar('::ipaddress_${private_interface}') %>")
Expand Down

0 comments on commit bc264d8

Please sign in to comment.