This article shows how to install OpenStack Juno on CentOS 7 with a couple of scripts. If you’ve manually installed OpenStack by following the official documentation, you know that there are many steps: adding repositories, installing services, modifying configuration files. I can take all day just to get the core services up and running. Tiring and tedious. After many test installations, I decided to write a few scripts to build the basic environment.
These scripts were built to deploy OpenStack on VMware virtual machines, but they should also work on physical machines. The scripts are basically a list of commands – no elaborate error checking. However, by keeping the scripts simple, they’re easier to read and understand.
The goal of the scripts is to deploy a single OpenStack controller, which runs the core controller services: mysql, rabbit, glance, nova, and cinder; and to deploy one or more compute nodes, which run nova-compute, nova-network, nova-metadata-api, and cinder-volume. These core services are enough to start deploying instances.
Note: this article uses the nova-network networking component which is simple and performs well. If you want to deploy the more complex neutron networking component, see my new article: OpenStack Juno Scripted Install with Neutron on CentOS 7.
The controller requires one network interface (NIC), connected to the management network. Compute nodes require two NICs, one connected to the management network, and the other connected to another subnet that we’ll use for OpenStack instances (virtual machines). The compute node also needs a second hard disk to be used for cinder (/dev/sdb). The resulting configuration will look something like this.
So to get started we need two CentOS 7 64 bit machines. The basic text-only installation is what we need. I won’t go into detail here. As stated above, the controller needs one NIC. The compute node needs two NICs and an extra hard disk for cinder.
Once these machines are built, we need to copy the scripts (shown below) to the machines, then we’ll customize the configuration and run the scripts.
Building the Controller
The first file is simply called config. This file will contain the specifics of the stack, and the IP configuration info for the node we are building.
Save this file on the controller (in your home directory) and give it the filename: config
Adjust the information accordingly. I’m using the IP address 192.168.1.237 for my controller. So both CONTROLLER_IP and THISHOST_IP are set to that address. I’ve also set the hostname, netmask, gateway, and DNS address accordingly. I’m also defining the admin token to be used in Keystone, the password to be used by the OpenStack services, and the password to be used by the OpenStack admin user.
This next script simply writes the IP information from the config file to the if-config file for the primary NIC. Note that the script assumes that the primary NIC has an interface index of 2 (the local loopback adapter is 1). If you’re building a VM, this assumption is probably correct. However, if your machine has multiple NICs, or you’re using aliases or VLANs, your interface indexes may be different. You should inspect the NICs that your system sees by listing /sys/class/net and looking at the ifindex of the NICs in your system, then adjust the script accordingly.
Save this file as ipconfig.sh and grant it execute permissions (chmod +x ipconfig.sh). Notice that if the system has a second NIC (ifindex = 3) then it will create a basic if-config file for that NIC, with no IP address. This won’t do anything on our controller (which has only one NIC), but it will be used when we build the compute node. When you run this script, the server will reboot and come up with the new IP address.
Now, we install and configure the OpenStack controller services.In the middle of this next script, the mysql_secure_installation routine will be called. You will be prompted for a password. The initial password is blank (just press enter). Then you can enter a new mysql root password of your choosing, and select the security defaults that you desire. Then the script will continue. Here’s the script:
That’s a lot of code, I know, but each section is fairly straightforward. Each section is commented to describe what it’s doing. Save the file as controller-node.sh, grant it execution rights (chmod +x controller-node.sh), and run the script like so:
Your controller should now be ready to go.
Building the Compute Node
Again, our compute node should have two NICs and two hard disks. The second hard disk will be used for the cinder-volumes LVM volume group. If you have a different hard disk configuration, you can modify the script to deploy the cinder-volumes volume group onto a different location.
As before, the first thing we need to do is modify the config file. In this case, the stack information remains the same as before, but we modify the IP address and hostname for this host as shown here.
Again, save this with the filename: config
Next run the ipconfig.sh script on the compute node. In this case, the if-config files for both NICs will be modified. The second NIC will not receive an IP address. Instead, OpenStack will create a virtual bridge and connect it to the second NIC. When Instances (VMs) are created, they will be connected to this bridge.
After the IP configuration is set and the system has been rebooted, we can run the script that installs the OpenStack compute node services.
Save this file as compute-node.sh and grant it execute permissions (chmod +x compute-node.sh). Then run it:
Notice that the script created a file called creds. Source this file before running any OpenStack command line utilities, as shown below.
Creating the VM Network
Finally, we need to create an OpenStack network object for the instances to connect to. In my case, I’m using the subnet 192.168.2.0/24. My router address on that subnet is 192.168.2.254.
Finally, reboot the compute node and you should be ready to deploy instances. Enjoy!