AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only

Programmatically updating AIX stanza files

By Dave Marquardt posted Wed May 07, 2025 06:04 PM

  

1. Enabling LLU in lvupdate.data

I recently attended a demo of AIX Live Update with the tech preview Live Library Update. You can enable live library update from Live Update by adding a stanza to the AIX lvupdate.data stanza file, like this:

llvupdate:
	llu = yes

But, as a customer pointed out, they don't want to edit this file, due to

  • having multiple LPARs that use Live Update
  • the risk of typographical errors

1.1. Ansible

If you're using Ansible, you can use ansible.builtin.blockinfile to ensure the block above is present in the file.

For example

- name: Enable llu in lvupdate.data
  ansible.builtin.blockinfile:
    path: /var/adm/ras/liveupdate/lvupdate.data
    block: |
      llvupdate:
        llu = yes

1.2. Use Python to update lvupdate.data

You could also write a program in Python to parse and update lvupdate.data. The ConfigParser module can parse and update configuration files similar to those of Microsoft Windows. The AIX stanza files are similar enough that some setting some options and overloading a method is all that's necessary to parse and update AIX stanza files. Then its a small matter of using ConfigParser to parse lvupdate.data, then ensure the "llvupdate" stanza (which ConfigParser calls a "section") exists with the attribute "llu" set to "yes". Then use ConfigParser to write out the updated lvupdate.data.

One down side to using this method is that it does not preserve comments. If that's a problem, using Ansible might be a better idea.

I've written a Python package "aixstanzaparser" to parse and update AIX stanza files, like I suggested just above. You can install it in your Python virtual environment with

pip install aixstanzaparser

Here's a small Python program that will read and parse /var/adm/ras/liveupdate/lvupdate.data and update it to include "llu = yes" as above.

import aixstanzaparser

# Create parser instance
config = aixstanzaparser.AIXStanzaParser()

# Read and parse lvupdate.date
config.read("lvupdate.data")

# Update llvupdate.llu to yes
if 'llvupdate' not in config.sections():
    config['llvupdate'] = {}
config['llvupdate']['llu'] = "yes"

# write updated lvupdate.data
with open("lvupdate.data", "w") as configfile:
    config.write(configfile)

And the resulting file shows our updated "llu = yes":

general:
	kext_check = 

disks:
	nhdisk = 
	mhdisk = 
	tohdisk = 
	tshdisk = 

hmc:
	lpar_id = 
	management_console = 
	user = 

llvupdate:
	llu = yes

4 comments
25 views

Permalink

Comments

Fri May 16, 2025 10:12 AM

@Erwin Groeneveld I'm not sure how to make that happen. Maybe open an issue at https://github.com/IBM/ansible-power-aix/issues

Tue May 13, 2025 09:09 AM

This looks really nice! 

When will this be inherited into the IBM galaxy collection? 

Tue May 13, 2025 07:04 AM

this is very nice! thanks Dave, we now can replace our ksh script chstanza :) with ansible scripting.

Thu May 08, 2025 05:04 AM

Cool! Thanks Dave.