Ansible and AIX

This post will indicate how to use ansible to deploy AIX LPAR(s). Once the LPARs are deployed, further testing will be done to control various aspects within AIX. This is a WIP, so things will be updated as they are tested.

Resources

ansible AIX playbook
Install ansible on AIX

First thing required is to install ansible on the control node: (linux debian system in this example)

Installing ansible on Debian steps: (this will be the ansible control node)

# echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list
# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
# sudo apt update
# sudo apt install ansible

Clone ansible AIX playbook on ansible control node

cd ~ && git clone https://github.com/IBM/ansible-power-aix.git ansible-power-aix

Grab IBM requirement module from galaxy

ansible-galaxy collection install ibm.power_aix

Prepare steps for AIX LPAR rollout(s)

  • Create a ssh key-pair on the Linux system
  • Modify inventory.yaml file for hosts/hostgroups (contained in the playbooks directory)

AIX LPAR:

Pre-requisites:

  • tcl.base and tk.base installed from AIX Media
  • run of /usr/sbin/updtvpkg performed

Build AIX 7.2 test system

  • Create new LPAR using HMC (or other depending on environment)
  • Upload ssh public key (for root user, or one w sudo permissions) to new LPAR
  • create entry for new AIX LPAR(s) in the control nodes inventory.yaml (if required)
    • test via ping module: ansible all -m ping -i playbooks/inventory.yml
  • Perform a deploy bootstrap check: ansible-playbook -i playbooks/inventory.yml -l aixlpar playbooks/demo_bootstrap.yml --check
  • Backup system (in case you want to roll things back) via mksysb / snapshot / other method
  • Prior to deployment (especially with a new system), some of the file systems disk space is too low, they will need to be extended. ex: chfs -a size=+2G /var ; chfs -a size=+2G /opt ; chfs -a size=+2G /usr ; chfs -a size=+5G /tmp
  • Deploy playbook (the -l in the ‘deploy bootstrap check’ above forces deployment to one specific host), remove the –check to actually deploy it

NOTE: The bootstrap playbook may have some issues whereby it looks for a register: yum_exists.stdout is search(“false”). The .stdout may need to be removed for it to run properly.

Sample run:

TASK [power_aix_bootstrap : Restore yum bundle content] ************************************************
ansible-playbook -i playbooks/inventory.yml -l aixlpar playbooks/demo_bootstrap.yml
PLAY [Bootstrap Yum on AIX] ****************************************************************************

TASK [power_aix_bootstrap : Fail if pkgtype not specified] *********************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Fail if download_dir not specified] ****************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Fail if target_dir not specified] ******************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Fail if rpm_src not specified] *********************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Fail if yum_src not specified] *********************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Bootstrap yum] *************************************************************
included: /home/linuxuser/ansible-power-aix/roles/power_aix_bootstrap/tasks/yum_install.yml for aixlpar

TASK [power_aix_bootstrap : Check for existence of yum] ************************************************
changed: [aixlpar]

TASK [power_aix_bootstrap : debug] *********************************************************************
ok: [aixlpar] => {
    "yum_exists": {
        "changed": true,
        "failed": false,
        "rc": 0,
        "stderr": "X11 forwarding request failed\r\nShared connection to aixlpar.example.com closed.\r\n",
        "stderr_lines": [
            "X11 forwarding request failed",
            "Shared connection to aixlpar.example.com closed."
        ],
        "stdout": "false\r\n",
        "stdout_lines": [
            "false"
        ]
    }
}

TASK [power_aix_bootstrap : Check for rpm_src file on localhost] ***************************************
ok: [aixlpar -> localhost]

TASK [power_aix_bootstrap : Download latest rpm (installp) fileset] ************************************
changed: [aixlpar -> localhost]

TASK [power_aix_bootstrap : Check for yum_src file on localhost] ***************************************
ok: [aixlpar -> localhost]

TASK [power_aix_bootstrap : Download yum bundle file] **************************************************
changed: [aixlpar -> localhost]

TASK [power_aix_bootstrap : Check for script file on localhost] ****************************************
ok: [aixlpar -> localhost]

TASK [power_aix_bootstrap : Copy the installer script file] ********************************************
changed: [aixlpar -> localhost]

TASK [power_aix_bootstrap : Check for target directory] ************************************************
changed: [aixlpar]

TASK [power_aix_bootstrap : Check for target yum bundle] ***********************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Create target filesystem for image transfer] *******************************
changed: [aixlpar]

TASK [power_aix_bootstrap : Mount target filesystem] ***************************************************
changed: [aixlpar]

TASK [power_aix_bootstrap : Transfer install images] ***************************************************
changed: [aixlpar -> localhost]

TASK [power_aix_bootstrap : Restore yum bundle content] ************************************************
changed: [aixlpar]

TASK [power_aix_bootstrap : Remove temporary storage space] ********************************************
changed: [aixlpar]

TASK [power_aix_bootstrap : Print status] **************************************************************
ok: [aixlpar] => {
    "msg": "Bootstrap attempt of yum on aixlpar has completed"
}

TASK [power_aix_bootstrap : Bootstrap python] **********************************************************
skipping: [aixlpar]

PLAY [Bootstrap Python on AIX] *************************************************************************

TASK [power_aix_bootstrap : Fail if pkgtype not specified] *********************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Fail if download_dir not specified] ****************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Fail if target_dir not specified] ******************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Fail if rpm_src not specified] *********************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Fail if yum_src not specified] *********************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Bootstrap yum] *************************************************************
skipping: [aixlpar]

TASK [power_aix_bootstrap : Bootstrap python] **********************************************************
included: /home/linuxuser/ansible-power-aix/roles/power_aix_bootstrap/tasks/python_install.yml for aixlpar

TASK [power_aix_bootstrap : Check for existence of yum] ************************************************
changed: [aixlpar]

PLAY RECAP *********************************************************************************************
aixlpar     : ok=18   changed=11   unreachable=0    failed=0    skipped=13   rescued=0    ignored=0

Afterwords, to confirm that yum was installed on that node, you can run an ansible ad-hoc command:

# ansible aixlpar -i inventory.yml -a "yum --version"
aixlpar | CHANGED | rc=0 >>
3.4.3
Installed: yum-3.4.3-8.noarch at 2021-08-27 15:38
Built : IBM AIX Toolbox https://ibm.biz/AIXToolbox at 2020-12-04 12:33
Committed: Sangamesh Mallayya <[email protected] at 2020-11-30

The ping module probably would of failed earlier, as python wasn’t on the system. Now that it has been installed, you can see what it outputs now with:

# ansible -m ping -i inventory.yml aixlpar

WARNING]: Platform aix on host aixlpar is using the discovered Python interpreter at
/usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
information.
aixlpar | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}

In case yum packages weren’t updated during the bootstrap, they can be upgraded now with: ansible-playbook -i inventory.yml -l aixlpar demo_yum.yml

Next step is to attempt a suma upgrade.

ansible-playbook -i inventory.yml -l aixlpar demo_suma.yml
PLAY [SUMA on AIX] *************************************************************************************
TASK [Gathering Facts] *********************************************************************************
ok: [aixlpar]
TASK [Check oslevel of system] *************************************************************************
changed: [aixlpar]
TASK [debug] *******************************************************************************************
ok: [aixlpar] => {
    "output": {
        "changed": true,
        "cmd": "oslevel -s",
        "delta": "0:00:02.413442",
        "end": "2021-09-13 14:33:40.540248",
        "failed": false,
        "rc": 0,
        "start": "2021-09-13 14:33:38.126806",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "7200-05-02-2114",
        "stdout_lines": [
            "7200-05-02-2114"
        ]
    }
}

TASK [Create file system for system updates] ***********************************************************
changed: [aixlpar]

TASK [Mount the file system (if necessary)] ************************************************************
changed: [aixlpar]

TASK [Check for, and install, system updates] **********************************************************
fatal: [aixlpar]: FAILED! => {"changed": false, "cmd": "/usr/sbin/suma -x -a RqType=Latest -a Action=Preview -a DLTarget=/usr/sys/inst.images -a 'DisplayName=preview request for oslevel latest' -a FilterDir=/usr/sys/inst.images -a Extend=y", "msg": "[Errno 2] A file or directory in the path name does not exist.", "rc": 2}

PLAY RECAP *********************************************************************************************
aixlpar                  : ok=5    changed=3    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Apparently no ‘suma’ package is installed by default on AIX 7.2. The fileset bos.suma would have to be installed prior to having a successful suma run.