AIX Open Source

 View Only
Expand all | Collapse all

Ansilbe throws errors: "The conditional check 'nimadm_phases_to_run is regex(\"[^0-9,]\") or nimadm_phases_to_run[-1] == ',''" while run playbook to updating AIX 7.3 Service pack.

  • 1.  Ansilbe throws errors: "The conditional check 'nimadm_phases_to_run is regex(\"[^0-9,]\") or nimadm_phases_to_run[-1] == ',''" while run playbook to updating AIX 7.3 Service pack.

    Posted Thu May 09, 2024 03:50 AM

    ENV: 
        - NIM server: (hostname: efsnim-p1, AIX version: 7300-02-01-2346)
        - NIM client: (hostname: lpar112, AIX version: 7300-02-00-0000)    
        
    NIM LPP_SOURCE, SPOT, NIM client and lspv on nimclinent information.

        root@efsnim-p1:/root> lsnim -l -l lpp_source_aix73
        lpp_source_aix73:
           class        = resources
           type         = lpp_source
           arch         = power
           Rstate       = ready for use
           prev_state   = unavailable for use
           location     = /export/lpp_source/lpp_source_aix73
           simages      = yes
           alloc_count  = 0
           server       = master
           date_updated = Fri Apr 12 02:47:12 2024

        root@efsnim-p1:/root> lsnim -l -l spot_aix73
        spot_aix73:
           class         = resources
           type          = spot
           plat_defined  = chrp
           arch          = power
           bos_license   = yes
           Rstate        = ready for use
           prev_state    = verification is being performed
           location      = /export/spot/spot_aix73/usr
           version       = 7
           release       = 3
           mod           = 2
           oslevel_r     = 7300-02
           oslevel_s     = 7300-02-01-2346
           alloc_count   = 0
           server        = master
           if_supported  = chrp.64 ent
           Rstate_result = success
           date_updated  = Fri Apr 12 02:56:59 2024

        root@efsnim-p1:/root> lsnim -l -l lpar112
        lpar112:
           class           = machines
           type            = standalone
           installed_image = efsesb-ap1-p1_20240411_mksysb
           connect         = nimsh
           platform        = chrp
           netboot_kernel  = 64
           if1             = network1 lpar112 0
           cable_type1     = N/A
           Cstate          = ready for a NIM operation
           prev_state      = currently running
           Mstate          = not running
           cpuid           = 00C117E04B00
           Cstate_result   = success

        root@efsnim-p1:/root> lspv
        hdisk0          00c117e0c533bd6e                    rootvg          active
        hdisk1          00c117e0cea7a3c0                    nimvg           active
        root@efsnim-p1:/root> lsvg -l nimvg
        nimvg:
        LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
        explv               jfs2       199     199     1    open/syncd    /export
        root@efsnim-p1:/root>


        root@lpar112:/root> lspv
        hdisk0          00c117e00a7d7827                    rootvg          active
        hdisk1          none                                None
        root@lpar112:/root>


    Ansible on Control node and ibm.power_aix 1.8.3 collection.

        [ckansible@efsnim-p1:/home/ckansible/ck-ans-02]$ ansible --version
        ansible [core 2.14.13]
          config file = /home/ckansible/ck-ans-02/ansible.cfg
          configured module search path = ['/home/ckansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
          ansible python module location = /opt/freeware/lib/python3.9/site-packages/ansible
          ansible collection location = /home/ckansible/ck-ans-02/ibmcollections:/usr/share/ansible/collections
          executable location = /opt/freeware/bin/ansible.orig
          python version = 3.9.16 (main, Jun 28 2023, 12:45:03) [GCC 8.3.0] (/opt/freeware/bin/python3.9)
          jinja version = 3.1.2
          libyaml = False
        [ckansible@efsnim-p1:/home/ckansible/ck-ans-02]$ ansible-galaxy collection list

        # /home/ckansible/ck-ans-02/ibmcollections/ansible_collections
        Collection    Version
        ------------- -------
        ibm.power_aix 1.8.3

        # /opt/freeware/lib/python3.9/site-packages/ansible_collections
        Collection                    Version
        ----------------------------- -------
        amazon.aws                    5.2.0
        ...

    Playbook, by reference "Migrating to AIX 7.3 with nimadm and Ansible" in url: https://community.ibm.com/community/user/power/blogs/chris-gibson1/2024/03/13/migrating-to-aix-73-with-nimadm-and-ansible

        [ckansible@efsnim-p1:/home/ckansible/ck-ans-02]$ cat playbooks/cg_nim_alt_disk_migration_lpar112_hdisk0.yml
        ---
        - name: "CK-PB - NIMADM playbook - Upgrading SP on AIX 7.3 TL02 SP00 to 7300-02-01-2346 with nimadm and Ansible"
          hosts: lpar112
          gather_facts: no

          collections:
            - ibm.power_aix
          tasks:
            - include_role:
                name: nim_alt_disk_migration
                apply:
                  delegate_to: efsnim-p1
              vars:
                nimadm_cache_vg: nimvg
                nim_client: lpar112
                target_disk:
                  disk_name: hdisk1
                lpp_source: lpp_source_aix73
                spot: spot_aix73
              register: nimadm_results

            - name: "T-1 - Debug: nimadm_results"
              ansible.builtin.debug: var=nimadm_results
        ...
        [ckansible@efsnim-p1:/home/ckansible/ck-ans-02]$

    Run playbook and errors.
        [ckansible@efsnim-p1:/home/ckansible/ck-ans-02]$ ansible-playbook playbooks/cg_nim_alt_disk_migration_lpar112_hdisk0.yml -u root --private-key=./devops_key/devops_id_ed25519

        PLAY [CK-PB - NIMADM playbook - Upgrading SP on AIX 7.3 TL02 SP00 to 7300-02-01-2346 with nimadm and Ansible] *************************************************************************

        TASK [include_role : nim_alt_disk_migration] ******************************************************************************************************************************************

        TASK [ibm.power_aix.nim_alt_disk_migration : Validating arguments against arg spec 'main' - This role is used to migrate a client OS levels from AIX 7.1/7.2 to AIX 7.3.] *************
        ok: [lpar112 -> efsnim-p1]

        TASK [ibm.power_aix.nim_alt_disk_migration : Fail if a NIM LPP resource is not specified] *********************************************************************************************
        skipping: [lpar112]

        TASK [ibm.power_aix.nim_alt_disk_migration : debug] ***********************************************************************************************************************************
        ok: [lpar112 -> efsnim-p1] => {
            "msg": "LPP resource lpp_source_aix73 specified for migration"
        }

        TASK [ibm.power_aix.nim_alt_disk_migration : Check if CacheVG 'nimvg' exists] *********************************************************************************************************
        ok: [lpar112 -> efsnim-p1]

        TASK [ibm.power_aix.nim_alt_disk_migration : Fail when '{{ nimadm_phases_to_run }}' contains invalid characters] **********************************************************************
        fatal: [lpar112 -> efsnim-p1]: FAILED! => {"msg": "The conditional check 'nimadm_phases_to_run is regex(\"[^0-9,]\") or nimadm_phases_to_run[-1] == ','' failed. The error was: error while evaluating conditional (nimadm_phases_to_run is regex(\"[^0-9,]\") or nimadm_phases_to_run[-1] == ','): 'nimadm_phases_to_run' is undefined. 'nimadm_phases_to_run' is undefined\n\nThe error appears to be in '/home/ckansible/ck-ans-02/ibmcollections/ansible_collections/ibm/power_aix/roles/nim_alt_disk_migration/tasks/main.yml': line 20, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Fail when '{{ nimadm_phases_to_run }}' contains invalid characters\"\n  ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n    with_items:\n      - {{ foo }}\n\nShould be written as:\n\n    with_items:\n      - \"{{ foo }}\"\n"}

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

        [ckansible@efsnim-p1:/home/ckansible/ck-ans-02]$

    Regards,

    Charin Kumjudpai.



    ------------------------------
    CHARIN KUMJUDPAI
    ------------------------------


  • 2.  RE: Ansilbe throws errors: "The conditional check 'nimadm_phases_to_run is regex(\"[^0-9,]\") or nimadm_phases_to_run[-1] == ',''" while run playbook to updating AIX 7.3 Service pack.

    Posted Thu May 09, 2024 05:15 AM

    Hi Charin,
    Pease open a defect on our GitHub repository - https://github.com/IBM/ansible-power-aix
    We track the issues/defects from there itself.



    ------------------------------
    Shreyansh Chamola
    ------------------------------



  • 3.  RE: Ansilbe throws errors: "The conditional check 'nimadm_phases_to_run is regex(\"[^0-9,]\") or nimadm_phases_to_run[-1] == ',''" while run playbook to updating AIX 7.3 Service pack.

    Posted Fri May 10, 2024 04:24 AM

    Yes, it is a bug in the latest versions of ibm.power_aix collection. It checks the value in the variable before it even sets the default value to it.

    The workaround is to define the attribute it requires:

    nimadm_phases_to_run: 1,2,3,4,5,6,7,8,9,10,11,12



    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------



  • 4.  RE: Ansilbe throws errors: "The conditional check 'nimadm_phases_to_run is regex(\"[^0-9,]\") or nimadm_phases_to_run[-1] == ',''" while run playbook to updating AIX 7.3 Service pack.

    Posted Mon May 13, 2024 01:20 AM

    Hello Andrey Klyachkin,

    Due to my purpose to use ansible to perform AIX update service pack (SP) on NIM client (A.K.A: Ansbile Managed node.)

    Ansible Env:
        - Control node/NIM Server (hostname: efsnim-p1, 7300-02-01-2346)
        - Managed ndoe/NIM Client (hostname: lpar111, lpar112, 7300-02-00-0000)

    To update SP on Managed node/NIM Client.
        FROM: 7300-02-00-0000
        TO: 7300-02-01-2346

    My solution.
        By reference the example playbook name "demo_nim.yml" was included in "ibm-power_aix-1.8.3" collection.
        And I have modified and using the below playbook.

        ---
        - name: "CK-PB-TEST-4 - NIM operation on AIX/VIOS UPDATE SP01 ON 2 LPARs..."
          hosts: efsnim-p1
          remote_user: root
          gather_facts: no
          vars:
            check_targets_v:        standalone
            install_targets_v:      lpar112,lpar111
            update_lpp_v:           lpp_source_aix73

          collections:
            - ibm.power_aix

          tasks:

            - name: "T-1 - Update a LPAR to the latest level available"
              nim:
                action: update
                targets: "{{ install_targets_v }}"
                lpp_source: "{{ update_lpp_v }}"
                asynchronous: true
                force: false
              register: result
            - debug: var=result
        ...

        I ran playbook above is took very short time and I verified in "Managed ndoe/NIM Client" in "cat /var/adm/ras/nim.installp"

            ...
                * * *  A T T E N T I O N  * * *
                System boot image has been updated. You should reboot the
                system as soon as possible to properly integrate the changes
                and to avoid disruption of current functionality.

            installp:  bosboot process completed.
            +-----------------------------------------------------------------------------+
                                            Summaries:
            +-----------------------------------------------------------------------------+

            Installation Summary
            --------------------
            Name                        Level           Part        Event       Result
            -------------------------------------------------------------------------------
            bos.dsc                     7.3.2.1         USR         APPLY       SUCCESS
            bos.rte.install             7.3.2.1         USR         APPLY       SUCCESS
            bos.rte.install             7.3.2.1         ROOT        APPLY       SUCCESS
            perfagent.tools             7.3.2.1         USR         APPLY       SUCCESS
            perfagent.tools             7.3.2.1         ROOT        APPLY       SUCCESS
            devices.vdevice.IBM.vfc-cli 7.3.2.1         USR         APPLY       SUCCESS
            devices.vdevice.IBM.vfc-cli 7.3.2.1         ROOT        APPLY       SUCCESS
            bos.rte.serv_aid            7.3.2.1         USR         APPLY       SUCCESS
            bos.rte.serv_aid            7.3.2.1         ROOT        APPLY       SUCCESS
            bos.rte                     7.3.2.1         USR         APPLY       SUCCESS
            bos.mp64                    7.3.2.1         USR         APPLY       SUCCESS
            bos.mp64                    7.3.2.1         ROOT        APPLY       SUCCESS
            bos.alt_disk_install.boot_i 7.3.2.1         USR         APPLY       SUCCESS

            END:Sat May 11 02:18:54 2024:051019185424
            root@lpar111:/root>
        
        And check "oslevel -s" command on both Managed nodes shown "7300-02-01-2346".

            root@efsnim-p1:/home/ckansible/ck-ans-02> ansible lpar111,lpar112 -m shell -a "oslevel -s"
            lpar111 | CHANGED | rc=0 >>
            7300-02-01-2346
            lpar112 | CHANGED | rc=0 >>
            7300-02-01-2346
            root@efsnim-p1:/home/ckansible/ck-ans-02>

    In my opinion.
     When I tried to test/POC Ansible for power (AIX) such as update TL or SP operations there is NOT MUCH document to explain about playbook detail and operation from IBM (undoc) for "ibm-power_aix-1.8.3" collection.
     Could you please advice or guide document for Ansible playbook for AIX operation use cases such as TL/SP update, AIX upgrade, ifix install and (emgr) installation.

    Regards,
    Charin Kumjudpai.



    ------------------------------
    CHARIN KUMJUDPAI
    ------------------------------



  • 5.  RE: Ansilbe throws errors: "The conditional check 'nimadm_phases_to_run is regex(\"[^0-9,]\") or nimadm_phases_to_run[-1] == ',''" while run playbook to updating AIX 7.3 Service pack.

    Posted Mon May 13, 2024 03:57 AM

    Hi Charin,

    I don't know any documentation which would fit every environment ;-)

    There is the aforementioned article of Chris and I find it very good and use the playbook from it to make several upgrade tests and as a base for my own AIX upgrade playbooks.

    There is Ansible on IBM Power Redbook https://www.redbooks.ibm.com/abstracts/sg248551.html but there is no AIX upgrade topic in it. Only AIX updates. This is my fault. I missed it completely from the radar.

    I have plans to write articles (or series) on AIX updates and upgrades later this year but it will be not earlier as in summer.



    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------