AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
Expand all | Collapse all

Not able to run clone playbook from ansible automation platform

  • 1.  Not able to run clone playbook from ansible automation platform

    Posted Thu December 14, 2023 08:37 AM

    Hello Team,

    We are not able to run alt_clone play book from ansible automation platform. We are getting following error. It seems to be related to IBM power collection package not able to locate. Would you please help ? 

    ansible-playbook [core 2.15.4]
      config file = /etc/ansible/ansible.cfg
      configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
      ansible python module location = /usr/lib/python3.9/site-packages/ansible
      ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections
      executable location = /usr/bin/ansible-playbook
      python version = 3.9.16 (main, May 31 2023, 12:21:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python3.9)
      jinja version = 3.1.2
      libyaml = True
    Using /etc/ansible/ansible.cfg as config file
    host_list declined parsing /runner/inventory/hosts as it did not pass its verify_file() method
    Parsed /runner/inventory/hosts inventory source with script plugin
    ERROR! couldn't resolve module/action 'ibm.power_aix.alt_disk'. This often indicates a misspelling, missing collection, or incorrect module path.

    The error appears to be in '/runner/project/alt_disk_copy.yml': line 22, column 5, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:

      # Create sysalt on existing altinst_rootvg or old_rootvg disk
      - name: Create sysalt on existing altinst_rootvg or old_rootvg disk
        ^ here

    Playbook content:

    ---
    - name: Alt Disk copy in AIX
      hosts: all
      vars:
          ansible_python_interpreter: /opt/freeware/bin/python3
      strategy: linear
      gather_facts: false


      # Tasks
      tasks:

      # Retrieve disk list
      - name: Retrieve disk list with lspv command
        ansible.builtin.shell:
          cmd: 'lspv | grep -E "_rootvg"|grep -v grep'
        register: pv_list

      # Create sysalt on existing altinst_rootvg or old_rootvg disk
      - name: Create sysalt on existing altinst_rootvg or old_rootvg disk
        ibm.power_aix.alt_disk:
          action: copy
          force: True
          allow_old_rootvg: True
          targets: "{{ lspv_disk[0] }}"
        register: sysalt_run
        when: '"_rootvg" in lspv_disk[2]'
        vars:
          lspv_disk: "{{ item|split() }}"
        with_list: "{{ pv_list.stdout_lines }}"

      # Fail if no sysalt processed
      - name: Fail if no sysalt processed
        ansible.builtin.fail:
          msg: No sysalt have been processed
        when: sysalt_run.changed == false



    ------------------------------
    Manoj Kumar
    ------------------------------


  • 2.  RE: Not able to run clone playbook from ansible automation platform

    Posted Fri December 15, 2023 05:03 AM

    Hi Manoj,

    do you use Ansible Automation Platform 2?

    which execution environment do you use to execute your playbook?

    does the execution environment contain ibm.power_aix collection?

    do you have requirements.yml file with the list of the required collections in your project?



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

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



  • 3.  RE: Not able to run clone playbook from ansible automation platform

    Posted Fri December 15, 2023 05:46 AM

    Hello Andrey,

    Please find the response on below.

    do you use Ansible Automation Platform 2?

    Yes, we are using aap 2. Please find the output below.

     ansible --version
    ansible [core 2.15.4]
      config file = /etc/ansible/ansible.cfg
      configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
      ansible python module location = /usr/lib/python3.9/site-packages/ansible
      ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
      executable location = /usr/bin/ansible
      python version = 3.9.16 (main, May 31 2023, 12:21:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python3.9)
      jinja version = 3.1.2
      libyaml = True

    which execution environment do you use to execute your playbook?

    We use default execution environment. Can we create new execution environment and how we can do that for IBM AIX.

    does the execution environment contain ibm.power_aix collection?

    Please find the collection from controller node.

     ansible-galaxy collection list

    # /root/.ansible/collections/ansible_collections
    Collection      Version
    --------------- -------
    ibm.power_aix   1.7.2
    servicenow.itsm 2.3.0

    do you have requirements.yml file with the list of the required collections in your project?

    Collection list is shared in above command.

    Please check all response above and let us know if we are missing something here. Normal AIX playbook where we don't use IBM power collection we can execute from ansible automation platform.



    ------------------------------
    Manoj Kumar
    ------------------------------



  • 4.  RE: Not able to run clone playbook from ansible automation platform

    Posted Fri December 15, 2023 06:17 AM

    Hi Manoj,

    thank you for your answers. 

    What you've shared are locally installed collections. In AAP2 execution environments are used to execute your playbooks. If you use default execution environment, it doesn't contain any IBM collection and has no idea that you need one.

    You must create a subfolder "collections" in your project and add requirement.yml file there, like:

    ---
    collections:
      - name: ibm.power_aix
      - name: enfence.powerha_aix

    Then it will download the collection from Ansible Galaxy before executing the playbook.

    Or you can create your own execution environment with the collections you need. It takes more time but I think it is better from the development perspective. I did the video a year ago about building execution environments for ibm.power_aix collection - https://youtu.be/HO_Scxhc6Pg



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

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



  • 5.  RE: Not able to run clone playbook from ansible automation platform

    Posted Fri December 15, 2023 07:19 AM

    Thanks Andrey for the update.

    We tried to execute the playbook as you mentioned but still getting the error message. It seems we are missing something.

    Later we will try to create separate execution environment, we will go through that video. But first we wanted to execute the playbook without execution environment as you mentioned in first step.

    [root@ collections]# pwd
    /var/lib/awx/projects/collections
    [root@ collections]# cat requirements.yml

    ---
    collections:
      - name: ibm.power_aix

    screenshot from aap:

    Error after playbook execution

    ansible-playbook [core 2.15.4]
    2
    config file = /etc/ansible/ansible.cfg
    3
    configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
    4
    ansible python module location = /usr/lib/python3.9/site-packages/ansible
    5
    ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections
    6
    executable location = /usr/bin/ansible-playbook
    7
    python version = 3.9.16 (main, May 31 2023, 12:21:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python3.9)
    8
    jinja version = 3.1.2
    9
    libyaml = True
    10
    Using /etc/ansible/ansible.cfg as config file
    11
    host_list declined parsing /runner/inventory/hosts as it did not pass its verify_file() method
    12
    Parsed /runner/inventory/hosts inventory source with script plugin
    13
    ERROR! couldn't resolve module/action 'ibm.power_aix.alt_disk'. This often indicates a misspelling, missing collection, or incorrect module path.
    14
    15
    The error appears to be in '/runner/project/alt_disk_copy.yml': line 20, column 5, but may
    16
    be elsewhere in the file depending on the exact syntax problem.
    17
    18
    The offending line appears to be:
    19
    20
    # Create sysalt on existing altinst_rootvg or old_rootvg disk



    ------------------------------
    Manoj Kumar
    ------------------------------



  • 6.  RE: Not able to run clone playbook from ansible automation platform

    Posted Fri December 15, 2023 08:48 AM

    HI Manoj,

    can you please make a screenshot of your "patch project" definition?



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

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



  • 7.  RE: Not able to run clone playbook from ansible automation platform

    Posted Mon December 18, 2023 04:31 AM

    Hello Andrey,

    Please find the below snippet.



    ------------------------------
    Manoj Kumar
    ------------------------------



  • 8.  RE: Not able to run clone playbook from ansible automation platform

    Posted Mon December 18, 2023 05:37 AM

    Hi Manoj,

    To debug, I sould connect to the container that is created during execution of the playbook to check if you have the correct collections.

    .

    Show container ID with podman
    podman ps -a
    CONTAINER ID  IMAGE                                  COMMAND               CREATED         STATUS         PORTS       NAMES
    b45debbdd9ae  quay.io/thuche/aap/th-ee-image:latest  ssh-agent sh -c t...  20 seconds ago  Up 19 seconds              ansible_runner_204
    .
    Connect to the container
    podman exec -ti b45debbdd9ae /bin/bash
    .
    List the collections.
    ansible-galaxy collection list
    Collection      Version
    --------------- -------
    ibm.power_aix   1.6.4
    openstack.cloud 2.1.0
    .


    ------------------------------
    -----------------------------------
    Thierry Huché
    Power Systems Brand Technical Specialist
    IBM France
    -----------------------------------
    ------------------------------



  • 9.  RE: Not able to run clone playbook from ansible automation platform

    Posted Mon December 18, 2023 06:03 AM

    Hello Thierry,

    Please find the command output. So far I didn't create execution environment.

    [root@hlp10405 AIX]# podman ps -a
    CONTAINER ID  IMAGE                                                                        COMMAND               CREATED      STATUS                  PORTS       NAMES
    b6848a9de043  registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:latest  ansible-inventory...  13 days ago  Exited (0) 13 days ago              elated_goldberg
    af5a69170d80  registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:latest  ansible-inventory...  10 days ago  Exited (0) 10 days ago              brave_goldberg
    da755f286fbf  registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:latest  ansible-inventory...  5 days ago   Exited (0) 5 days ago               relaxed_clarke
    [root@hlp10405 AIX]# ansible-galaxy collection list

    # /root/.ansible/collections/ansible_collections
    Collection      Version
    --------------- -------
    ibm.power_aix   1.7.2
    servicenow.itsm 2.3.0



    ------------------------------
    Manoj Kumar
    ------------------------------



  • 10.  RE: Not able to run clone playbook from ansible automation platform

    Posted Mon December 18, 2023 06:35 AM

    Hi Manoj,

    if you use "manual" SCM type in AAP, change to the directory with your playbooks, in your case it is /var/lib/awx/projects/playbooks

    cd /var/lib/awx/projects/playbooks

    Create ansible.cfg file with the following content:

    [defaults]
    collections_paths=./collections

    If you already have ansible.cfg, just add the path for collections.

    Create a subdirectory for collections:

    mkdir collections

    Add the collections you need to the subdirectory:

    ansible-galaxy collection install ibm.power_aix -p collections

    Make sure that everything is owned by user awx:

    sudo chown -R awx .

    Start the job in AAP. It should work.



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

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



  • 11.  RE: Not able to run clone playbook from ansible automation platform

    Posted Mon December 18, 2023 07:16 AM

    Thanks Andrey, It's working now. I always really appreciate to working with you. Always found my query answer.

    We will try to setup execution environment as well if needed. 



    ------------------------------
    Manoj Kumar
    ------------------------------