Permalink
Browse files

update for removing a record as a first step in the process

  • Loading branch information...
1 parent 7d911c4 commit b2179c65b80bd6c7aab21e1d2e53c4844c39e87d @kgray87 kgray87 committed Dec 13, 2010
Showing with 8 additions and 13 deletions.
  1. +8 −13 scripts/replace_server.sh
@@ -5,24 +5,20 @@ mkdir ~/gameday_temp
# use our template file to create a json file with the correct ip address in it
IPTODELETE=$1
-IPTODELETE=$(echo $IPTODELETE|sed 's/\./a/g')
-sed s/xxxx/${IPTODELETE}/g ~/gameday/script_resources/dynect_delete.template > ~/gameday_temp/dynect_delete.json
-# now use the json file to create a data bag with the ip to be deleted so that we can remove it
-knife data bag delete dynect_delete -y
-knife data bag create dynect_delete
-knife data bag from file dynect_delete ~/gameday_temp/dynect_delete.json
+# first lets get this IP out of the list of DNS A Records so users won't see a bad server
+ruby ~/gameday/script_resources/ruby_delete_a_record.rb $IPTODELETE
# remove the bad server from zenoss's monitoring
-wget -T 5 -t 1 --auth-no-challenge --http-user=XXXXXXX --http-password=XXXXXXX "http://devops.zenoss.com:8080/zport/dmd/Devices/Server/Linux/devices/$1/deleteDevice"
+wget -T 5 -t 1 --quiet --auth-no-challenge --http-user=gameday --http-password=zenossgd "http://devops.zenoss.com:8080/zport/dmd/Devices/Server/SSH/Linux/devices/$1/deleteDevice"
-# call out to chef to remove the ec2 instance
+# call out to chef to remove the old ec2 instance
knife ec2 server delete $2 -y
-# bring up the new ec2 cloud server
-knife ec2 server create -G default -S dynect-ops-integration -I ~/gameday/script_resources/dynect-ops-integration.pem -Z us-east-1c --flavor m1.small -i ami-a6c62ecf -x ubuntu -s https://api.opscode.com/organizations/cloudworkshop 'role[base]' 'recipe[dynect::default]' 'recipe[dynect::del_a_record]' 'role[wordpress1]' 'recipe[dynect::add_a_record]' 2>&1 | tee ~/gameday_temp/server_create_output.txt
+# bring up the new ec2 cloud server
+knife ec2 server create -G default -S dynect-ops-integration -I ~/gameday/script_resources/dynect-ops-integration.pem -Z us-east-1c --flavor m1.small -i ami-a6c62ecf -x ubuntu -s https://api.opscode.com/organizations/cloudworkshop 'role[base]' 'recipe[dynect::default]' 'role[wordpress1]' 'recipe[dynect::add_a_record]' 2>&1 | tee ~/gameday_temp/server_create_output.txt
-# parse through the output of the knife create to get the newly created instance id
+# parse through the output of the knife create to get the newly created instance id
cat ~/gameday_temp/server_create_output.txt | grep -m 1 'Instance ID' > ~/gameday_temp/instance_id.txt
INSTANCEID=`cat ~/gameday_temp/instance_id.txt | grep -o 'i-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]'`
@@ -31,9 +27,8 @@ cat ~/gameday_temp/server_create_output.txt | grep -m 1 'Public IP Address' > ~/
PUBLIC_IP=`cat ~/gameday_temp/public_ip_line.txt | grep -o '[0-9]*[0-9]*[0-9][.][0-9]*[0-9]*[0-9][.][0-9]*[0-9]*[0-9][.][0-9]*[0-9]*[0-9]'`
# add new server to zenoss to monitor again
-wget -T 5 -t 1 --auth-no-challenge --http-user=XXXXXXX --http-password=XXXXXXX "http://devops.zenoss.com:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=$PUBLIC_IP&devicePath=/Server/Linux&tag=$INSTANCEID"
+wget -T 5 -t 1 --quiet --auth-no-challenge --http-user=gameday --http-password=zenossgd "http://devops.zenoss.com:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=$PUBLIC_IP&devicePath=/Server/SSH/Linux&tag=$INSTANCEID"
# now let's cleanup our temp work
rm -r ~/gameday_temp
-

0 comments on commit b2179c6

Please sign in to comment.