Automation with Power

 View Only
  • 1.  Creating lpp_source with ansible

    Posted Wed May 22, 2024 12:38 PM

    I want to create an lpp_source with ansible

    Can anyone help with how they go about this please? I am trying to use the flash version of the ISO 



    ------------------------------
    Rasaq Raji
    ------------------------------



  • 2.  RE: Creating lpp_source with ansible

    IBM Champion
    Posted Thu May 23, 2024 04:38 AM

    This is an excerpt from my old playbook where I do the same:

      - name: Set LPP source name
        ansible.builtin.set_fact:
          lppsource: "{{ oslevel }}-lpp_source"
    
      - name: Check if lpp_source {{ lppsource }} exists
        ansible.builtin.command: lsnim -l {{ lppsource }}
        register: lppsource_check
        failed_when: false
    
      - name: Exit playbook if lpp_source {{ lppsource }} exists
        ansible.builtin.meta: end_play
        when: lppsource_check.rc == 0
    
      - name: Check if base AIX TL ISO image exists
        ansible.builtin.stat:
          path: "{{ isoimage }}"
        register: basetl_image
    
      - name: Fail if base AIX TL ISO image doesn't exist
        ansible.builtin.fail:
          msg: Could not find ISO image in {{ isoimage }}
        when: not basetl_image.stat.exists
     
     - name: Create a new lpp source {{ lppsource }} with base filesets
        ansible.builtin.command: nim -o define -t lpp_source -a server=master -a location=/export/lpp_source/{{ lppsource }} -a source={{ basetl_image.stat.path }} -a packages=all {{ lppsource }}
    


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

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



  • 3.  RE: Creating lpp_source with ansible

    Posted Thu May 23, 2024 07:45 AM

    Thank you Andrey for your response. Below is the playbook i tried using but the problem is the lpp_source is not correctly created, comparing  its size the ones i  have created manually.

    ---
    - name: "NIM operations to create, delete or show NIM resource objects"
      hosts: nim_server
      gather_facts: true
      vars:
        lpp_source_v: aix7300_0201_test1
        software_lpp_source: /nim/7.3_Base/AIX_v7300-02-01-2346_flash
        lpp_source_location: /nimdata/lpp_source/aix7300_0201_test1
    
      collections:
        - ibm.power_aix
      tasks:
    
        - name: Create/define an lpp_source NIM resource object from the
                software in the system.
          nim_resource:
            action: create
            name: "{{ lpp_source_v }}"
            object_type: lpp_source
            attributes:
              source: "{{ software_lpp_source }}"
              location: "{{ lpp_source_location }}"
          register: result
    
        - name: Display result
          debug: var=result
    

    Thanks



    ------------------------------
    Rasaq Raji
    ------------------------------



  • 4.  RE: Creating lpp_source with ansible

    Posted Wed May 29, 2024 08:22 PM
    Edited by Chris Gibson Wed May 29, 2024 08:22 PM

    Hi, I had the same problem, until I added  packages: "all" to the playbook. Thanks to Rich Jefferies (IBM) for the tip.

    ---
    - name: "NIM operations to create, delete or show NIM resource objects"
      hosts: nim
      gather_facts: true
      vars:
        lpp_name: myaixlpp
        software_lpp_source: /export/lpp_source/AIX73TL1SP1
        lpp_new_location: /cg/myaixlpp
      collections:
        - ibm.power_aix
      tasks:

        - name: Create/define an lpp_source NIM resource object from the
                software in the system.
          nim_resource:
            action: create
            name: "{{ lpp_name }}"
            object_type: lpp_source
            attributes:
              source: "{{ software_lpp_source }}"
              location: "{{ lpp_new_location }}"
              packages: "all"
          register: result

        - name: Display result
          debug: var=result



    ------------------------------
    Chris Gibson
    ------------------------------



  • 5.  RE: Creating lpp_source with ansible

    Posted Thu May 30, 2024 03:49 AM

    Hi Chris,

    Thank you for sharing this tips with me, I really appreciate.

    This works perfectly.

    Just getting into Ansible on POWER environment, if you have got anymore playbooks that i can use to automate things on AIX, I will appreciate if you could share the resources with me.

    Thanks



    ------------------------------
    Rasaq Raji
    ------------------------------