We created an LPAR on IBM Power and installed AIX on it. Of course, with Ansible. But what if I need Linux, not AIX, on my LPAR?
What’s the problem? Just change one line.
Of course, there is one (at least one) prerequisite. You have read my articles about preparing a Linux installation server:
You can use the same principle to build your Linux installation server on IBM Power if you don’t have access to x86 VMs.
But if you wish, you can use my older articles about using AIX NIM server to install Linux on Power:
This article will probably be a repeat of those articles for some of you. But this time I don’t use AIX NIM; instead, I use a Linux installation server created earlier.
One line to change
Do you remember the Ansible code to install AIX on an LPAR from the previous newsletter? No problem, here it is:
- name: Start installation
ibm.power_hmc.powervm_lpar_instance:
hmc_host: "{{ hmc }}"
hmc_auth: "{{ hmc_auth }}"
system_name: "{{ managed_system }}"
vm_name: "{{ lpar }}"
install_settings:
vm_ip: "{{ lpar_ip }}"
nim_ip: "{{ nim_ip }}"
nim_gateway: "{{ lpar_gw }}"
nim_netmask: "{{ lpar_netmask }}"
action: install_osDo you know what the new code to install Linux on an LPAR looks like? Here it is:
- name: Start installation
ibm.power_hmc.powervm_lpar_instance:
hmc_host: "{{ hmc }}"
hmc_auth: "{{ hmc_auth }}"
system_name: "{{ managed_system }}"
vm_name: "{{ lpar }}"
install_settings:
vm_ip: "{{ lpar_ip }}"
nim_ip: "{{ instsrv_ip }}"
nim_gateway: "{{ lpar_gw }}"
nim_netmask: "{{ lpar_netmask }}"
action: install_osDid you find the difference? It is the line with nim_ip.
In the previous version, I used the variable nim_ip, and in this version, I use the variable instsrv_ip.
As you probably already guessed, the old variable contained the IP address of my AIX NIM server. The new variable contains the IP address of my Linux installation server.
Is that all???
Unfortunately, no.
Similar to AIX, if we want to install Linux, we must ensure that the installation resources are available.
In the Linux case, we must create a server definition in the DHCP configuration file, create the GRUB configuration, and create a kickstart or AutoYAST profile.
Get MAC address from HMC
To create server definition we must first get the LPAR’s MAC address from HMC.
We use the following command to get it:
- name: Get LPAR's MAC address
ibm.power_hmc.hmc_command:
cmd: "lshwres -m {{ managed_system }} -r virtualio --rsubtype eth --level lpar --filter lpar_names={{ lpar }} -F mac_addr"
changed_when: false
register: macaddrThis was the command for a virtual Ethernet adapter. If you use SR-IOV or hardware adapters, it will not work. It also will not work if you have multiple virtual Ethernet adapters. In this case, you must find your way through the jungle of MAC addresses.
Configure DHCPd
After we found the MAC address, we must format it accordingly to the DHCP requirements:
- name: Set MAC address fact
ansible.builtin.set_fact:
mac_addr: "{{ macaddr.command_output.0 | ansible.utils.hwaddr('linux') }}"Now we are ready to change DHCP configuration:
- name: Add LPAR to dhcpd.conf
ansible.builtin.lineinfile:
path: /etc/dhcp/dhcpd.conf
line: "host {{ lpar }} { hardware ethernet {{ mac_addr }}; fixed-address {{ lpar_ip }}; filename "boot/grub2/powerpc-ieee1275/core.elf"; }'
delegate_to: "{{ instsrv }}"
become: trueOf course, you must restart DHCPd after the configuration is changed:
- name: Restart DHCP
ansible.builtin.systemd_service:
name: dhcpd
state: restarted
delegate_to: "{{ instsrv }}"
become: trueIf you want to do everything fine, you must declare the task “Restart DHCP” as a handler and add a notify clause to the task “Add LPAR to dhcpd.conf”. But let’s keep it simple today.
Configure GRUB
I usually create LPAR-specific GRUB configuration files. They must have names like grub.cfg-IP_Address_in_HEX. It means we must first convert our LPAR IP address to hex:
- name: Convert IP address to hex
ansible.builtin.set_fact:
lpar_ip_hex: "{{ lpar_ip | ansible.utils.ip4_hex | upper }}"Now we can create the configuration file:
- name: Create GRUB configuration
ansible.builtin.template:
src: grub.cfg.j2
dest: "/var/lib/tftpboot/boot/grub2/powerpc-ieee1275/grub.cfg-{{ lpar_ip_hex }}"
owner: root
group: root
mode: '0644'
delegate_to: "{{ instsrv }}"
become: trueThis is the example of grub.cfg.j2 file I used during my last workshop:
echo "Welcome to the Linux on IBM Power installer!"
echo ""
set timeout=60
{% if linux_distro == 'RHEL' %}
menuentry 'Install Red Hat Enterprise Linux {{ linux_version }}' --class fedora --class gnu-linux --class gnu --class os --id rhel {
linux (tftp,10.10.10.10)/rhel/{{ linux_version }}-ppc64le/vmlinuz ro ip=dhcp inst.repo=http://10.10.10.10/RHEL/{{ linux_version }}-ppc64le/ inst.ks=http://10.10.10.10/ks/{{ lpar }}.ks
initrd (tftp,10.10.10.10)/rhel/{{ linux_version }}-ppc64le/initrd.img
}
{% else %}
menuentry 'Install SUSE Linux Enterprise Server {{ linux_version }}' --class opensuse --class gnu-linux --class gnu --class os --id sles {
linux (tftp,10.10.10.10)/sles/{{ linux_version }}-ppc64le/linux ro ip=dhcp install=http://10.10.10.10/SLES/{{ linux-version }}-ppc64le/ autoyast=http://10.10.10.10/ks/{{ lpar }}.ks
initrd (tftp,10.10.10.10)/sles/{{ linux_version }}-ppc64le/initrd
}
{% endif %}I think you can find multiple ways to make this configuration better. You can parameterize some hard-coded values or standardize directory names to get rid of ugly if conditions. Or you can add some nice graphics with your company logo :-)
Kickstart and AutoYast files
This is an optional step, and if you don't have them, you can skip it.
- name: Create RHEL kickstart file
ansible.builtin.template:
src: autoinst.ks.j2
dest: "/var/www/html/ks/{{ lpar }}.ks"
owner: root
group: root
mode: '0644'
delegate_to: "{{ instsrv }}"
become: true
when: linux_distro == "RHEL"
- name: Create SLES autoyast profile
ansible.builtin.template:
src: autoinst.xml.j2
dest: "/var/www/html/ks/{{ lpar }}.xml"
owner: root
group: root
mode: '0644'
delegate_to: "{{ instsrv }}"
become: true
when: linux_distro == "SLES"Sorry, I will not post the kickstart and autoyast profiles. They are very long.
You can find them in my older articles:
In any case, you must change them for your environment.
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!
That’s all!
Of course, my playbooks from this newsletter are not always production-ready. You should combine the tasks, add the variables referenced in the playbook, and probably change one or more hard-coded values.
Maybe you should add other tasks, specific to your environment.
Still, I hope I could show you that deploying an LPAR on IBM Power and installing AIX or Linux into it using Ansible is an easy task. You can now deploy as many LPARs as you wish in your environment.
Have fun installing Linux on IBM Power!
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.




