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
  • 1.  dnf works, but unable to import dnf python module

    Posted Wed November 22, 2023 09:32 AM
      |   view attached

    Hi!

    I recently installed dnf on several AIX 7.2 servers using the power_aix_bootstrap ansible role as follows:

     - import_role:
          name: power_aix_bootstrap
        vars:
          pkgtype: "dnf"
          download_dir: "~"
          target_dir: "/tmp/.ansible.cpdir"
        environment:
          https_proxy: http://{{ AIX_Package_Proxy_User }}:{{ AIX_Package_Proxy_Pass }}@osde01proxy:8080/

    In a second step we add the the proxy configuration to the dnf.conf.  And in it seems to work.  From the command line I have no issues running dnf. For example here a screenshot of dnf installing sudo.

    However, what does not work is installing packages via the dnf ansible module. I tried the following:

    • name: Install the latest version of our standard tools
          ansible.builtin.dnf:
            conf_file: /opt/freeware/etc/dnf/dnf.conf
            name:
              - sudo
            state: latest
          environment:
            PATH: /opt/freeware/bin:{{ ansible_env.PATH }}

    That results in the following:

    t seems, that python can't import the dnf module:

    I found DNF failed to run on AIX 7.2 , installing libggc8 and libstdc++8 didn't solve my problems. I see in the failed ansible output, recommends to verify the output of dump -Tv, but that doesn't tell me much. 

    Any ideas on how to solve that problem?

    Best regards,

      Alexander



    ------------------------------
    Alexander Reichle-Schmehl
    ------------------------------

    Attachment(s)

    txt
    dump.txt   473 KB 1 version


  • 2.  RE: dnf works, but unable to import dnf python module

    Posted Wed November 22, 2023 10:39 AM

    Ah, the duelling python problem. dnf requires the ansible_interpreter to be /opt/freeware/bin/python3. So everytime you call the dnf module, you have to tell it which interpreter to use. In this exampe using your code, I've added a conditional variable which uses the release of AIX to decide which one to point to.

    name: Install the latest version of our standard tools
        ansible.builtin.dnf:
          conf_file: /opt/freeware/etc/dnf/dnf.conf
          name:
            - sudo
          state: latest
        vars:
          ansible_python_interpreter: "{{ '/opt/freeware/bin/python3' if ansible_distribution_version == '7.3' else '/opt/freeware/libexec/python3' }}"

    You can check if your python has the dnf module like this:

    root@aix73host# /usr/bin/python3
    Python 3.9.18 (main, Sep 19 2023, 04:57:07)
    [GCC 10.3.0] on aix
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import dnf
    Traceback (most recent all last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'dnf'
    >>> <ctrl-d> to exit
    
    root@aix73host# /opt/freeware/bin/python3
    Python 3.9.18 (main, Sep 19 2023, 04:57:07)
    [GCC 10.3.0] on aix
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import dnf
    >>> <ctrl-d> to exit



    ------------------------------
    Mario
    ------------------------------



  • 3.  RE: dnf works, but unable to import dnf python module

    Posted Thu November 23, 2023 03:54 AM

    Thanks for the hint!

    While I was about to reply, that we are using AIX 7.2 and have no other python intepreter installed (yet) and we do set the python interpreter to the one in /opt/freeware we seem to run in the 64/32 bit python issue also discussed here before.

    So, for AIX 7.2 setting the python inteprter to /opt/freeware/bin/python3 will use the 64 bit pythoin version. Using /opt/freeware/libexec/python3 sets it to the 32 bit version, which does work with the dnf modul!

    So this one doesn't work:

    But this one does:

    Many thanks again!



    ------------------------------
    Alexander Reichle-Schmehl
    ------------------------------



  • 4.  RE: dnf works, but unable to import dnf python module

    Posted Tue December 05, 2023 08:00 AM

    Hello @Alexander Reichle-Schmehl ! CC: @Andrey Klyachkin (because you helped me as well with   https://community.ibm.com/community/user/power/discussion/ansible-and-dnf , thanks for that!)

    Thanks for the information, I´ve had the same issue and solved it via the libexec entry.

    What still doesn´t work is actually installing a package, because I get:

       - name:  If not installed or upgradeable, install or upgrade, even with dependencies!
         ansible.builtin.dnf:
           name: rsync
           conf_file: /opt/freeware/etc/dnf/dnf.conf
           update_only: false
           validate_certs: false
           state: latest
           update_cache: true

    -->

    failed: {
        "changed": false,
        "failures": [
            "No package rsync available."
        ],
        "msg": "Failed to install some of the specified packages",
        "rc": 1,
        "results": []
    }

    When I do it via ansible.builtin.shell it works:

    done | stdout: Last metadata expiration check: 0:19:53 ago on Tue Dec  5 13:09:25 MET 2023.
    Dependencies resolved.
    ================================================================================
     Package         Architecture  Version              Repository             Size
    ================================================================================
    Installing:
     rsync           ppc           3.2.7-1              AIX_Toolbox           867 k
    Installing dependencies:
     lz4             ppc           1.9.3-1              AIX_Toolbox           390 k

    Transaction Summary
    ================================================================================
    Install  2 Packages

    Total download size: 1.2 M
    Installed size: 3.3 M
    Downloading Packages:
    (1/2): lz4-1.9.3-1.aix6.1.ppc.rpm               273 kB/s | 390 kB     00:01    
    (2/2): rsync-3.2.7-1.aix7.1.ppc.rpm             469 kB/s | 867 kB     00:01    
    --------------------------------------------------------------------------------
    Total                                           678 kB/s | 1.2 MB     00:01     
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                        1/1 
      Installing       : lz4-1.9.3-1.ppc                                        1/2 
      Installing       : rsync-3.2.7-1.ppc                                      2/2 
      Running scriptlet: rsync-3.2.7-1.ppc                                      2/2 
    rsync version effective # 3.2.7 default rsync daemon config is now /opt/freeware/etc/rsyncd.conf

      Verifying        : lz4-1.9.3-1.ppc                                        1/2 
      Verifying        : rsync-3.2.7-1.ppc                                      2/2 

    Installed:
      rsync-3.2.7-1.ppc                       lz4-1.9.3-1.ppc                      

    Complete!


    What am I doing wrong :D ?

    Thanks,

    with kind regards,

    Steve



    ------------------------------
    Stephan Dietl
    ------------------------------



  • 5.  RE: dnf works, but unable to import dnf python module

    Posted Wed December 06, 2023 07:13 AM

    Hello!

    Answering myself here, I´ve now found another posting where my problem is described:

    https://community.ibm.com/community/user/power/discussion/issue-with-dnf-and-python-and-ansible

    It seems that so far no Issue has been raised on the Ansible Github page, I´ll have a look how to do that :) but also CC: to @Christophe Gehin and @Ayappan P just in case!

    Thanks,

    With kind regards,

    Steve



    ------------------------------
    Stephan Dietl
    ------------------------------



  • 6.  RE: dnf works, but unable to import dnf python module

    Posted Wed December 06, 2023 08:35 AM

    Hello!

    I´ve opened https://github.com/ansible/ansible/issues/82365 for that!

    Ciao,

    Steve



    ------------------------------
    Stephan Dietl
    ------------------------------



  • 7.  RE: dnf works, but unable to import dnf python module

    Posted Wed December 06, 2023 10:06 AM

    Hello!

    Has already been solved by additionally adding "PATH" environment variable into the task:

    https://github.com/ansible/ansible/issues/82365#issuecomment-1842926126

    HTH,

    Ciao,

    Steve



    ------------------------------
    Stephan Dietl
    ------------------------------