Skip to content

Commit

Permalink
Merge pull request redhat-openstack#44 from jguiditta/havanna
Browse files Browse the repository at this point in the history
Update astaphor to work with foreman 1.2.1 and openstack havanna.
  • Loading branch information
jsomara committed Aug 20, 2013
2 parents 0182d15 + d7214eb commit b2eac89
Show file tree
Hide file tree
Showing 512 changed files with 36 additions and 23,456 deletions.
65 changes: 27 additions & 38 deletions bin/foreman_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ if [ "x$PACKSTACK_HOME" = "x" ]; then
fi

if [ "x$FOREMAN_INSTALLER_DIR" = "x" ]; then
FOREMAN_INSTALLER_DIR=/usr/share/openstack-foreman-installer/installer_puppet
FOREMAN_INSTALLER_DIR=/usr/share/foreman-installer
fi

if [ "x$FOREMAN_DIR" = "x" ]; then
FOREMAN_DIR=$SCL_RUBY_HOME/usr/share/foreman
FOREMAN_DIR=/usr/share/foreman
fi

if [ ! -d $FOREMAN_INSTALLER_DIR ]; then
Expand All @@ -100,15 +100,15 @@ if [ ! -f /etc/redhat-release ] || \
fi

if [ "$FOREMAN_PROVISIONING" = "true" ]; then
NUM_INT=$(scl enable ruby193 "facter -p"|grep ipaddress_|grep -v _lo|wc -l)
NUM_INT=$(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) ) }')
PRIMARY_PREFIX=$(scl enable ruby193 "facter network_${PRIMARY_INT}" | cut -d. -f1-3)
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)
PRIMARY_PREFIX=$(facter network_${PRIMARY_INT} | cut -d. -f1-3)
SECONDARY_INT=$(facter -p|grep ipaddress_|grep -Ev "_lo|$PRIMARY_INT"|awk -F"[_ ]" '{print $2;exit 0}')
SECONDARY_PREFIX=$(facter network_${SECONDARY_INT} | cut -d. -f1-3)
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}')
fi
Expand All @@ -126,13 +126,10 @@ sudo sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.co
setenforce 0

# Puppet configuration
augtool <<EOF
set /augeas/load/Puppet/incl[last()+1] /opt/rh/ruby193/root/etc/puppet/puppet.conf
load
set /files/opt/rh/ruby193/root/etc/puppet/puppet.conf/agent/server $PUPPETMASTER
set /files/opt/rh/ruby193/root/etc/puppet/puppet.conf/main/pluginsync true
save
EOF
augtool -s <<EOA
set /files/etc/puppet/puppet.conf/agent/server $PUPPETMASTER
set /files/etc/puppet/puppet.conf/main/pluginsync true
EOA

# fix db migrate script for scl
cp ../config/dbmigrate $FOREMAN_DIR/extras/
Expand All @@ -149,8 +146,7 @@ include puppet::server
include passenger
class { 'foreman':
db_type => 'mysql',
custom_repo => true,
app_root => '/opt/rh/ruby193/root/usr/share/foreman'
custom_repo => true
}
#
# Check foreman_proxy/manifests/{init,params}.pp for other options
Expand All @@ -160,7 +156,7 @@ EOM

if [ "$FOREMAN_PROVISIONING" = "true" ]; then
cat >> installer.pp << EOM
tftp_servername => '$(scl enable ruby193 "facter ipaddress_${SECONDARY_INT}")',
tftp_servername => '$(facter ipaddress_${SECONDARY_INT})',
dhcp => true,
dhcp_gateway => '${FOREMAN_GATEWAY}',
dhcp_range => '${SECONDARY_PREFIX}.50 ${SECONDARY_PREFIX}.200',
Expand All @@ -183,15 +179,15 @@ EOM

fi

scl enable ruby193 "puppet apply --verbose installer.pp --modulepath=. "
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
# GSutcliffe: Should be uneccessary once Foreman Provisioning is shown to be working
echo '*' >> $SCL_RUBY_HOME/etc/puppet/autosign.conf
echo '*' >> /etc/puppet/autosign.conf

# Add smart proxy
sed -i "s/foreman_hostname/$PUPPETMASTER/" foreman-params.json
Expand All @@ -200,21 +196,17 @@ scl enable ruby193 "ruby foreman-setup.rb proxy"
# Class defaults now handled by the seed file, see below

# install puppet modules
mkdir -p $SCL_RUBY_HOME/etc/puppet/environments/production/modules
mkdir -p /etc/puppet/environments/production/modules
# copy ntp, quickstack
cp -r ../puppet/modules/* $SCL_RUBY_HOME/etc/puppet/environments/production/modules/
cp -r ../puppet/modules/* /etc/puppet/environments/production/modules/
# copy packstack
cp -r $PACKSTACK_HOME/modules/* $SCL_RUBY_HOME/etc/puppet/environments/production/modules/
cp -r $PACKSTACK_HOME/modules/* /etc/puppet/environments/production/modules/
# don't need this for puppet 3.1
rm -rf $SCL_RUBY_HOME/etc/puppet/environments/production/modules/create_resources
rm -rf /etc/puppet/environments/production/modules/create_resources
# fix an error caused by ASCII encoded comment
sed -i 's/^#.*//' $SCL_RUBY_HOME/etc/puppet/environments/production/modules/horizon/manifests/init.pp
sed -i 's/^#.*//' /etc/puppet/environments/production/modules/horizon/manifests/init.pp
sudo -u foreman scl enable ruby193 "cd $FOREMAN_DIR; RAILS_ENV=production rake puppet:import:puppet_classes[batch]"

# Fix the proxy (is already done upstream)
echo ":dns_provider: nsupdate" >> /opt/rh/ruby193/root/etc/foreman-proxy/settings.yml
/etc/init.d/foreman-proxy restart

# Set params, and run the db:seed file
cp ./seeds.rb $FOREMAN_DIR/db/.
sed -i "s#SECONDARY_INT#$SECONDARY_INT#" $FOREMAN_DIR/db/seeds.rb
Expand All @@ -235,24 +227,21 @@ fi
# TODO don't hit yum unless packages are not installed
cat >/tmp/foreman_client.sh <<EOF
# start with a subscribed RHEL6 box
yum install -y augeas ruby193-puppet
# start with a subscribed RHEL6 box needs optional channels and epel
yum install -y augeas puppet
# Puppet configuration
augtool <<EOA
set /augeas/load/Puppet/incl[last()+1] /opt/rh/ruby193/root/etc/puppet/puppet.conf
load
set /files/opt/rh/ruby193/root/etc/puppet/puppet.conf/agent/server $PUPPETMASTER
set /files/opt/rh/ruby193/root/etc/puppet/puppet.conf/main/pluginsync true
save
augtool -s <<EOA
set /files/etc/puppet/puppet.conf/agent/server $PUPPETMASTER
set /files/etc/puppet/puppet.conf/main/pluginsync true
EOA
# check in to foreman
scl enable ruby193 "puppet agent --test"
puppet agent --test
sleep 1
scl enable ruby193 "puppet agent --test"
puppet agent --test
/etc/init.d/ruby193-puppet start
/etc/init.d/puppet start
EOF

echo "Foreman is installed and almost ready for setting up your OpenStack"
Expand Down
8 changes: 4 additions & 4 deletions bin/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@
yum -t -y -e 0 update
# and add the puppet package
yum -t -y -e 0 install ruby193-puppet
yum -t -y -e 0 install puppet
echo "Configuring puppet"
cat > /opt/rh/ruby193/root/etc/puppet/puppet.conf << EOF
cat > /etc/puppet/puppet.conf << EOF
<%= snippets "puppet.conf" %>
EOF
# Setup puppet to run on system reboot
/sbin/chkconfig --level 345 ruby193-puppet on
/sbin/chkconfig --level 345 puppet on
scl enable ruby193 "puppet agent --config /opt/rh/ruby193/root/etc/puppet/puppet.conf -o --tags no_such_tag --server <%= @host.puppetmaster %> --no-daemonize"
puppet agent -o --tags no_such_tag --server <%= @host.puppetmaster %> --no-daemonize
sync
Expand Down
Loading

0 comments on commit b2eac89

Please sign in to comment.