Commit 35cc3773 authored by Jens-Petter Salvesen's avatar Jens-Petter Salvesen

initial commit - untested

parents
Pipeline #2247 failed with stages
in 9 seconds
# servers to create
export list=("083" "093" "043" "063" "106" "114")
# set some params we'll use throughout the scripts
export postfix="-test" # set to "" for production
export puppetenv="api_ece5_master"
export os_avail_zone="osl3" #osl2,osl3,osl4 - the availability zone we're creating VMs in
export os_network="api.test-network-osl2"
export os_disk_size=35 # set to 0 for no external storage (for the g2* flavors)
export os_key_name="jeppe"
export os_flavor="gp.large"
export os_security_groups=("escenic-test.pfw" "sg.pfw")
#!/usr/bin/env bash
export list=("083" "093" "043" "063" "106" "114")
# abort on error
set -e
# create dir for yamls unless it already exists
mkdir -p ./yamls/
# create yamls
# start by writing this to template.yml.
echo "
# cloud-config
hostname: eceplaceholder$postfix
fqdn: eceplaceholder$postfix.api.c.bitbit.net
puppet_server: puppet.api.c.bitbit.net
puppet_environment: puppetenv
bootcmd:
- printf "SELINUX=permissive\nSELINUXTYPE=targeted\n" > /etc/selinux/config
- ifconfig eth0 mtu 1450
packages:
- vim
package_update: true
rlnc-init: true" > ./template.yml
# go over the servers in the list and create a yaml for it inside yamls/
for i in ${list[@]}; do
cp ./template.yml ./yamls/ece$i$postfix.api.yaml
sed -i "s/placeholder/$i/g" ./yamls/ece$i$postfix.api.yaml
sed -i "s/puppetenv/$puppetenv/g" ./yamls/ece$i$postfix.api.yaml
done
set +e
#!/usr/bin/env bash
export list=("083" "093" "043" "063" "106" "114")
# abort on error
set -e
# only create disks if os_disk_size is set.
if [ ! -z "${os_disk_size}" ]; then
#create disks
echo "creating openstack disks"
for i in ${list[@]}; do
echo "making volume ece$i$postfix-disk for server ece$i$postfix"
openstack volume create \
--type ceph-sata \
--bootable \
--availability-zone $os_avail_zone \
--image e891d4d4-ca59-4a39-b54d-96811098a1e2 \
--size $os_disk_size ece$i$postfix-disk
done
fi
set +e
#!/usr/bin/env bash
export list=("083" "093" "043" "063" "106" "114")
# abort on error
set -e
echo ${list[*]}
echo $os_flavor
# create instances:
for i in ${list[@]};do
echo "making vm for item $i"
cmd="openstack server create "
cmd+="--volume ece$i$postfix-disk "
cmd+="--flavor $os_flavor "
for secgroup in ${os_security_groups[@]};
do
cmd+="--security-group $secgroup "
done
cmd+="--user-data ./yamls/ece$i$postfix.api.yaml "
cmd+="--availability-zone $os_avail_zone "
cmd+="--network $os_network "
cmd+="--key-name $os_key_name "
cmd+="ece$i$postfix.api";
echo $cmd
done
set +e
#!/usr/bin/env bash
export list=("083" "093" "043" "063" "106" "114")
# abort on error
set -e
echo '%migratehosts' > ./mpssh_hosts
echo '[migratehosts]' > ./ansible_hosts
for i in ${list[@]}; do
hostname= "ece$i$postfix.api"
IPV4=`openstack server list|grep $hostname |awk '{print $9}'`
IPV6=`openstack server show $hostname |grep addresses|awk '{print $4}'|awk -F"=" '{print $2}'|cut -d ',' -f1`
echo $hostname
echo $IPV4
echo $IPV6
echo ------adding ip adresses to ansible ./ansible_hosts
echo $IPV4 >> ./ansible_hosts
echo $IPV4 >> ./mpssh_hosts
echo "updating dns"
echo "
update delete $hostname.c.bitbit.net A
update delete $hostname.c.bitbit.net AAAA
update add $hostname.c.bitbit.net 60 in A $IPV4
update add $hostname.api.c.bitbit.net 60 in AAAA $IPV6
send
answer
"
# | tee -a dnsupdates | nsupdate -v -k ~v/.cert/Kapi.c.bitbit.net.+157+49975.key;
done
echo run 'mpssh -sf mpssh_hosts "sudo ps -ef|grep puppet"'
set +e
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment