Forked from danalsan/osp-ovn-playground-create.sh
Last active
September 17, 2020 19:44
-
-
Save flavio-fernandes/c572b228740bc3f43d4918815e902d0a to your computer and use it in GitHub Desktop.
osp-ovn-playground-create.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# | |
# | |
# +------------+ | |
# | | | |
# | | | |
# | public | | |
# | | | |
# | | | |
# +-----+------+ | |
# | | |
# | 10.0.0.244 | |
# | | |
# +-----+------+ | |
# 192.168.30.1 | | 192.168.40.1 | |
# | | | |
# +-------------------+ router1 +--------------------+ | |
# | | | | | |
# | | | | | |
# | +------------+ | | |
# | | | |
# | | | |
# | | | |
# +-----+------+ +------+-----+ | |
# | | | | | |
# | | | | | |
# +-----------+ private1 +--------+ +---------+ private2 +-----------+ | |
# | | | | | | | | | |
# | | | | | | | | | |
# | +------------+ | | +------------+ | | |
# | | | | | |
# | | | | | |
# |192.168.30.84 192.168.30.159| |192.168.40.166 192.168.40.220| | |
# |(10.0.0.170) | |(10.0.0.172) (10.0.0.173) | | |
#+-------------+ +-----+-------+ +-------------+ +------+------+ | |
#| | | | | | | | | |
#| +-------------------+ | | | | | | |
#| centos1_1 +-------------------+ centos1_2 | | centos2_1 | | centos2_2 | | |
#| c1 | VRRP | c0 | | c1 | | c0 | | |
#| | | | | | | | | |
#+-------------+ +-------------+ +-------------+ +-------------+ | |
# VIP: 192.168.30.166 | |
# (10.0.0.174) | |
# | |
source ~/overcloudrc | |
#openstack network list | |
for net in $(openstack network list -f value -c ID -c Name | grep -E "public|nova" | cut -d' ' -f1); do \ | |
echo network $net | |
for subnet in $(openstack subnet list --network $net -f value -c ID); do \ | |
openstack subnet delete $subnet | |
done | |
openstack network delete $net | |
done | |
[ -e CentOS-7-x86_64-GenericCloud.qcow2c ] || \ | |
curl https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2c > \ | |
CentOS-7-x86_64-GenericCloud.qcow2c | |
openstack image create "centos7" --file CentOS-7-x86_64-GenericCloud.qcow2c \ | |
--disk-format qcow2 --container-format bare \ | |
--public | |
[ -e cirros-0.4.0-x86_64-disk.img ] || \ | |
curl http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img > cirros-0.4.0-x86_64-disk.img | |
openstack image create "cirros" --file cirros-0.4.0-x86_64-disk.img \ | |
--disk-format qcow2 --container-format bare \ | |
--public | |
openstack network create public --provider-physical-network datacentre \ | |
--provider-network-type vlan \ | |
--provider-segment 10 \ | |
--external --share || \ | |
openstack network create public --provider-physical-network datacentre \ | |
--provider-network-type flat \ | |
--external --share | |
openstack subnet create --network public public --subnet-range 10.0.0.0/24 \ | |
--allocation-pool start=10.0.0.20,end=10.0.0.250 \ | |
--dns-nameserver 8.8.8.8 --gateway 10.0.0.1 \ | |
--no-dhcp | |
openstack network create private1 | |
openstack network create private2 | |
openstack subnet create --network private1 private1 --subnet-range 192.168.30.0/24 | |
openstack subnet create --network private2 private2 --subnet-range 192.168.40.0/24 | |
openstack router create router1 | |
openstack router set --enable-snat --external-gateway public router1 | |
openstack router add subnet router1 private1 | |
openstack router add subnet router1 private2 | |
openstack security group create sg1 | |
openstack security group rule create --ingress --protocol tcp --dst-port 22 sg1 | |
openstack security group rule create --ingress --protocol icmp sg1 | |
openstack security group rule create --protocol 112 sg1 | |
openstack security group create sg2 | |
openstack security group rule create --ingress --protocol tcp --dst-port 22 sg2 | |
openstack security group rule create --ingress --protocol icmp sg2 | |
openstack security group rule create --ingress --protocol tcp --dst-port 100:200 --remote-group sg1 sg2 | |
openstack security group rule create --ingress --protocol tcp --dst-port 300:400 --remote-group sg2 sg1 | |
openstack flavor create m1.tiny --disk 1 --vcpus 1 --ram 64 | |
openstack flavor create m1.medium --disk 10 --vcpus 1 --ram 512 | |
openstack keypair create centos_key > ~/centos_key.pem | |
chmod 0600 ~/centos_key.pem | |
openstack port create --network private1 --fixed-ip subnet=private1,ip-address=192.168.30.84 \ | |
--security-group sg1 private1_vm1 | |
openstack port create --network private1 --fixed-ip subnet=private1,ip-address=192.168.30.159 \ | |
--security-group sg1 private1_vm2 | |
openstack port create --network private2 --fixed-ip subnet=private2,ip-address=192.168.40.166 \ | |
--security-group sg2 private2_vm1 | |
openstack port create --network private2 --fixed-ip subnet=private2,ip-address=192.168.40.220 \ | |
--security-group sg2 private2_vm2 | |
openstack server create --flavor m1.medium --image centos7 --nic port-id=private1_vm1 --key-name centos_key centos1_1 | |
openstack server create --flavor m1.medium --image centos7 --nic port-id=private1_vm2 --key-name centos_key centos1_2 | |
openstack server create --flavor m1.medium --image centos7 --nic port-id=private2_vm1 --key-name centos_key centos2_1 | |
openstack server create --flavor m1.medium --image centos7 --nic port-id=private2_vm2 --key-name centos_key centos2_2 | |
for n in {0..3}; do | |
echo creating FIP 10.0.0.17$n | |
openstack floating ip create --floating-ip-address 10.0.0.17$n public | |
done | |
openstack floating ip set --port private1_vm1 10.0.0.170 | |
#openstack floating ip set --port private1_vm2 10.0.0.171 | |
openstack floating ip set --port private2_vm1 10.0.0.172 | |
openstack floating ip set --port private2_vm2 10.0.0.173 | |
source ~/stackrc | |
ansible -i /usr/bin/tripleo-ansible-inventory -m copy -a "src=~/centos_key.pem dest=~/centos_key.pem" overcloud |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment