Last week I had a failure. On Thursday, I was in Zurich, where we held the Ansible workshop. The first exercise was to deploy an LPAR on IBM Power. We thought it was a good exercise to start with Ansible. People click a button and become an LPAR five minutes later. The best experience and the best demonstration of what Ansible can do for you.
People clicked the button, and … They didn’t get their LPARs.
30 participants of the workshop simultaneously, plus some of my configuration errors, led to a lame HMC, which didn’t work anymore as it should have.
I thought I would run away from the workshop and would never come back to Zurich.
Heartfelt thanks to my colleagues Alexander Paul and Michael Fiebig, who found and fixed all problems.
Sometimes we are fixated on loud people and forget about those who simply do their jobs every day, regardless of what happens.
I would also like to thank Hermann Huber for the excellent organization of the workshop.
No, I don’t want to write too much about the workshop
The workshop is in the past.
What I want to write about is the delivery, which begins with the creation of an LPAR.
Yes, two years later, I decided to fulfill my promise and write how to create an LPAR on IBM Power using HMC and Ansible.
Maybe because it is easier to do today than it was two years ago.
But even though there are some prerequisites, today it is a single task.
Single task to rule them all
Here it is:
- name: Create AIX/Linux LPAR
ibm.power_hmc.powervm_lpar_instance:
hmc_host: "{{ hmc }}"
hmc_auth: "{{ hmc_auth }}"
system_name: "{{ lpar.system }}"
vm_name: "{{ lpar.name }}"
min_mem: 2048
mem: "{{ lpar.memory }}"
max_mem: "{{ lpar.memory * 2 }}"
min_proc_unit: 0.1
proc_unit: "{{ lpar.proc_units }}"
max_proc_unit: "{{ lpar.proc_units * 2 }}"
min_proc: 1
proc: "{{ lpar.vcpus }}"
max_proc: "{{ lpar.vcpus * 2 }}"
proc_mode: uncapped
volume_config:
- volume_name: "{{ lpar.root_hdisk }}"
vios_name: "{{ lpar.vios }}"
virt_network_config:
- network_name: "{{ lpar.network }}"
os_type: aix_linux
state: present
As you see, these are the exact parameters you usually enter in the HMC when you create an LPAR using the wizard. But a little bit differently named.
What are the prerequisites you talk about?
There is an obvious prerequisite - you must have ibm.power_hmc collection. Somewhere, where Ansible can find it.
The second prerequisite is not so obvious, but it is documented in the powervm_lpar_instance module’s documentation. You need the lxml Python package.
If you use Ansible Automation Platform or Linux, it is not a problem. In the first case, it is most probably already installed in your execution environment. If not, you can install it using pip3:
pip3 install lxml
or if you use Red Hat Enterprise Linux:
dnf -y install python3-lxml
You can add it as the first task in your playbook and be sure that the LPAR creation will work.
The last prerequisite is not mentioned anywhere, but it is self-evident.
You must have access to the HMC from your Ansible controller node.
We usually say that Ansible uses SSH, and you must open port 22 on your firewall to make it work.
In this particular case, the HMC collection uses REST API calls through port 443. It means that you must open port 443 between your Ansible controller node and your HMC.
Inventory
It is up to you to decide what you want to have in the inventory. As for me, the most usual way to start the task on localhost, which is my Ansible controller node.
You can put it in the inventory or simply use delegate_to at the end of the task:
delegate_to: localhost
Parameters
I defined many variables, but you can define even more if you wish.
First of all, we need to know which HMC we use and how we can authenticate there:
hmc: hmc1.power-devops.cloud
hmc_auth:
username: hscroot
password: P@ssw0rd
Of course, you must use a different user (not hscroot!), and the user must have privileges to create LPARs on the selected managed system.
All information about the future LPAR I packed into a dict called lpar:
lpar:
name: mytest
system: myE1180
memory: 8192
vcpus: 4
proc_units: 4.0
network: Network1
root_hdisk: hdisk60
vios: myvios1
Why is your root disk configuration so short?
First of all, I use VSCSI in this case. If you wish, you can use NPIV. It works too. Maybe I will write about it in the following newsletter.
Second, you don’t have to write each VIOS and disk. If you have a “normal" configuration where the disk is zoned to two VIOSes, the module makes some magic and finds the second VIOS without our help. It creates correct mappings on both VIOSes.
What I am missing here is the possibility to specify the connection device name on VIOS. By default, it is vtscsi with some number.
Support the Power DevOps Newsletter!
If you like reading technical articles about IBM Power, AIX, and Linux on IBM Power, consider upgrading to the paid tier to show your support. As a paid subscriber, you not only get regular posts, but you will get additional posts with the full code and further explanations, access to the whole archive of the blog, and take part in our monthly calls where you can ask your questions and propose topics for future newsletters. Be an active member of our community!
No, it is not everything about creating LPARs!
There is something that I don’t like in such playbooks.
They use hard-coded values.
I hard-coded the managed system name, the VIOS names, the disk name, and the network name.
It would be nice to detect all of these values automatically.
Of course, I’d like to test IBM i LPAR creation too. I can’t do it right now, but maybe I will have the opportunity to do it by next week. But you can try to do it in your environment. Or if you don’t work with IBM i (like me), create an AIX or Linux LPAR!
Have fun creating LPARs on IBM Power with Ansible!
Andrey
Hi, I am Andrey Klyachkin, IBM Champion and IBM AIX Community Advocate. This means I don’t work for IBM. Over the last twenty years, I have worked with many different IBM Power customers all over the world, both on-premise and in the cloud. I specialize in automating IBM Power infrastructures, making them even more robust and agile. I co-authored several IBM Redbooks and IBM Power certifications. I am an active Red Hat Certified Engineer and Instructor.
Follow me on LinkedIn, Twitter and YouTube.
You can meet me at events like IBM TechXchange, the Common Europe Congress, and GSE Germany’s IBM Power Working Group sessions.