This post will describe how to set up Foreman and provision an OpenStack environment via PackStack. We demonstrate this through OpenStack installation on two Nodes. Foreman 1.8 is used to install the Host System on the Nodes and PackStack to provision OpenStack.
Installing Foreman
First thing we do is installing Foreman on the management host inside a VM and we use Vagrant to have the installation part of Foreman already automated in case of redeployment. The requirements include: Vagrant and VirtualBox installed, as well as having the “Ubuntu/Trusty64” box added to Vagrant.
Execute the “vagrant init” command and open the Vagrant file with a text editor of your choice. After the Vagrant file configuration, forward the port 443 to a port on the host and specify the private network; link the script that will be run after the Ubuntu installation.
config.vm.network "forwarded_port", guest: 443, host: 8080
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", inline: < "files/script.sh"
end
The script should automatically set the hostname as well as install the Foreman-installer. Make sure that it is placed at the location you point at in your Vagrant file.
#!/bin/bash
#Correcting the hostname
echo 127.0.0.1 localhost > /etc/hosts
echo 10.0.2.15 foreman18.loc.local foreman18 >> /etc/hosts
apt-get update
apt-get upgrade -y
#Download and Installation of Puppet:
apt-get -y install ca-certificates
wget https://apt.puppetlabs.com/puppetlabs-release-utopic.deb
sudo dpkg -i puppetlabs-release-utopic.deb
#Download and Installation of the Foreman-Installer to install Foreman:
echo "deb http://deb.theforeman.org/ trusty 1.8" > /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins 1.8" >> /etc/apt/sources.list.d/foreman.list
wget -q http://deb.theforeman.org/pubkey.gpg -O- | apt-key add -
apt-get update && apt-get -y install foreman-installer
reboot
exit 0;
After creating the script.sh file, bring the Vagrant box up and ssh into the machine.
One of the parameters to pass to the command that installs Foreman, is the Foreman Discovery Plugin that enables Foreman to do automatic bare-metal discovery of unknown nodes on the provisioning network.
~$ sudo foreman-installer --enable-foreman-plugin-discovery --foreman-plugin-discovery-install-images=true
Write down the login credentials and then reboot the system. After the reboot you should be able to access Foreman under this address: https://localhost:8080
Configuration of Foreman
Next step is the Provisioning Setup. Log into Foreman, then go to Infrastructure–> Provisioning Setup and fill in the needed Information. You should fix a gateway for the network otherwise you would get problems when provisioning the machines.
In our example we will use Foreman as DNS, DHCP, and GW. Our settings:
Name: prov-network Network address*: 192.168.33.0 Network mask*: 255.255.255.0 Gateway: 192.168.33.10 (foreman) Primary DNS: (foreman) IPAM: DHCP Boot mode DHCP
Submit and copy the displayed script that into the Terminal. After this step continue to the next window and select the Ubuntu Mirror under “Existing Medium” before submitting again. Now everything is done to provision the hosts.
Provisioning Hosts
The next task is to boot the hosts over the network (with PXE). Make sure that they are listed under hosts.
If the error message “ip already given” pops up during the provisioning process, you have to ACK it and under Network settings, press “Suggest new one”. Repeat this step for each host.
After the provision you need to change the name of the interfaces. It is important that all the interfaces are mapped the same way on all of the hosts.
For example:
controller-node:
eth0 --> private
eth1 --> public
compute:
eth0 --> private
The following commands need to be executed on each host.
First add to “/etc/default/grub” the :
sudo vi /etc/default/grub
net.ifnames=0
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos_somename-controller/root splash=quiet nofb crashkernel=auto rd.lvm.lv=centos_somename-controller/swap net.ifnames=0 rhgb quiet"
This line is needed to assign the same name to the network interfaces – a requirement from OpenStack.
Afterwards execute the following command and reboot the machine:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
When the machine has finished rebooting you need to add the following line to “/etc/udev/rules.d/70-persistent-net.rules”:
sudo vi /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b0:83:fe:5e:f1:ec", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
Remember that you have to do the steps above for each of the hosts.
Preparation of the Nodes for the OpenStack installation
We now prepare the Nodes for the next step, the OpenStack installation.
First, disable firewalld:
systemctl stop firewalld
systemctl disable firewalld
Than, set SELINUX to permissive:
setenforce 0
vim /etc/sysconfig/selinux
SELINUX=permissive
Afterwards, disable the Network Manager and migrate to “network” before rebooting the machines:
systemctl disable NetworkManager
systemctl stop NetworkManager
systemctl enable network
When the reboot has finished check if all the “ifcfg-*” files look sane under “/etc/sysconfig/network-scripts/”. If they are sane they will look similar to this:
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.56.53
NETMASK=255.255.255.0
DEVICE=enp0s8
Controller node interface configuration
Now we will configure the interface of the OpenStack controller node.
cat /etc/sysconfig/network-scripts/ifcfg-p4p2
# Generated by dracut initrd
NAME="p4p2"
NM_CONTROLLED=no
DEVICE="p4p2"
ONBOOT=yes
NETBOOT=yes
UUID="e5177752-e509-4d8c-b88d-a98ce263a06a"
BOOTPROTO=none
IPADDR=10.20.0.104
NETMASK=255.255.255.0
TYPE=Ethernet
Also set the gateway in “/etc/sysconfig/network”.
vim /etc/sysconfig/network
# Created by anaconda
GATEWAY=10.90.0.244
The next step is to install PackStack and let it create the OpenStack environment, by passing it a so called “answer file” you previously create. It is very important that you configure your own answer file as it is tightly coupled to the particular environment. The process may take you several re-runs of the answer file until you fully eliminate any error and finish the process successfully.
PackStack
To install PackStack execute the following commands:
sudo yum update -y
sudo yum install -y https://rdoproject.org/repos/rdo-release.rpm
sudo yum install -y openstack-packstack
Finally, to let PackStack set up the OpenStack environment, we pass it the “answer_file_name” file we created.
packstack --anwser-file=[answer_file_name]