Automation with Power

Automation with Power

Learn about using IBM Power automation tools to automate repetitive tasks and quickly identify and resolve production issues. Start a discussion thread - share your experiences by writing a blog - and stay up to date by browsing the content library. 

 View Only
  • 1.  ibm.power_hmc complaining about missing lxml from AAP 2.5

    Posted 29 days ago

    Could use your all's help again, pretty please.  Can't seem to figure this out.

    Simple play, works fine when run with ansible-playbook:

    ---
    - name: Grab the WWN's of the LPARs on a HMC
      hosts: dsshmcs
      connection: local
      gather_facts: false
        - name: Capture LPAR Data
          ibm.power_hmc.powervm_lpar_instance:
            hmc_host: "{{ src_hmc }}"
            hmc_auth: "{{ hmc_auth }}"
            system_name: "{{ src_system_name }}"
            vm_name: "{{ lpar_name }}"
            state: facts
            advanced_info: true
          register: lpar_info
          connection: local
    When running the same playbook from AAP 2.5, using a custom execution environment, it complains about missing lxml. Yes, the execution environment includes lxml and I've tried lxml at version 4.9.2 and 5.4.0.  I went and added some more troubleshooting items into my playbook, that clearly show me that lxml exists:

      tasks:
        - name: Run a PIP3 command
          ansible.builtin.pip:
            name: lxml
            state: present
            executable: pip3

        - name: List all PIP3 packages
          ansible.builtin.command: pip3 list
          register: pip_list
          changed_when: pip_list.rc != 0

        - name: Show PIP3 packages
          ansible.builtin.debug:
            msg: "{{ pip_list.stdout_lines }}"

        - name: Capture LPAR Data
          ibm.power_hmc.powervm_lpar_instance:
            hmc_host: "{{ src_hmc }}"
            hmc_auth: "{{ hmc_auth }}"
            system_name: "{{ src_system_name }}"
            vm_name: "{{ lpar_name }}"
            state: facts
            advanced_info: true
          register: lpar_info
          connection: local
     And still, it complains:
    Requirement already satisfied: lxml in /usr/local/lib64/python3.11/site-packages (5.4.0)
    msg:
      - Package                   Version
      - '------------------------- ---------'
    ...
      - lockfile                  0.12.2
      - lxml                      5.4.0
      - MarkupSafe                2.1.5
    ... _ansible_verbose_always: true _ansible_no_log: false changed: false
    msg: 'Error: Missing prerequisite lxml package. Hint pip install lxml'
    invocation:
      module_args:
    Running out of things to try. Any guidance is certainly appreciated.


    ------------------------------
    Mark Steele
    Guru
    Direct Systems Support
    San Diego CA
    ------------------------------


  • 2.  RE: ibm.power_hmc complaining about missing lxml from AAP 2.5

    Posted 28 days ago

    Hi Mark

    I include it in my bindep.txt

    libxml2-devel
    libxslt-devel
    python3-devel
    gcc
    python3-lxml

    Regards

    Ian



    ------------------------------
    Ian Bellinfantie
    ------------------------------



  • 3.  RE: ibm.power_hmc complaining about missing lxml from AAP 2.5

    Posted 28 days ago
    Edited by Mark Steele 23 days ago

    Thanks Ian, I was missing python3-lxml, so added it to bindep.txt and that EE now works. I kept adding it and validating it via pip, which obviously doesn't work. That's some reading I'll have to do to understand that difference.

    So for anyone else's benefit who might run into this, this is what my EE build looks like.

    execution-environment:

    ---
    version: 3

    build_arg_defaults:
      ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: '--pre'

    images:
      base_image:
        name: registry.redhat.io/ansible-automation-platform-25/ee-minimal-rhel8@sha256:7d2df3be0924c78258d974dde537b0a1654e1c4abbcc5f86916502eb89cb7949

    dependencies:
      galaxy: requirements.yml
      python:
        - six
        - pyds8k
        - pip
        - requests
        - jmespath
      system: bindep.txt

    options:
      package_manager_path: /usr/bin/microdnf

    additional_build_steps:
      prepend_base:
        - RUN echo This is a prepend base command!
      prepend_galaxy:
        # Environment variables used for Galaxy client configurations
        - ENV ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1
        - ENV ANSIBLE_GALAXY_SERVER_LIST=galaxy
        - ENV ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_URL=https://*************/pulp_ansible/galaxy/rh-certified/
        - ARG ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_TOKEN=*********************************
        - ENV ANSIBLE_GALAXY_SERVER_GALAXY_URL=https://galaxy.ansible.com/

      prepend_final:
        - RUN whoami
        - RUN cat /etc/os-release
      append_final:
        - RUN echo This is a post-install command!
        - RUN ls -la /etc
        - RUN microdnf upgrade

    Then in bindep.txt:

    gcc
    python3-devel
    python3-psutil
    python3-pip
    libxml2-devel
    libxslt-devel
    python3-lxml
    python3-requests
     python3-jmespath

    And finally my requirements.txt:

    ---
    collections:
      - name: ibm.power_hmc
      - name: ibm.power_aix
      - name: markuman.nextcloud
      - name: ibm.spectrum_virtualize
      - name: ibm.ds8000
      - name: brocade.fos
      - name: community.general

    Thanks again for all the help and insights.

    6/16/25 - I've made some additional changes and additions of further requirements I found for some of the IBM collections.  What was causing me so much confusion, is that by default, Ansible does not use /usr/bin/python3 as the interpreter in a EE, so those PIP installed packages aren't found. It's using /usr/libexec/platform-python-3*.  Here's some details on that. 

    https://www.reddit.com/r/ansible/comments/rb80pv/execution_environments_and_pip_module_locations/



    ------------------------------
    Mark Steele
    Guru
    Direct Systems Support
    San Diego CA
    ------------------------------



  • 4.  RE: ibm.power_hmc complaining about missing lxml from AAP 2.5

    Posted 28 days ago

    Hi, Mark!

    Does your minimal test case work in one of the default EEs? If so which one?

    You're really asking "what is wrong with my EE", but you told us literally nothing about the EE. We don't know, for example, if it contains the libraries that lxml depends on.

    When promoting work from the CLI to AAP, have you considered using ansible-navigator? This will let you use the EE in a tighter development loop, without needing so much AAP-foolery. This is a good way to test if your EE works and compare the results from two EEs.

    Also, be aware that a "Red Hat Certified Collection" has no requirement to have ever been tested on the platform for which it is certified.



    ------------------------------
    --
    Stephen Ulmer
    Enterprise Architect
    Mainline Information Systems
    ------------------------------