
Bear Metal
In this post I will document the steps that I am using to create a fully virtualized OSP 10 environment in my lab. The undercloud node is a VM, as well as the overcloud nodes. We will configure libvirt so that ironic has the ability to boot and shutdown the VMs on the underlying hypervisor via Ironic.
Add the stack user on your hypervisor. In this case my hypervisor’s hostname is virt01, however we will refer to it as hypervisor for clarity.
[simterm]
hypervisor# useradd stack
hypervisor# echo “password” | passwd stack –stdin
[/simterm]
Modify polkit to allow stack user to manage libvirt.
[simterm]hypervisor # cat << EOF > /etc/polkit-1/localauthority/50-local.d/50-libvirt-user-stack.pkla
[libvirt Management Access]
Identity=unix-user:stack
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes
EOF
[/simterm]
Now attempt to libvirt as stack via a remote session. Here we are just connecting back to the localhost, virt01. In the example below, 10.1.99.112 is the ip of the hypervisor. The undercloud has an ip of 10.1.99.10
[simterm]undercloud# virsh –connect qemu+ssh://stack@10.1.99.112/system list –all
[/simterm]
Now ssh as stack to your undercloud vm
Copy stack’s public key to your hypervisor (virt01 in this case). In the command below you will replace the ip address shown with the ip that your undercloud vm will use to connect to libvirt on the hypervisor
[simterm]undercloud# ssh-copy-id -i ~/.ssh/id_rsa.pub stack@10.1.99.112
[/simterm]
Now we need to create a few Virtual Machines. Specifically I am building an environment with 5 virtual machines to run virtualized Red Hat Openstack 13. My overcloud will consist of 2 computes and three controller nodes
I will use the command below to create 5 qcows.
[simterm]hypervisor# cd /var/lib/libvirt/images/
hypervisor# for i in {1..5}; do qemu-img create -f qcow2 \
-o preallocation=metadata overcloud-node$i.qcow2 60G; done
Formatting ‘overcloud-node1.qcow2′, fmt=qcow2 size=64424509440 encryption=off cluster_size=65536 preallocation=’metadata’ lazy_refcounts=off
Formatting ‘overcloud-node2.qcow2′, fmt=qcow2 size=64424509440 encryption=off cluster_size=65536 preallocation=’metadata’ lazy_refcounts=off
Formatting ‘overcloud-node3.qcow2′, fmt=qcow2 size=64424509440 encryption=off cluster_size=65536 preallocation=’metadata’ lazy_refcounts=off
Formatting ‘overcloud-node4.qcow2′, fmt=qcow2 size=64424509440 encryption=off cluster_size=65536 preallocation=’metadata’ lazy_refcounts=off
Formatting ‘overcloud-node5.qcow2′, fmt=qcow2 size=64424509440 encryption=off cluster_size=65536 preallocation=’metadata’ lazy_refcounts=off
[/simterm]
The command below will create 5 xml files and use those to spawn my 5 VMs.
[simterm] hypervisor# for i in {1..5}; do \
virt-install –ram 16384 –vcpus 4 –os-variant rhel7 \
–disk path=/var/lib/libvirt/images/overcloud-node$i.qcow2,device=disk,bus=virtio,format=qcow2 \
–noautoconsole –vnc –network network:provisioning –network bridge:br99 \
–network network:default –name overcloud-node$i \
–dry-run –print-xml > /tmp/overcloud-node$i.xml; \
hypervisor# virsh define –file /tmp/overcloud-node$i.xml; done
[/simterm]
You should end up with the following virtual machines
[simterm]hypervisor# virsh list –all
Id Name State
—————————————————-
1 undercloud running
– overcloud-node1 shut off
– overcloud-node2 shut off
– overcloud-node3 shut off
– overcloud-node4 shut off
– overcloud-node5 shut off
[/simterm]
Back on the undercloud we use the command below to grab the provisioning network mac address from each virtual machine running on the hypervisor. We could run this command locally on the hypervisor, but since we need the mac addresses for ironic on the undercloud, we will run it here.
[simterm]undercloud$ for i in {1..5}; do virsh -c qemu+ssh://stack@10.1.99.112/system domiflist overcloud-node$i | awk ‘$3 == “provisioning” {print $5}’; done> /tmp/nodes.txt
[/simterm]
Now we use our temp file above to populate the instackenv.json that we will import into ironic. See gist below
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
undercloud$ jq . << EOF > ~/instackenv.json | |
{ | |
"ssh-user": "stack", | |
"ssh-key": "$(cat ~/.ssh/id_rsa)", | |
"power_manager": "nova.virt.baremetal.virtual_power_driver.VirtualPowerManager", | |
"host-ip": "192.168.122.1", | |
"arch": "x86_64", | |
"nodes": [ | |
{ | |
"name": "overcloud-node1", | |
"pm_addr": "192.168.122.1", | |
"pm_password": "$(cat ~/.ssh/id_rsa)", | |
"pm_type": "pxe_ssh", | |
"mac": [ | |
"$(sed -n 1p /tmp/nodes.txt)" | |
], | |
"cpu": "4", | |
"memory": "8192", | |
"disk": "60", | |
"arch": "x86_64", | |
"pm_user": "stack" | |
}, | |
{ | |
"name": "overcloud-node2", | |
"pm_addr": "192.168.122.1", | |
"pm_password": "$(cat ~/.ssh/id_rsa)", | |
"pm_type": "pxe_ssh", | |
"mac": [ | |
"$(sed -n 2p /tmp/nodes.txt)" | |
], | |
"cpu": "4", | |
"memory": "8192", | |
"disk": "60", | |
"arch": "x86_64", | |
"pm_user": "stack" | |
}, | |
{ | |
"name": "overcloud-node3", | |
"pm_addr": "192.168.122.1", | |
"pm_password": "$(cat ~/.ssh/id_rsa)", | |
"pm_type": "pxe_ssh", | |
"mac": [ | |
"$(sed -n 3p /tmp/nodes.txt)" | |
], | |
"cpu": "4", | |
"memory": "8192", | |
"disk": "60", | |
"arch": "x86_64", | |
"pm_user": "stack" | |
}, | |
{ | |
"name": "overcloud-node4", | |
"pm_addr": "192.168.122.1", | |
"pm_password": "$(cat ~/.ssh/id_rsa)", | |
"pm_type": "pxe_ssh", | |
"mac": [ | |
"$(sed -n 4p /tmp/nodes.txt)" | |
], | |
"cpu": "4", | |
"memory": "8192", | |
"disk": "60", | |
"arch": "x86_64", | |
"pm_user": "stack" | |
}, | |
{ | |
"name": "overcloud-node5", | |
"pm_addr": "192.168.122.1", | |
"pm_password": "$(cat ~/.ssh/id_rsa)", | |
"pm_type": "pxe_ssh", | |
"mac": [ | |
"$(sed -n 5p /tmp/nodes.txt)" | |
], | |
"cpu": "4", | |
"memory": "8192", | |
"disk": "60", | |
"arch": "x86_64", | |
"pm_user": "stack" | |
} | |
] | |
} | |
EOF |
At this point we are ready to import our nodes via Ironic.
Note that I do not claim to be the original author of the steps documented above, rather I wanted to ensure that I could easily consume these steps in the future.
Also, I look forward to experimenting with the vbmc ironic driver and might stop using pxe_ssh altogether.