OpenStack is a highly configurable open source platform for creating and maintaining cloud infrastructure. It’s extremely configurable nature both makes it amazing and frustrating as ever since the command line documentation has about a hundred different flags with few examples on how to spin up a basic server.
This is the crash course to get your servers up and running.
Setup up CLI authentication
The example I am using is with the Cloud Provider Ramnode but most cloud server providers using OpenStack should have a similar authentication process.
Ramnode has pretty documentation for this already here: OpenStack SDK Tutorial – Knowledgebase – RamNode
Staying quick and to the point you’ll want to install the OpenStack client with:
sudo apt install python3-openstackclient
Then login to your Ramnode Cloud Control Panel and go to API Users at the bottom right of the screen press the “+” sign
Give the API user a name and generate a password (make sure to save this as it will be used later)
Once you finish adding the user you might notice that there is nothing in the API Users control panel section, this is a bug that you can fix by pressing the grid view button in the top right of the screen:
Now you should be able to see the API User you created:
Click the download button then select the region you wish to launch the servers in.
This will download an openrc file to your downloads folder. Copy this file onto your linux host if you are not already on one then make sure to run: chmod +x openrc
If you don’t you are going to keep getting the message that you entered the password for the file wrong (I learned this the hard way)
Now you can run the command: source openrc
It will prompt you for the password you created earlier in the Ramnode Cloud control panel, once you’ve entered that in you will be authenticated to use the OpenStack CLI. You can test this by running:
openstack flavor list
If you see multiple items listed you are properly authenticated.
Creating Servers with OpenStack CLI
At the basic level to create a server with OpenStack you need to know 4 things: flavor id, image id, security group name, and key name.
To find the flavor id that you need run the command: openstack flavor list
From here copy the desired flavor ID and save it.
Then find the image id with: openstack image list
Again, copy your desired OS distribution’s ID and save it.
The last 2 things, firewall and security group name we add from the Ramnode Cloud Control panel.
In the cloud panel navigate to the “Security groups” section and click the plus button in the bottom right corner. Select the desired region then give it a name, one which you will use with the OpenStack CLI.
After you have created this firewall make sure to add the inbound and outbound rules.
Now you can navigate to the SSH key section and click the plus button to add or generate a SSH key. If you already have a keypair generated make sure to put the PUBLIC key content in the key content section, you can also generate a keypair from the menu:
Now with this information you can launch a server from the CLI (substituting the id names with your own) with:
openstack server create \ --flavor aeb78066-fcae-4271-8cfa-a1bca7ef3b1f \ --image fcaa9649-193e-4561-a28a-647003e0357c \ --security-group test-firewall \ --key-name test-key-pair \ my-server-name
Scripting multiple server launches
This is a little script I wrote for launching multiple servers:
#!/bin/bash source openrc for host in $(cat host_names.txt) do openstack server create \ --flavor aeb78066-fcae-4271-8cfa-a1bca7ef3b1f \ --image fcaa9649-193e-4561-a28a-647003e0357c \ --security-group test-firewall \ --key-name test-key-pair\ $host sleep 10 done
This script requires you to make a text file called “host_names.txt” with your server names listed. I added the sleep 10 in there because without it I found server spawning would sometimes error out.