Automation with Power

 View Only
Expand all | Collapse all

nim_alt_disk_migration

  • 1.  nim_alt_disk_migration

    Posted Wed October 02, 2024 03:16 AM
    Edited by Henrik Morsing Wed October 02, 2024 04:04 AM

    Good morning,

    I am trying to use the above role from the ibm.power_aix collection but I just get:

    ERROR! the role 'nim_alt_disk_migration' was not found in ibm.power_aix:ansible.legacy:/runner/project/ansible/playbooks/roles:/runner/requirements_roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/runner/project/ansible/playbooks
    We use the collection already for standard AIX related modules, so I don't understand what the problem is. Our collection is on version 1.6.1 which definitely has this role.
    .
    .
    .
    Any ideas?
    .
    .
    .
    .
    .
      vars:
        mountpoint/mnt/upgrade
        UPDATE_LPP"lpp_source_7300-02-00"
        nim_client"{{ node }}"
        target_disk:
          disk_namehdisk1
        lpp_source7300-02-00-2345_lpp_source
        spotspot_7300-02-00
      collections:
        ibm.power_aix

      tasks:
    [...]
      - namePerform 7.2 to 7.3 migration
        include_role:
          namenim_alt_disk_migration
          apply:
            delegate_to"{{ nimserver }}"
        vars:
          target_disk:
            disk_namehdisk1
          lpp_source7300-02-00-2345_lpp_source
          spotspot_7300-02-00
        registernimadm_results

      - name"Debugnimadm_results"
        debugvar=nimadm_results

    .
    ------------------------------
    Henrik Morsing
    ------------------------------



  • 2.  RE: nim_alt_disk_migration

    Posted Thu October 03, 2024 12:45 AM

    I don't know what might be causing your particular problem, but maybe you could try updating your AIX collection first, and see if it helps. Just a thought. Last time I worked with this, it was successful with v1.8.1, https://community.ibm.com/community/user/power/blogs/chris-gibson1/2024/03/13/migrating-to-aix-73-with-nimadm-and-ansible. The latest version is 1.9.2.



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



  • 3.  RE: nim_alt_disk_migration

    Posted Thu October 03, 2024 02:20 AM

    Hi Chris,

    I got a bit further investigating this yesterday. It is down to the "roles" variable not being defined in ansible.cfg, however, we use AWX (sadly) and although I managed to figure out how to define the variable so the pods can see it, they don't have the path I define. I need to find a way to get the roles directory into the pods, which may be via the DevOps repository. Still investigating.

    Regards,

    Henrik Morsing



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 4.  RE: nim_alt_disk_migration

    Posted Thu October 03, 2024 12:08 PM

    If you use AWX or Ansible Automation Platform with Execution Environments:

    • use ansible-navigator to check your playbooks and roles before deploying them into AAP
    • have all resources (roles and collections) in one project directory
    • create ansible.cfg specific for the project with the paths to your roles and collections

    Another comment - try to write the full qualified name for your role, like ibm.power_aix.nim_alt_disk_migration instead of simply nim_alt_disk_migration. You save some time for searching through all collections and directories.



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

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



  • 5.  RE: nim_alt_disk_migration

    Posted Fri October 04, 2024 03:06 AM

    Hi Andrey,

    I got a bit further yesterday. Placing the roles directory under my playbook directory picked it up. However, it now fails on finding an "internal" module/action:

    ERROR! couldn't resolve module/action 'ibm.power_aix.internal.nim_select_target_disk'. This often indicates a misspelling, missing collection, or incorrect module path.
    However, it is there:
    I've tried putting that plugins folder in different locations but nothing helps.
    Regards,
    Henrik Morsing


    ------------------------------
    Henrik Morsing
    ------------------------------



  • 6.  RE: nim_alt_disk_migration

    Posted Fri October 04, 2024 10:00 AM

    Hi Henrik,

    I don't understand why it is under roles in your structure.

    1. Create a subdirectory for your project:

    mkdir ~/nimadm
    cd ~/nimadm

    2. Create Ansible configuration file:

    cat >ansible.cfg <<EOF
    [defaults]
    collections_paths = ./collections
    EOF

    3. Install ibm.power_aix collections into subdirectory collections:

    ansible-galaxy collection install ibm.power_aix -p ./collections
    
    OR
    
    ansible-galaxy collection install ibm.power_aix==1.6.1 -p ./collections

    4. Write the playbook

    ---
    - name: Perform NIM alt_disk migration
      hosts: all
      vars:
        mountpoint: /mnt/upgrade
        UPDATE_LPP: "lpp_source_7300-02-00"
        nim_client: "{{ node }}"
        target_disk:
          disk_name: hdisk1
        lpp_source: 7300-02-00-2345_lpp_source
        spot: spot_7300-02-00
    
      tasks:
      - name: Perform 7.2 to 7.3 migration
        include_role:
          name: ibm.power_aix.nim_alt_disk_migration
          apply:
            delegate_to: "{{ nimserver }}"
        vars:
          target_disk:
            disk_name: hdisk1
          lpp_source: 7300-02-00-2345_lpp_source
          spot: spot_7300-02-00
        register: nimadm_results
    
      - name: "Debug: nimadm_results"
        debug: var=nimadm_results
    

    5. If you are on Linux, check it with ansible-navigator.

    ansible-navigator run -i inventory nimadm.yml



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

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



  • 7.  RE: nim_alt_disk_migration

    Posted Sat October 05, 2024 10:22 AM

    Hi Andrey,

    That is what I have done. The structure is like it is in the collections.

    Regards,

    Henrik Morsing



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 8.  RE: nim_alt_disk_migration

    Posted Mon October 07, 2024 08:31 AM

    Hi Henrik,

    if I download the version 1.6.1 which I assume you have, the file is on the right place:

    $ find . -name 'nim_select_target_disk.py'
    ./collections/ansible_collections/ibm/power_aix/plugins/modules/internal/nim_select_target_disk.py

    I can suggest to remove your collections subdirectory and download all collections one more time. Or if you use private automation hub, check that you have the correct collection on your hub.



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

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



  • 9.  RE: nim_alt_disk_migration

    Posted Mon October 07, 2024 08:43 AM

    Hi Andrey,

    What do you mean "in the right place"? If its own tasks can't find it, it is surely the wrong place?

    Regards,

    Henrik Morsing



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 10.  RE: nim_alt_disk_migration

    Posted Mon October 07, 2024 08:48 AM

    Hi Henrik,

    as you can see from the output I posted as for me the file is in 'collections/*/plugins/modules/internal'.

    From your output it is in 'roles/plugins/modules/internal' which is wrong place for one module.



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

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



  • 11.  RE: nim_alt_disk_migration

    Posted Mon October 07, 2024 08:58 AM

    Hi Andrey,

    I don't think DevOps can handle folders called *, is that really what you mean?

    Again, all I have done is download the collection and it is in roles/ . I've just tried again, download 1.6.4 from here:

    https://galaxy.ansible.com/ui/repo/published/ibm/power_aix/?version=1.6.4

    unzip and un-tar. and nim_alt_disk_migration is under roles/ . No-where else.

    Also, I have tried moving things around, it doesn't help. I could try to move internal, but I just think I'm now entering the realm of what the collections developer should be fixing, not me.

    If only I could figure out where it is actually defined what "internal" refers to.

    Regards,

    Henrik Morsing



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 12.  RE: nim_alt_disk_migration

    Posted Mon October 07, 2024 09:28 AM

    Hi Henrik,

    I don't know what you mean with DevOps, but please read my post above. I didn't say a word about untar, unzip or place in roles.

    • Please use ansible-galaxy to install collection even if you downloaded tarball file.
    • Please install collections in the directory which is for collections, not for roles as per my example above


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

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



  • 13.  RE: nim_alt_disk_migration

    Posted Mon October 07, 2024 11:11 AM

    Hi Andrey,

    >  Please use ansible-galaxy to install collection even if you downloaded tarball file.

    I don't know what that is, but if it is a command line tool, I doubt it can deploy to DevOps.

    > Please install collections in the directory which is for collections, not for roles as per my example above

    Collections or roles? I have installed the collections where collections go, the root of my DevOps deployment. 

    This is DevOps:

    https://azure.microsoft.com/en-gb/products/devops

    I can try your Ansible tool suggestion, but as we have AWX, not Ansible, it probably won't know what to do.

    Regards,

    Henrik



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 14.  RE: nim_alt_disk_migration

    Posted Mon October 07, 2024 01:44 PM

    I never worked with Azure DevOps, but I created a new project and I see that it is quite usual Git repository with pipelines, nothing special. So it changes nothing in my answer.

    You don't execute ansible-galaxy in Azure DevOps but on your local workstation where you write your code. Exactly as I wrote in the post #6 (I don't know how to post a link to the post here), do it step by step. Create a new project, execute the steps I wrote above and commit it to Azure DevOps.

    If the pipeline doesn't work, post the output of the pipeline log here.



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

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



  • 15.  RE: nim_alt_disk_migration

    Posted Tue October 08, 2024 03:45 AM

    Hi Andrey,

    By "local workstation", do you mean execution environment? I will have to see how that is built, but I think I already checked that at the beginning of this journey.

    ansible-galaxy isn't mentioned in our execution environment build document, it has a requirements.yml file that is used to pull collections from galaxy at build time. It is un-clear what reads that file or if at any point it is possible to run ansible-galaxy by hand, but I will have to ask the person who built it.

    Regards,

    Henrik 



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 16.  RE: nim_alt_disk_migration

    Posted Tue October 08, 2024 05:24 AM

    Hi Henrik,

    now we should define how you develop your Ansible code :-)

    "Normal" case with AAP/AWX: you have your own workstation or laptop, you write the code there and then you commit the code to some Git repository, like Azure DevOps. The code is "built" and checked there and deployed to your systems or to AWX/AAP.

    If you don't use your own workstation/laptop to write the code, but do it directly in some "Web UI" - there are many of them - you've lost most of the functionality you could use. Learn how to use git. You can use it quite automatically with tools like VS Code without learning whole git command line options.

    You don't need ansible-galaxy in your execution environment. The file requirements.yml specifies which collections must be installed and used during the execution. It is usually read by your execution environment, but it depends what execution environment you use and how you use it.

    That's why my sincere advice to you - don't rely on the infrastructure, you don't own! Either create your own infrastructure (your own execution environments) with all your dependencies or go the way I proposed to you and include the collections you need with your project.



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

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



  • 17.  RE: nim_alt_disk_migration

    Posted Tue October 08, 2024 05:48 AM

    Hi Andrey,

    > "[...] you've lost most of the functionality you could use."

    I think that happened right after we installed AWX... 

    I tend to stay clear of Ansible, but the few times I have written playbooks, I have done so in the DevOps web-GUI. The flaws in YAML and the playbook language are so deep the choice of development environment makes very little difference.

    > "That's why my sincere advice to you - don't rely on the infrastructure, you don't own! Either create your own infrastructure (your own execution environments) with all your dependencies or go the way I proposed to you and include the collections you need with your project."

    We create our own execution environment. I tried to add the collection to my project but it couldn't find "internal". That is still my problem and I cannot guarantee that adding the collection to the EE will fix this.

    Regards,

    Henrik



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 18.  RE: nim_alt_disk_migration

    Posted Tue October 08, 2024 04:53 AM

    Hi,

    I've had a look at the ansible-builder generated Docker image and it is missing the roles, it looks like. Oddly, images over a year old do have them.

    Time to attempt to build a new one.

    Regards,

    Henrik Morsing



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 19.  RE: nim_alt_disk_migration

    Posted Tue October 08, 2024 05:26 AM

    https://quay.io/repository/powerdevops/ansible-power-ee



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

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



  • 20.  RE: nim_alt_disk_migration

    Posted Tue October 08, 2024 05:50 AM

    Thanks, I have passed this on to our AWX SME. Whether we are allowed to trust something like that is questionable.

    Regards,

    Henrik Morsing



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 21.  RE: nim_alt_disk_migration

    Posted Tue October 08, 2024 07:25 AM

    No, I was wrong, it is there:

    [/var/lib/docker/overlay2/b45bb23d3e733f0860b9a235e71a4611a8d7df1db2ab3cffee9ae4738380ba52/diff/usr/share/ansible/collections/ansible_collections/ibm/power_aix]# find . -name "nim_select_target_disk*"
    ./plugins/modules/internal/nim_select_target_disk.py

    I don't know. I still can't see this being anything but a collections bug then.

    Regards,

    Henrik Morsing



    ------------------------------
    Henrik Morsing
    ------------------------------



  • 22.  RE: nim_alt_disk_migration

    Posted Mon October 07, 2024 05:42 AM

    'morning.

    I have raised a bug report now. I can't see this being anything other than the directory structure being wrong in the collection.

    Regards,

    Henrik



    ------------------------------
    Henrik Morsing
    ------------------------------