留神:运行shell,应用"source xx.sh or . xx.sh",不要应用"bash xx.sh"
set environment variablesecho "#Add by Ly">>/etc/profileecho "export CONTROLLER_IP=172.36.214.11">>/etc/profileecho "export CTRL_HOST_NAME=stein-ctrl">>/etc/profileecho "export ALL_PASS=123456">>/etc/profilesource /etc/profileB_setup_base_env.shset -e -xyum install -y net-toolsyum install -y expectyum install -y tcpdumpyum install -y python-pipyum install -y treeecho "$CONTROLLER_IP $CTRL_HOST_NAME" >>/etc/hostssystemctl stop firewalldsystemctl disable firewalldsleep 2cp /etc/selinux/config /etc/selinux/config.baksed -i "/SELINUX=enforcing/cSELINUX=disabled" /etc/selinux/configsetenforce 0cp /etc/chrony.conf /etc/chrony.conf.baksed -i "/server 0.centos.pool.ntp.org iburst/cserver 10.165.7.181 iburst" /etc/chrony.confsed -i "/centos.pool.ntp.org/d" /etc/chrony.confsystemctl enable chronydsystemctl restart chronydsystemctl status chronydsleep 2chronyc sourcestimedatectl set-timezone Asia/Shanghaisleep 5#by your diyC_setup_base_soft_about_ctrl_stein.shset -e -xecho "The time now is : $CURDATE"sleep 3yum install centos-release-openstack-stein -yyum install python-openstackclient -yyum install openstack-selinux -yyum install -y mariadbyum install -y mariadb-serveryum install -y python2-PyMySQLtouch /etc/my.cnf.d/openstack.cnfecho "[mysqld]" >>/etc/my.cnf.d/openstack.cnfecho "bind-address = $CONTROLLER_IP" >>/etc/my.cnf.d/openstack.cnfecho "" >>/etc/my.cnf.d/openstack.cnfecho "default-storage-engine = innodb" >>/etc/my.cnf.d/openstack.cnfecho "innodb_file_per_table = on" >>/etc/my.cnf.d/openstack.cnfecho "max_connections = 4096" >>/etc/my.cnf.d/openstack.cnfecho "collation-server = utf8_general_ci" >>/etc/my.cnf.d/openstack.cnfecho "character-set-server = utf8" >>/etc/my.cnf.d/openstack.cnfsystemctl enable mariadb.servicesystemctl start mariadb.servicesystemctl status mariadb.servicesleep 2mysql_secure_installation <<EOFy$ALL_PASS$ALL_PASSyyyyEOF#Message queueyum install rabbitmq-server -ysystemctl enable rabbitmq-server.servicesystemctl start rabbitmq-server.servicesystemctl status rabbitmq-server.servicesleep 2rabbitmqctl add_user openstack $ALL_PASSrabbitmqctl set_permissions openstack ".*" ".*" ".*"#Memcachedyum install memcached python-memcached -ycp /etc/sysconfig/memcached /etc/sysconfig/memcached.baksed -i "/OPTIONS=\"-l 127.0.0.1,::1\"/cOPTIONS=\"-l 127.0.0.1,::1,$CONTROLLER_IP\"" /etc/sysconfig/memcachedsystemctl enable memcached.servicesystemctl start memcached.servicesystemctl status memcached.servicesleep 2#ETCDyum install etcd -ycp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.baksed -i '/ETCD_DATA_DIR/cETCD_DATA_DIR="/var/lib/etcd/default.etcd"' /etc/etcd/etcd.confsed -i "/ETCD_LISTEN_PEER_URLS/cETCD_LISTEN_PEER_URLS=\"http://$CONTROLLER_IP:2380\"" /etc/etcd/etcd.confsed -i "/ETCD_LISTEN_CLIENT_URLS/cETCD_LISTEN_CLIENT_URLS=\"http://$CONTROLLER_IP:2379\"" /etc/etcd/etcd.confsed -i "/ETCD_NAME/cETCD_NAME=\"$CON_HOST_NAME\"" /etc/etcd/etcd.confsed -i "/ETCD_INITIAL_ADVERTISE_PEER_URLS/cETCD_INITIAL_ADVERTISE_PEER_URLS=\"http://$CONTROLLER_IP:2380\"" /etc/etcd/etcd.confsed -i "/ETCD_ADVERTISE_CLIENT_URLS/cETCD_ADVERTISE_CLIENT_URLS=\"http://$CONTROLLER_IP:2379\"" /etc/etcd/etcd.confsed -i "/ETCD_INITIAL_CLUSTER=/cETCD_INITIAL_CLUSTER=\"$CON_HOST_NAME=http://$CONTROLLER_IP:2380\"" /etc/etcd/etcd.confsed -i '/ETCD_INITIAL_CLUSTER_TOKEN/cETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"' /etc/etcd/etcd.confsed -i '/ETCD_INITIAL_CLUSTER_STATE/cETCD_INITIAL_CLUSTER_STATE="new"' /etc/etcd/etcd.confsystemctl enable etcdsystemctl start etcdsystemctl status etcdsleep 2D_setup_keystone_about_ctrl_stein.shset -e -xyum install openstack-keystone -yyum install httpd -yyum install mod_wsgi -ymysql -N -uroot -p$ALL_PASS<<EOFDROP DATABASE if exists keystone;CREATE DATABASE if not exists keystone;GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY '$ALL_PASS';GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY '$ALL_PASS';EOF#yum install openstack-keystone -y#yum install httpd -y#yum install mod_wsgi -ycp /etc/keystone/keystone.conf /etc/keystone/keystone.conf.bak#[database]sed -i "/#connection = <None>/aconnection = mysql+pymysql://keystone:$ALL_PASS@$CONTROLLER_IP/keystone" /etc/keystone/keystone.conf#[token]sed -i '/provider =/aprovider = fernet' /etc/keystone/keystone.conf#Populate the Identity service databasesu -s /bin/sh -c "keystone-manage db_sync" keystonekeystone-manage fernet_setup --keystone-user keystone --keystone-group keystonekeystone-manage credential_setup --keystone-user keystone --keystone-group keystone#keystone-manage bootstrap --bootstrap-password $ALL_PASS \ --bootstrap-admin-url http://$CONTROLLER_IP:5000/v3/ \ --bootstrap-internal-url http://$CONTROLLER_IP:5000/v3/ \ --bootstrap-public-url http://$CONTROLLER_IP:5000/v3/ \ --bootstrap-region-id RegionOne#ServerNamesed -i "/#ServerName/aServerName $CONTROLLER_IP" /etc/httpd/conf/httpd.conf#Creating a soft linkln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/systemctl enable httpd.servicesystemctl start httpd.servicesystemctl status httpd.service#Configure the administrative accountexport OS_USERNAME=adminexport OS_PASSWORD=$ALL_PASSexport OS_PROJECT_NAME=adminexport OS_USER_DOMAIN_NAME=Defaultexport OS_PROJECT_DOMAIN_NAME=Defaultexport OS_AUTH_URL=http://$CONTROLLER_IP:5000/v3export OS_IDENTITY_API_VERSION=3#Create a domain, projects, users, and rolesopenstack domain create --description "An Example Domain" exampleopenstack project create --domain default --description "Service Project" serviceopenstack project create --domain default --description "Demo Project" myproject/usr/bin/expect << EOFset timeout 15spawn openstack user create --domain default --password-prompt myuserexpect "User*"send "$ALL_PASS\r"expect "Repeat *"send "$ALL_PASS\r"expect eofEOFopenstack role create myroleopenstack role add --project myproject --user myuser myroleunset OS_AUTH_URL OS_PASSWORD/usr/bin/expect << EOFset timeout 15spawn openstack --os-auth-url http://$CONTROLLER_IP:5000/v3 \ --os-project-domain-name Default --os-user-domain-name Default \ --os-project-name admin --os-username admin token issueexpect "*Password*"send "$ALL_PASS\r"expect eofEOF/usr/bin/expect << EOFset timeout 15spawn openstack --os-auth-url http://controller:5000/v3 \ --os-project-domain-name Default --os-user-domain-name Default \ --os-project-name myproject --os-username myuser token issueexpect "*Password*"send "$ALL_PASS\r"expect eofEOF#Creating admin-openrctouch /root/admin-openrcecho "export OS_PROJECT_DOMAIN_NAME=Default" >/root/admin-openrcecho "export OS_USER_DOMAIN_NAME=Default" >>/root/admin-openrcecho "export OS_PROJECT_NAME=admin" >>/root/admin-openrcecho "export OS_USERNAME=admin" >>/root/admin-openrcecho "export OS_PASSWORD=$ALL_PASS" >>/root/admin-openrcecho "export OS_AUTH_URL=http://$CONTROLLER_IP:5000/v3" >>/root/admin-openrcecho "export OS_IDENTITY_API_VERSION=3" >>/root/admin-openrcecho "export OS_IMAGE_API_VERSION=2" >>/root/admin-openrc#Creating demo-openrctouch /root/demo-openrcecho "export OS_PROJECT_DOMAIN_NAME=Default" >/root/demo-openrcecho "export OS_USER_DOMAIN_NAME=Default" >>/root/demo-openrcecho "export OS_PROJECT_NAME=myproject" >>/root/demo-openrcecho "export OS_USERNAME=myuser" >>/root/demo-openrcecho "export OS_PASSWORD=$ALL_PASS" >>/root/demo-openrcecho "export OS_AUTH_URL=http://$CONTROLLER_IP:5000/v3" >>/root/demo-openrcecho "export OS_IDENTITY_API_VERSION=3" >>/root/demo-openrcecho "export OS_IMAGE_API_VERSION=2" >>/root/demo-openrcsource /root/admin-openrcopenstack token issuesleep 2E_setup_image_about_ctrl_stein.shset -e -x#Database operations: glancemysql -N -uroot -p$ALL_PASS<<EOFDROP DATABASE if exists glance;CREATE DATABASE if not exists glance;GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '$ALL_PASS';GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '$ALL_PASS';EOFsource /root/admin-openrc/usr/bin/expect << EOFset timeout 15spawn openstack user create --domain default --password-prompt glanceexpect "User*"send "$ALL_PASS\r"expect "Repeat*"send "$ALL_PASS\r"expect eofEOFopenstack role add --project service --user glance adminopenstack service create --name glance --description "OpenStack Image" imageopenstack endpoint create --region RegionOne image public http://$CONTROLLER_IP:9292openstack endpoint create --region RegionOne image internal http://$CONTROLLER_IP:9292openstack endpoint create --region RegionOne image admin http://$CONTROLLER_IP:9292yum install openstack-glance -ycp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak#[database]sed -i "/#connection =/aconnection = mysql+pymysql://glance:$ALL_PASS@$CONTROLLER_IP/glance" /etc/glance/glance-api.conf#[keystone_authtoken]sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/glance/glance-api.confsed -i "/\[keystone_authtoken]$/ausername = glance" /etc/glance/glance-api.confsed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/glance/glance-api.confsed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/glance/glance-api.confsed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/glance/glance-api.confsed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/glance/glance-api.confsed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/glance/glance-api.confsed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/glance/glance-api.confsed -i "/\[keystone_authtoken]$/awww_authenticate_uri = http://$CONTROLLER_IP:5000" /etc/glance/glance-api.conf#[paste_deploy]sed -i "/flavor = keystone/cflavor = keystone" /etc/glance/glance-api.conf#[glance_store]sed -i "/\[glance_store]$/afilesystem_store_datadir = /var/lib/glance/images/" /etc/glance/glance-api.confsed -i "/\[glance_store]$/adefault_store = file" /etc/glance/glance-api.confsed -i "/\[glance_store]$/astores = file,http" /etc/glance/glance-api.conf#备份glance-registry.confcp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak#[database]sed -i "/#connection = <None>/aconnection = mysql+pymysql://glance:$ALL_PASS@$CONTROLLER_IP/glance" /etc/glance/glance-registry.conf#[keystone_authtoken]sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/glance/glance-registry.confsed -i "/\[keystone_authtoken]$/ausername = glance" /etc/glance/glance-registry.confsed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/glance/glance-registry.confsed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/glance/glance-registry.confsed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/glance/glance-registry.confsed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/glance/glance-registry.confsed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/glance/glance-registry.confsed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/glance/glance-registry.confsed -i "/\[keystone_authtoken]$/awww_authenticate_uri = http://$CONTROLLER_IP:5000" /etc/glance/glance-registry.conf#[paste_deploy]sed -i "/flavor = keystone/cflavor = keystone" /etc/glance/glance-registry.conf#Populate the Image service databasesu -s /bin/sh -c "glance-manage db_sync" glancesystemctl enable openstack-glance-api.service openstack-glance-registry.servicesystemctl start openstack-glance-api.service openstack-glance-registry.serviceF_setup_placement_about_ctrl_stein.shset -x -e#mysql -N -uroot -p$ALL_PASS<<EOFCREATE DATABASE placement;GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY '$ALL_PASS';GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY '$ALL_PASS';EOFsource /root/admin-openrc/usr/bin/expect << EOFset timeout 15spawn openstack user create --domain default --password-prompt placementexpect "User*"send "$ALL_PASS\r"expect "Repeat*"send "$ALL_PASS\r"expect eofEOFopenstack role add --project service --user placement adminopenstack service create --name placement --description "Placement API" placementopenstack endpoint create --region RegionOne placement public http://$CONTROLLER_IP:8778openstack endpoint create --region RegionOne placement internal http://$CONTROLLER_IP:8778openstack endpoint create --region RegionOne placement admin http://$CONTROLLER_IP:8778yum install openstack-placement-api -y#cp /etc/placement/placement.conf /etc/placement/placement.conf.bak#[placement_database]sed -i "/\[placement_database]$/aconnection = mysql+pymysql://placement:$ALL_PASS@$CONTROLLER_IP/placement" /etc/placement/placement.conf#[api]sed -i "/\[api]$/aauth_strategy = keystone" /etc/placement/placement.conf#[keystone_authtoken]sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/placement/placement.confsed -i "/\[keystone_authtoken]$/ausername = placement" /etc/placement/placement.confsed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/placement/placement.confsed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/placement/placement.confsed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/placement/placement.confsed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/placement/placement.confsed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/placement/placement.confsed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000/v3" /etc/placement/placement.confsu -s /bin/sh -c "placement-manage db sync" placementsystemctl restart httpd#verify installationsource /root/admin-openrcplacement-status upgrade check#install osc-placementmkdir /root/.piptouch /root/.pip/pip.confecho "[global]" >/root/.pip/pip.confecho "index-url=http://10.153.3.130/pypi/web/simple" >>/root/.pip/pip.confecho "" >>/root/.pip/pip.confecho "[install]" >>/root/.pip/pip.confecho "trusted-host=10.153.3.130" >>/root/.pip/pip.confpip install osc-placementsed -i "/<\/VirtualHost>/i\ \ <Directory \/usr\/bin>" /etc/httpd/conf.d/00-placement-api.confsed -i "/<\/VirtualHost>/i\ \ \ \ <IfVersion >= 2.4>" /etc/httpd/conf.d/00-placement-api.confsed -i "/<\/VirtualHost>/i\ \ \ \ \ \ \ \ Require all granted" /etc/httpd/conf.d/00-placement-api.confsed -i "/<\/VirtualHost>/i\ \ \ \ <\/IfVersion>" /etc/httpd/conf.d/00-placement-api.confsed -i "/<\/VirtualHost>/i\ \ \ \ <IfVersion < 2.4>" /etc/httpd/conf.d/00-placement-api.confsed -i "/<\/VirtualHost>/i\ \ \ \ \ \ \ \ Order allow,deny" /etc/httpd/conf.d/00-placement-api.confsed -i "/<\/VirtualHost>/i\ \ \ \ \ \ \ \ Allow from all" /etc/httpd/conf.d/00-placement-api.confsed -i "/<\/VirtualHost>/i\ \ \ \ <\/IfVersion>" /etc/httpd/conf.d/00-placement-api.confsed -i "/<\/VirtualHost>/i\ \ <\/Directory>" /etc/httpd/conf.d/00-placement-api.confsystemctl restart httpdsystemctl status httpdopenstack --os-placement-api-version 1.2 resource class list --sort-column nameopenstack --os-placement-api-version 1.6 trait list --sort-column nameG_setup_nova_about_ctrl_stein.shset -x -e#mysql -N -uroot -p$ALL_PASS<<EOFDROP DATABASE if exists nova_api;CREATE DATABASE if not exists nova_api;DROP DATABASE if exists nova;CREATE DATABASE if not exists nova;DROP DATABASE if exists nova_cell0;CREATE DATABASE if not exists nova_cell0;GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY '$ALL_PASS';GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY '$ALL_PASS';GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY '$ALL_PASS';GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY '$ALL_PASS';GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY '$ALL_PASS';GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY '$ALL_PASS';EOFsource /root/admin-openrc/usr/bin/expect << EOFset timeout 15spawn openstack user create --domain default --password-prompt novaexpect "User*"send "$ALL_PASS\r"expect "Repeat*"send "$ALL_PASS\r"expect eofEOFopenstack role add --project service --user nova adminopenstack service create --name nova --description "OpenStack Compute" computeopenstack endpoint create --region RegionOne compute public http://$CONTROLLER_IP:8774/v2.1openstack endpoint create --region RegionOne compute internal http://$CONTROLLER_IP:8774/v2.1openstack endpoint create --region RegionOne compute admin http://$CONTROLLER_IP:8774/v2.1yum install -y openstack-nova-apiyum install -y openstack-nova-conductoryum install -y openstack-nova-novncproxyyum install -y openstack-nova-schedulercp /etc/nova/nova.conf /etc/nova/nova.conf.bak#[DEFAULT]sed -i "/\[DEFAULT]$/afirewall_driver = nova.virt.firewall.NoopFirewallDriver" /etc/nova/nova.confsed -i "/\[DEFAULT]$/ause_neutron = True" /etc/nova/nova.confsed -i "/\[DEFAULT]$/amy_ip = $CONTROLLER_IP" /etc/nova/nova.confsed -i "/\[DEFAULT]$/atransport_url = rabbit://openstack:$ALL_PASS@$CONTROLLER_IP" /etc/nova/nova.confsed -i "/\[DEFAULT]$/aenabled_apis = osapi_compute,metadata" /etc/nova/nova.conf#[api_database]sed -i "/\[api_database]$/aconnection = mysql+pymysql://nova:$ALL_PASS@$CONTROLLER_IP/nova_api" /etc/nova/nova.conf#[database]sed -i "/\[database]$/aconnection = mysql+pymysql://nova:$ALL_PASS@$CONTROLLER_IP/nova" /etc/nova/nova.conf#[api]sed -i "/\[api]$/aauth_strategy = keystone" /etc/nova/nova.conf#[keystone_authtoken]sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/nova/nova.confsed -i "/\[keystone_authtoken]$/ausername = nova" /etc/nova/nova.confsed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/nova/nova.confsed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/nova/nova.confsed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/nova/nova.confsed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/nova/nova.confsed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/nova/nova.confsed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/nova/nova.conf#[vnc]sed -i "/\[vnc]$/aserver_proxyclient_address = \$my_ip" /etc/nova/nova.confsed -i "/\[vnc]$/aserver_listen = \$my_ip" /etc/nova/nova.confsed -i "/\[vnc]$/aenabled = true" /etc/nova/nova.conf#[glance]sed -i "/\[glance]$/aapi_servers = http://$CONTROLLER_IP:9292" /etc/nova/nova.conf#[oslo_concurrency]sed -i "/\[oslo_concurrency]$/alock_path = /var/lib/nova/tmp" /etc/nova/nova.conf#[placement]sed -i "/\[placement]$/apassword = $ALL_PASS" /etc/nova/nova.confsed -i "/\[placement]$/ausername = placement" /etc/nova/nova.confsed -i "/\[placement]$/aauth_url = http://$CONTROLLER_IP:5000/v3" /etc/nova/nova.confsed -i "/\[placement]$/auser_domain_name = Default" /etc/nova/nova.confsed -i "/\[placement]$/aauth_type = password" /etc/nova/nova.confsed -i "/\[placement]$/aproject_name = service" /etc/nova/nova.confsed -i "/\[placement]$/aproject_domain_name = Default" /etc/nova/nova.confsed -i "/\[placement]$/aos_region_name = RegionOne" /etc/nova/nova.confsu -s /bin/sh -c "nova-manage api_db sync" novasu -s /bin/sh -c "nova-manage cell_v2 map_cell0" novasu -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" novasu -s /bin/sh -c "nova-manage db sync" novasu -s /bin/sh -c "nova-manage cell_v2 list_cells" novasystemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.servicesystemctl start openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.servicesleep 3#Verify operationsource /root/admin-openrcopenstack compute service listsleep 1openstack catalog listsleep 1openstack image listsleep 1nova-status upgrade checksleep 4H_setup_neutron_about_ctrl_stein.shset -e -x#mysql -N -uroot -p$ALL_PASS<<EOFDROP DATABASE if exists neutron;CREATE DATABASE if not exists neutron;GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY '$ALL_PASS';GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY '$ALL_PASS';EOFsource /root/admin-openrc/usr/bin/expect << EOFspawn openstack user create --domain default --password-prompt neutronexpect "User*"send "$ALL_PASS\r"expect "Repeat*"send "$ALL_PASS\r"expect eofEOFopenstack role add --project service --user neutron adminopenstack service create --name neutron --description "OpenStack Networking" networkopenstack endpoint create --region RegionOne network public http://$CONTROLLER_IP:9696openstack endpoint create --region RegionOne network internal http://$CONTROLLER_IP:9696openstack endpoint create --region RegionOne network admin http://$CONTROLLER_IP:9696yum install -y openstack-neutronyum install -y openstack-neutron-ml2yum install -y openstack-neutron-openvswitchyum install -y ebtables#/etc/neutron/neutron.confcp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak#[database]sed -i "/\[database]$/aconnection = mysql+pymysql://neutron:$ALL_PASS@$CONTROLLER_IP/neutron" /etc/neutron/neutron.conf#[DEFAULT]sed -i "/\[DEFAULT]$/anotify_nova_on_port_data_changes = true" /etc/neutron/neutron.confsed -i "/\[DEFAULT]$/anotify_nova_on_port_status_changes = true" /etc/neutron/neutron.confsed -i "/\[DEFAULT]$/aauth_strategy = keystone" /etc/neutron/neutron.confsed -i "/\[DEFAULT]$/atransport_url = rabbit://openstack:$ALL_PASS@$CONTROLLER_IP" /etc/neutron/neutron.confsed -i "/\[DEFAULT]$/aallow_overlapping_ips = true" /etc/neutron/neutron.confsed -i "/\[DEFAULT]$/aservice_plugins = router" /etc/neutron/neutron.confsed -i "/\[DEFAULT]$/acore_plugin = ml2" /etc/neutron/neutron.conf#[keystone_authtoken]sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/neutron/neutron.confsed -i "/\[keystone_authtoken]$/ausername = neutron" /etc/neutron/neutron.confsed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/neutron/neutron.confsed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/neutron/neutron.confsed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/neutron/neutron.confsed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/neutron/neutron.confsed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/neutron/neutron.confsed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/neutron/neutron.confsed -i "/\[keystone_authtoken]$/awww_authenticate_uri = http://$CONTROLLER_IP:5000" /etc/neutron/neutron.conf#[nova]sed -i "/\[nova]$/apassword = $ALL_PASS" /etc/neutron/neutron.confsed -i "/\[nova]$/ausername = nova" /etc/neutron/neutron.confsed -i "/\[nova]$/aproject_name = service" /etc/neutron/neutron.confsed -i "/\[nova]$/aregion_name = RegionOne" /etc/neutron/neutron.confsed -i "/\[nova]$/auser_domain_name = Default" /etc/neutron/neutron.confsed -i "/\[nova]$/aproject_domain_name = Default" /etc/neutron/neutron.confsed -i "/\[nova]$/aauth_type = password" /etc/neutron/neutron.confsed -i "/\[nova]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/neutron/neutron.conf#[oslo_concurrency]sed -i "/\[oslo_concurrency]$/alock_path = /var/lib/neutron/tmp" /etc/neutron/neutron.confcp /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini.bak#[ml2]sed -i "/\[ml2]$/aextension_drivers = port_security" /etc/neutron/plugins/ml2/ml2_conf.inised -i "/\[ml2]$/amechanism_drivers = openvswitch,l2population" /etc/neutron/plugins/ml2/ml2_conf.inised -i "/\[ml2]$/atenant_network_types = vxlan,vlan" /etc/neutron/plugins/ml2/ml2_conf.inised -i "/\[ml2]$/atype_drivers = flat,vlan,vxlan" /etc/neutron/plugins/ml2/ml2_conf.ini#[ml2_type_flat]sed -i "/\[ml2_type_flat]$/aflat_networks = provider" /etc/neutron/plugins/ml2/ml2_conf.ini#[ml2_type_vlan]sed -i "/\[ml2_type_vlan]$/anetwork_vlan_ranges = physicnet:1000:2000" /etc/neutron/plugins/ml2/ml2_conf.ini#[ml2_type_vxlan]sed -i "/\[ml2_type_vxlan]$/avni_ranges = 30000:31000" /etc/neutron/plugins/ml2/ml2_conf.ini#[securitygroup]sed -i "/\[securitygroup]$/aenable_ipset = true" /etc/neutron/plugins/ml2/ml2_conf.ini#/etc/neutron/plugins/ml2/openvswitch_agent.inicp /etc/neutron/plugins/ml2/openvswitch_agent.ini /etc/neutron/plugins/ml2/openvswitch_agent.ini.bak#[agent]#sed -i "/tunnel_types = /atunnel_types = vxlan" /etc/neutron/plugins/ml2/openvswitch_agent.ini#[ovs]#sed -i "/\[ovs]$/alocal_ip = 10.214.1.2" /etc/neutron/plugins/ml2/openvswitch_agent.ini#sed -i "/\[ovs]$/atun_peer_patch_port = patch-int" /etc/neutron/plugins/ml2/openvswitch_agent.ini#sed -i "/\[ovs]$/aint_peer_patch_port = patch-tun" /etc/neutron/plugins/ml2/openvswitch_agent.ini#sed -i "/\[ovs]$/atunnel_bridge = br-tun" /etc/neutron/plugins/ml2/openvswitch_agent.ini#[securitygroup]sed -i "/\[securitygroup]$/aenable_security_group = true" /etc/neutron/plugins/ml2/openvswitch_agent.inised -i "/\[securitygroup]$/afirewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver" /etc/neutron/plugins/ml2/openvswitch_agent.inicp /etc/neutron/l3_agent.ini /etc/neutron/l3_agent.ini.baksed -i "/\[DEFAULT]$/ainterface_driver = neutron.agent.linux.interface.OVSInterfaceDriver" /etc/neutron/l3_agent.inicp /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.baksed -i "/\[DEFAULT]$/aenable_isolated_metadata = true" /etc/neutron/l3_agent.inised -i "/\[DEFAULT]$/adhcp_driver = neutron.agent.linux.dhcp.Dnsmasq" /etc/neutron/dhcp_agent.inised -i "/\[DEFAULT]$/ainterface_driver = neutron.agent.linux.interface.OVSInterfaceDriver" /etc/neutron/dhcp_agent.inised -i "/force_metadata = /aforce_metadata = true" /etc/neutron/dhcp_agent.inicp /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini.baksed -i "/\[DEFAULT]$/ametadata_proxy_shared_secret = $ALL_PASS" /etc/neutron/metadata_agent.inised -i "/\[DEFAULT]$/anova_metadata_host = $CONTROLLER_IP" /etc/neutron/metadata_agent.ini#Edit /etc/nova/nova.conf file and perform the fllowing actionssed -i "/\[neutron]$/ametadata_proxy_shared_secret = $ALL_PASS" /etc/nova/nova.confsed -i "/\[neutron]$/aservice_metadata_proxy = true" /etc/nova/nova.confsed -i "/\[neutron]$/apassword = $ALL_PASS" /etc/nova/nova.confsed -i "/\[neutron]$/ausername = neutron" /etc/nova/nova.confsed -i "/\[neutron]$/aproject_name = service" /etc/nova/nova.confsed -i "/\[neutron]$/aregion_name = RegionOne" /etc/nova/nova.confsed -i "/\[neutron]$/auser_domain_name = Default" /etc/nova/nova.confsed -i "/\[neutron]$/aproject_domain_name = Default" /etc/nova/nova.confsed -i "/\[neutron]$/aauth_type = password" /etc/nova/nova.confsed -i "/\[neutron]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/nova/nova.confsed -i "/\[neutron]$/aurl = http://$CONTROLLER_IP:9696" /etc/nova/nova.confln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.inisu -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutronsystemctl restart openstack-nova-api.servicesystemctl enable neutron-server.service \ neutron-openvswitch-agent.service neutron-dhcp-agent.service \ neutron-metadata-agent.service neutron-l3-agent.servicesystemctl start neutron-server.service \ neutron-openvswitch-agent.service neutron-dhcp-agent.service \ neutron-metadata-agent.service neutron-l3-agent.servicesleep 4I_setup_dashboard_about_ctrl_stein.shset -x -eyum install openstack-dashboard -y##/etc/openstack-dashboard/local_settingscp /etc/openstack-dashboard/local_settings /etc/openstack-dashboard/local_settings.baksed -i "/OPENSTACK_HOST = /cOPENSTACK_HOST = \"$CONTROLLER_IP\"" /etc/openstack-dashboard/local_settingssed -i "/ALLOWED_HOSTS = /cALLOWED_HOSTS = ['*']" /etc/openstack-dashboard/local_settings#SESSION_ENGINE = 'django.contrib.sessions.backends.cache' #CACHESsed -i "/^CACHES =/iSESSION_ENGINE = 'django.contrib.sessions.backends.cache'" /etc/openstack-dashboard/local_settingssed -i "/^[ \t]*'BACKEND'/a\\ \t'LOCATION': '$CONTROLLER_IP:11211'," /etc/openstack-dashboard/local_settingssed -i 's/django.core.cache.backends.locmem.LocMemCache/django.core.cache.backends.memcached.MemcachedCache/g' /etc/openstack-dashboard/local_settings#sed -i "/OPENSTACK_KEYSTONE_URL/cOPENSTACK_KEYSTONE_URL = \"http://%s:5000/v3\" % OPENSTACK_HOST" /etc/openstack-dashboard/local_settings#sed -i "/OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT/cOPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True" /etc/openstack-dashboard/local_settings#OPENSTACK_API_VERSIONS = {# "identity": 3,# "image": 2,# "volume": 2,#}sed -i "s/#OPENSTACK_API_VERSIONS/OPENSTACK_API_VERSIONS/g" /etc/openstack-dashboard/local_settingssed -i "/# \"identity\": 3,/c\\ \"identity\": 3," /etc/openstack-dashboard/local_settingssed -i "/# \"image\": 2,/c\\ \"image\": 2," /etc/openstack-dashboard/local_settingssed -i "/# \"volume\": 2,/c\\ \"volume\": 2," /etc/openstack-dashboard/local_settingssed -i "/# \"compute\": 2,/a}" /etc/openstack-dashboard/local_settings#sed -i "/#OPENSTACK_KEYSTONE_DEFAULT_DOMAIN/cOPENSTACK_KEYSTONE_DEFAULT_DOMAIN = \"Default\"" /etc/openstack-dashboard/local_settingssed -i "/OPENSTACK_KEYSTONE_DEFAULT_ROLE/cOPENSTACK_KEYSTONE_DEFAULT_ROLE = \"user\"" /etc/openstack-dashboard/local_settings#OPENSTACK_NEUTRON_NETWORK = {# ...# 'enable_router': False,# 'enable_quotas': False,# 'enable_distributed_router': False,# 'enable_ha_router': False,# 'enable_lb': False,# 'enable_firewall': False,# 'enable_vpn': False,# 'enable_fip_topology_check': False,#}##/etc/httpd/conf.d/openstack-dashboard.conf#cp /etc/httpd/conf.d/openstack-dashboard.conf /etc/httpd/conf.d/openstack-dashboard.conf.baksed -i "/WSGIScriptAlias/iWSGIApplicationGroup %{GLOBAL}" /etc/httpd/conf.d/openstack-dashboard.conf#systemctl restart httpd.service memcached.servicesystemctl status httpd memcachedsleep 3#Fwaasyum install openstack-neutron-fwaas -yneutron-db-manage --subproject neutron-fwaas upgrade head#lbaasv2yum install openstack-neutron-lbaas -yneutron-db-manage --subproject neutron-lbaas upgrade head#vpnaasyum install openstack-neutron-vpnaas -yneutron-db-manage --subproject neutron-vpnaas upgrade head