Skip to content

Instantly share code, notes, and snippets.

@rahulvramesh
Forked from enricobacis/install.sh
Last active April 6, 2019 03:31
Show Gist options
  • Select an option

  • Save rahulvramesh/af0dcc43d3a0ca893873a729db347ee2 to your computer and use it in GitHub Desktop.

Select an option

Save rahulvramesh/af0dcc43d3a0ca893873a729db347ee2 to your computer and use it in GitHub Desktop.
openstack installation on CentOS 7
#!/bin/bash
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
#read config
ifconfig
read -p "Enter your external interface: " EXT_INTER
set -x # enable echo
#update
sudo yum update -y
#disable network
sudo systemctl disable firewalld
sudo systemctl stop firewalld
sudo systemctl disable NetworkManager
sudo systemctl stop NetworkManager
sudo systemctl enable network
sudo systemctl start network
sudo yum install -y vim git tmux bash-completion net-tools htop psmisc
sudo yum install -y https://rdoproject.org/repos/rdo-release.rpm
sudo yum install -y centos-release-openstack-rocky
#ltmux kep mux , no need though will see later
curl -L bit.do/ltmux | sudo tee /usr/bin/ltmux
sudo chmod a+x /usr/bin/ltmux
yum-config-manager --enable openstack-rocky
sudo yum update -y
#install openstack
sudo yum install -y openstack-packstack
#beep
echo -e '\a'
# fix kvm
sudo rmmod kvm_intel
sudo rmmod kvm
sudo modprobe kvm
sudo modprobe kvm_intel
#install packsatcl
packstack --allinone --provision-demo=n --os-neutron-ovs-bridge-mappings=extnet:br-ex --os-neutron-ovs-bridge-interfaces=br-ex:$EXT_INTER --os-neutron-ml2-type-drivers=vxlan,flat
# network configuration (https://www.rdoproject.org/networking/neutron-with-existing-external-network/)
sudo tee /etc/sysconfig/network-scripts/ifcfg-br-ex <<EOF
DEVICE=br-ex
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=1176.9.3.12 # Old $EXT_INTERFACE IP since we want the network restart to not
# kill the connection, otherwise pick something outside your dhcp range
NETMASK=255.255.255.255 # your netmask
GATEWAY=176.9.3.1 # your gateway
DNS1=213.133.100.100 # your nameserver
DNS2=213.133.99.99 # your nameserver
DNS3=213.133.98.98 # your nameserver
ONBOOT=yes
EOF
sudo tee /etc/sysconfig/network-scripts/$EXT_INTERFACE <<EOF
DEVICE=$EXT_INTERFACE
TYPE=OVSPort
DEVICETYPE=ovs
OVS_BRIDGE=br-ex
ONBOOT=yes
EOF
sudo tee /etc/sysconfig/network-scripts/ifcfg-bond0 <<EOF
DEVICE=bond0
DEVICETYPE=ovs
TYPE=OVSPort
OVS_BRIDGE=br-ex
ONBOOT=yes
BONDING_MASTER=yes
BONDING_OPTS="mode=802.3ad"
EOF
echo -e '\a\n\n\n\n\n' # beep
ifconfig
read -n1 -p "mark the IP_ADDR, NETMASK and GATEWAY of $EXT_INTERFACE
then hit any key to enter vi (save and close with <ESC> followed by :wq <ENTER>)"
sudo vi /etc/sysconfig/network-scripts/ifcfg-br-ex
sudo service network restart
source <(sudo cat /root/keystonerc_admin)
neutron net-create external_network --provider:network_type flat --provider:physical_network extnet --router:external
read -p "subnet pool-start-IP: " SUB_POOL_START
read -p "subnet pool-end-IP: " SUB_POOL_END
read -p "subnet gateway: " SUB_GATEWAY
read -p "subnet network (e.g. 192.168.1.0/24): " SUB_NETWORK
neutron subnet-create \
--name public_subnet \
--enable_dhcp=False \
--allocation-pool=start=$SUB_POOL_START,end=$SUB_POOL_END \
--gateway=$SUB_GATEWAY \
external_network $SUB_NETWORK
# download cirros image
curl http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img | glance \
image-create \
--name='cirros image' \
--visibility=public \
--container-format=bare \
--disk-format=qcow2
# create user
echo -e '\a\n\n\n\n\n' # beep
read -p "new project name: " PROJ_NAME
read -p "new username: " PROJ_USERNAME
read -p "new email: " PROJ_EMAIL
read -s -p "new password: " PROJ_PASSWORD
openstack project create --enable $PROJ_NAME
openstack user create --project $PROJ_NAME --password $PROJ_PASSWORD --email $PROJ_EMAIL --enable $PROJ_USERNAME
# allow ICMP and SSH access
for SECGROUPID in $(openstack security group list -f csv --quote none | grep default | cut -d',' -f1); do
neutron security-group-rule-create \
--direction ingress \
--ethertype IPv4 \
--protocol icmp \
$SECGROUPID
neutron security-group-rule-create \
--direction ingress \
--ethertype IPv4 \
--protocol tcp \
--port-range-min 22 \
--port-range-max 22 \
$SECGROUPID
done
# switch to new user
export OS_USERNAME=$PROJ_USERNAME
export OS_TENANT_NAME=$PROJ_NAME
export OS_PASSWORD=$PROJ_PASSWORD
# configuring network (https://www.rdoproject.org/networking/neutron-with-existing-external-network/)
neutron router-create router1
neutron router-gateway-set router1 external_network
neutron net-create private_network
neutron subnet-create --name private_subnet private_network 192.168.100.0/24
neutron router-interface-add router1 private_subnet
# restarting network
echo -e '\a' # beep
sudo ifdown br-ex
sudo ifup br-ex
sudo service network restart
echo -e '\a' # beep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment