Skip to content

Instantly share code, notes, and snippets.

@kitplummer
Created February 1, 2013 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitplummer/4687936 to your computer and use it in GitHub Desktop.
Save kitplummer/4687936 to your computer and use it in GitHub Desktop.
initialize openstack instance.
#!/bin/bash
if [ -f /root/.initialized ]; then
exit 0
fi
FQDN=`/usr/bin/curl -s http://169.254.169.254/latest/user-data | grep hostname | sed 's/.*=//' | sed 's/ //'`
HOSTNAME=`echo ${FQDN} | awk -F"." '{print $1}'`
PM=`/usr/bin/curl -s http://169.254.169.254/latest/user-data | grep puppetmaster | sed 's/.*=//' | sed 's/ //'`
if [ "$FQDN" == "" ]; then
echo "No hostname found in user metadata"
exit 0
fi
echo $FQDN > /etc/hostname
hostname $FQDN
echo "PM: $PM"
echo "server=$PM" >> /etc/puppet/puppet.conf
echo "listen=true" >> /etc/puppet/puppet.conf
echo "127.0.0.1 localhost $HOSTNAME $FQDN" > /etc/hosts
sed -ie '$d' /etc/ddclient.conf
echo "$HOSTNAME" >> /etc/ddclient.conf
#/usr/sbin/ddclient -foreground -ip `curl http://169.254.169.254/latest/meta-data/public-ipv4`
rm -rf /etc/puppet/ssl
puppet agent --waitforcert 60 --server puppet --test --no-daemonize
#touch /root/.initialized
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
sh /root/initialized.sh
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment