Open Source Development

Power Open Source Development

Explore the open source tools and capabilities for building and deploying modern applications on IBM Power platforms including AIX, IBM i, and Linux.


#Power


#Power


#Servers
#Opensource
 View Only
Expand all | Collapse all

Ansible setup on AIX

  • 1.  Ansible setup on AIX

    Posted 03/06/23 09:40 AM

    Hi Team,

    I am trying to setup ansible on AIX, so we have installed ansible and python on AIX servers. On client one of the server having python2 and other having python3. 

    I am not sure how python2 was installed, it seems it was installed manually with all dependency altogether with rpm command.

    Python3 was installed with dnf install command, so everything was installed automatically and updated. Python3 client is not working because having some link with other directory but python2 is working fine which is having link with /usr/bin/ directory. So I am not sure which is the correct way of doing this setup. 

    Would you please help?

    Working client ->

    root@dsmppa003t:/opt/freeware/bin# ls -ltr /usr/bin/python*
    lrwxrwxrwx    1 root     system           35 Aug 25 08:38 /usr/bin/python2.7_64 -> ../../opt/freeware/bin/python2.7_64
    lrwxrwxrwx    1 root     system           39 Aug 25 08:38 /usr/bin/python2.7-config -> ../../opt/freeware/bin/python2.7-config
    lrwxrwxrwx    1 root     system           32 Aug 25 08:38 /usr/bin/python2.7 -> ../../opt/freeware/bin/python2.7
    lrwxrwxrwx    1 root     system           37 Aug 25 08:38 /usr/bin/python2-config -> ../../opt/freeware/bin/python2-config
    lrwxrwxrwx    1 root     system           30 Aug 25 08:38 /usr/bin/python2 -> ../../opt/freeware/bin/python2
    lrwxrwxrwx    1 root     system           36 Aug 25 08:38 /usr/bin/python-config -> ../../opt/freeware/bin/python-config
    lrwxrwxrwx    1 root     system           29 Aug 25 08:38 /usr/bin/python -> ../../opt/freeware/bin/python
    lrwxrwxrwx    1 root     system           39 Aug 25 08:38 /usr/bin/python_64-config -> ../../opt/freeware/bin/python_64-config
    lrwxrwxrwx    1 root     system           32 Aug 25 08:38 /usr/bin/python_64 -> ../../opt/freeware/bin/python_64
    lrwxrwxrwx    1 root     system           40 Aug 25 08:38 /usr/bin/python2_64-config -> ../../opt/freeware/bin/python2_64-config
    lrwxrwxrwx    1 root     system           33 Aug 25 08:38 /usr/bin/python2_64 -> ../../opt/freeware/bin/python2_64
    lrwxrwxrwx    1 root     system           42 Aug 25 08:38 /usr/bin/python2.7_64-config -> ../../opt/freeware/bin/python2.7_64-config

    Non-working client ->

    root@dsmppa001s:/opt/freeware/bin#
    lrwxrwxrwx    1 root     system           10 Jan 09 08:09 python3 -> python3_64
    lrwxrwxrwx    1 root     system           12 Jan 09 08:09 python3.7 -> python3.7_64
    lrwxrwxrwx    1 root     system           13 Jan 09 08:09 python3.7_32 -> python3.7m_32
    lrwxrwxrwx    1 root     system           13 Jan 09 08:09 python3.7_64 -> python3.7m_64
    lrwxrwxrwx    1 root     system           13 Jan 09 08:09 python3.7m -> python3.7m_64
    lrwxrwxrwx    1 root     system           12 Jan 09 08:09 python3_32 -> python3.7_32
    lrwxrwxrwx    1 root     system           12 Jan 09 08:09 python3_64 -> python3.7_64
    lrwxrwxrwx    1 root     system           13 Jan 09 08:09 pyvenv-3.7 -> pyvenv-3.7_64
    lrwxrwxrwx    1 root     system            9 Jan 09 08:09 pyvenv -> pyvenv_64



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

    #AIXOpenSource


  • 2.  RE: Ansible setup on AIX

    Posted 03/06/23 10:27 AM

    I suggest to not to use python2 anymore.

    Python2 is out of support.

    One thing I can think of if you module looks for /usr/bin/python then they will find it for python2 installed on AIX.

    AIX toolbox python2 delivers /usr/bin/python link.

    So if that is the case then you need to set correct python in your module for python3 or create sylink in your AIX.

    But please be careful when creating symlink by not breaking existing code.

     

    Thanks,

     

    Sanket Rathi

     






  • 3.  RE: Ansible setup on AIX

    Posted 03/07/23 03:12 AM

    Hi Manoj,

    Ansible looks for python interpreter in /usr/bin/python. Old RPM packages created a symlink in /usr/bin for python binaries. New RPM packages don't do it anymore. Because you didn't provide any error message, I can suppose that this is the reason for your failure - the failing server doesn't have /usr/bin/python.

    The choices you have:

    • create symlinks in /usr/bin. I wouldn't recommend unless you know what you're doing.
    • add a variable ansible_python_interpreter: /opt/freeware/bin/python3 in your playbooks. This is my favourite way of solving the problem.
    • add a global configuration interpreter_python = /opt/freeware/bin/python3 in /opt/freeware/etc/ansible/ansible.cfg on your Ansible controller node.

    More about Python discovery in Ansible you can read here - https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html



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

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



  • 4.  RE: Ansible setup on AIX

    Posted 03/09/23 05:13 AM

    Thanks Andrey for the update, we are checking this.



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



  • 5.  RE: Ansible setup on AIX

    Posted 03/13/23 08:07 AM

    Hello Andrey,

    I try to update ansible.cfg with below content. But still getting same error. Can you please check whether added variable is correct or not? Anything else we need to do.

    This is my ansible.cfg file, in lieu of discovered_interpreter_python I used ansible_python_interpreter but same issue. I also try to use this ansible_python_interpreter: /opt/freeware/bin/python3 

     cat ansible.cfg
    [defaults]
    inventory=/home/automation/ansible/systemfiles/inventory
    log_path=/home/automation/ansible/systemfiles/ansible_logs
    discovered_interpreter_python=/opt/freeware/bin/python3
    forks=10
    interpreter_python=auto_silent

    [privilege_escalation]
    become=true
    become_user=root
    become_method=sudo



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



  • 6.  RE: Ansible setup on AIX

    Posted 03/13/23 09:54 AM

    You can do "ansible-config dump | grep -i interpreter" and share the output here. 



    ------------------------------
    Ayappan P
    ------------------------------



  • 7.  RE: Ansible setup on AIX

    Posted 03/14/23 05:27 PM

    I think right now you need – Red hat linux server with Ansible first – then from this you can use ansible play book on AIX client. Is this what you are doing and have problem on AIX server.






  • 8.  RE: Ansible setup on AIX

    Posted 03/16/23 12:23 PM

    Yes we used ansible controller node on Linux and try to run commands on AIX. Now it is working after Andrey recommended



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



  • 9.  RE: Ansible setup on AIX

    Posted 03/14/23 05:40 PM

    Hello Manoj,

    please try:

    interpreter_python = /opt/freeware/bin/python3

    instead of discovered_interpreter_python=/opt/freeware/bin/python3



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

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



  • 10.  RE: Ansible setup on AIX

    Posted 03/16/23 12:22 PM

    Thanks Andrey, it is working now. Really appreciate to working with all of you guys. 

    Further addition to that, in this scenario we have Linux controller node and agent are AIX and Linux both. But we use AIX controller node how we can setup the same thing. We have installing ansible with python3 on one of AIX node. We used same dnf method to install all packages. Now when we are running ansbile -m ping all command, it is giving below error. 

    root@server3:/# ansible -m ping all
    Server1 | UNREACHABLE! => {
        "changed": false,
        "msg": "Failed to connect to the host via ssh: root@server1: Permission denied (publickey,password,keyboard-interactive).",
        "unreachable": true
    }
    server2 | UNREACHABLE! => {
        "changed": false,
        "msg": "Failed to connect to the host via ssh: root@server2: Permission denied (publickey,password,keyboard-interactive).",
        "unreachable": true
    }
    localhost | SUCCESS => {
        "changed": false,
        "ping": "pong"
    }
    server3| SUCCESS => {
        "changed": false,
        "ping": "pong"
    }



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



  • 11.  RE: Ansible setup on AIX

    Posted 03/17/23 04:51 AM

    Glad to hear that it works.

    As @Stephen Ulmer wrote, if you have different classes of clients with different paths to python, it is better to define path to python in inventory or in playbooks. You have two different classes - Linux boxes and AIX boxes. Your inventory could look like:

    linux1 ansible_python_interpreter=/usr/bin/python3
    linux2 ansible_python_interpreter=/usr/bin/python3
    aix1 ansible_python_interpreter=/opt/freeware/bin/python3
    aix2 ansible_python_interpreter=/opt/freeware/bin/python3

    Your error "Failed to connect to the host via ssh: root@server2: Permission denied (publickey,password,keyboard-interactive)." usually means that you didn't exchange SSH keys between your Ansible controller node and the managed node (server2).

    Try to execute on the Ansible controller node:

    ssh-copy-id root@server2

     

    It will copy your public key (if you have it) from the Ansible controller node to the managed node server2.



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

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



  • 12.  RE: Ansible setup on AIX

    Posted 03/17/23 11:39 AM

    Thanks Andrey, we get to know that Ansible controller node can't be setup on AIX, it has to be Linux only. So we will be working on it. 



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



  • 13.  RE: Ansible setup on AIX

    Posted 03/17/23 02:41 PM
    Just in case you haven't run across it yet, you will need a helper program called sshpass if you want to use Ansible with ssh password authentication.

    It is much better to use ssh keys, but sometimes you may need to use a password during bootstrapping of Ansible on the node.

    -- 
    Stephen Ulmer

    Sent from a mobile device; please excuse auto-correct silliness.





  • 14.  RE: Ansible setup on AIX

    Posted 03/17/23 09:44 AM

    Right now there is no AIX controller node for Ansible Only Linux OS controller node.  You use AIX as client of Ansible controller on Linux OS that is all. AIX Ansible controller will not work.






  • 15.  RE: Ansible setup on AIX

    Posted 04/06/23 03:32 AM

    Hello Team,

    One thing would like to know that once we run ./dnf_aixtoolbox.sh is gives below 3 option (flag) for installation. So which method would you prefer to use. We have to install across the AIX servers. 

    and How we can remediate any future vulnerability or update related to ansible on AIX?

    Usage: dnf_aixtoolbox.sh <-d> <-y> <-n> -?
     
          -d    Install and setup dnf if yum is not installed.
                yum command will not be available only dnf command can be used.
          -y    Installs dnf, and updates yum3 to dnf yum4 if yum3 is installed.
                If no yum3 is installed then dnf and yum4 will be installed.
                yum command will also be available along with dnf.
          -n    Install dnf where both yum and dnf can coexist if yum is installed already.
                This is not a recommended option.



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



  • 16.  RE: Ansible setup on AIX

    Posted 04/06/23 04:25 AM

    Hi Manoj,

    I personally almost always use -y. I like to have a compatibility layer to yum. In many different documentation or presentations you still can find references to yum and it is easier for me if I have yum command as an alias to dnf. The same does Red Hat Enterprise Linux, where you have both yum and dnf commands. 

    Regarding updates of Ansible on AIX. I use Ansible from AIX Toolbox. It means if there is a new version of Ansible available, I can always update it using either:

    dnf -y update


    or Ansible itself:

    - hosts: all
      gather_facts: no
      vars:
        ansible_python_interpreter: /opt/freeware/bin/python3
    
      tasks:
      - name: update all packages
        dnf:
          name: '*'
          state: latest
    

    ansible-playbook -c local -i localhost, dnf-update.yml


    I hope IBM will publish a new Ansible version if there are vulnerabilities in the existing one ;-)



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

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



  • 17.  RE: Ansible setup on AIX

    Posted 04/06/23 08:41 AM

    Thanks Andrey for the update.



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



  • 18.  RE: Ansible setup on AIX

    Posted 03/13/23 08:52 AM

    One thing would like to add the controlled node here is Linux. 



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



  • 19.  RE: Ansible setup on AIX

    Posted 03/13/23 10:30 AM
    Okay, please be very specific about where you are invoking ansible, and what you are managing...

    ansible.cfg mostly configures things on the control/management node. If you have different interpreter paths on different classes of managed nodes, you should change those paths by setting variables in the inventory.

    -- 
    Stephen L. Ulmer
    Enterprise Architect
    Mainline Information Systems






  • 20.  RE: Ansible setup on AIX

    Posted 05/10/23 12:17 PM

    We installed python on few servers and it is working fine on few servers but today when we try to install it on 2 or more servers. It's not working.

    Method which we used for installation on AIX.
    First download the dnf script and copy it to client.
    Then run ./dnf_aixtoolbox.sh -d from the client. 
    After that command successfully executed, we have updated the packages to latest level with ./dnf update command.
    copy controller node public key into client authorized keys. 

    After that I tried to run ansible -m ping all but it gives below error. Could you please suggest what is next steps. 

    [root@hld10297 AIX]# ansible -m ping all
    dsmjca71img | UNREACHABLE! => {
        "changed": false,
        "msg": "Failed to connect to the host via ssh: Shared connection to dsmjca71img closed.",
        "unreachable": true
    }
    [root@hld10297 AIX]# cat inventory
    dsmjca71img
    [root@hld10297 AIX]# cat ansible.cfg
    [defaults]
    inventory=/home/automation/ansible/AIX/inventory
    log_path=/home/automation/ansible/AIX/ansible_logs
    interpreter_python=/opt/freeware/bin/python3
    forks=10
    #interpreter_python=auto_silent
     
    [privilege_escalation]
    become=true
    become_user=root
    become_method=sudo




    Regards
    Manoj




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



  • 21.  RE: Ansible setup on AIX

    Posted 05/10/23 12:46 PM

    Do ping test from ansible to client – from OS only (if redhat linux to AIX client with ansible)

    Do traceroute from ansible to client

     

    If both works then problem is some where else.






  • 22.  RE: Ansible setup on AIX

    Posted 05/11/23 02:10 AM

    Hi!

    dsmjca71img | UNREACHABLE! => {
        "changed": false,
        "msg": "Failed to connect to the host via ssh: Shared connection to dsmjca71img closed.",
        "unreachable": true
    }

    First thing I would investigate is, if you actually connect to that host via ssh passwordless.


    Best regards,
      Alexander



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



  • 23.  RE: Ansible setup on AIX

    Posted 05/12/23 02:59 AM

    Hi again!

    From your reply I got, that you can ping as well as ssh works without problems.

    Then I would suggest to check whether your configured python interpreter works, and then whether your become method "sudo" works.

    So best try from your ansible host try to log in via ssh:
    ssh dsmjca71img
    Then try to start the python interpreter you configured. It should look similar to:
    root@dsmjca71img:/root # /opt/freeware/bin/python3
    Python 3.7.9 (default, Mar 30 2021, 00:48:16) 
    [GCC 8.3.0] on aix7
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 

    And if that works, try to run sudo, as you configured that as your become method. For example by running sudo -l:
    root@dsmjca71img:/root # sudo -l
    User root may run the following commands on dsmjca71img:
        (ALL) NOPASSWD: ALL

    Note:  I don't think you require a become method, if you connect as root anyway. But as you have it configured, I guess it might cause the above failure.


    If ssh, python and sudo works, your ansible should work.  If it still doesn't work, I'm running out of ideas, what might be the problem.


    Best regards,
      Alexander





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



  • 24.  RE: Ansible setup on AIX

    Posted 05/12/23 07:06 AM

    Hi Manoj,

    I don't know why your replies don't show up here, so I'm taking the liberty to copy and paste this from your e-mail:

    But this is the cause of your ansible error:

    root@dsmjcanim01:/# oslevel -s
    7200-05-05-2246
    root@dsmjcanim01:/# ls -ld /opt/freeware/bin/python3
    lrwxrwxrwx    1 root     system           10 May 10 10:28 /opt/freeware/bin/python3 -> python3_64
    root@dsmjcanim01:/# /opt/freeware/bin/python3
    exec(): 0509-036 Cannot load program /opt/freeware/bin/python3 because of the following errors:
            0509-130 Symbol resolution failed for /opt/freeware/lib64/libpython3.7m.so because:
            0509-136   Symbol _GLOBAL__AIXI_libintl_so (number 4) is not exported from
                       dependent module /usr/lib/libintl.a[libintl.so.8].
            0509-136   Symbol _GLOBAL__AIXD_libintl_so (number 5) is not exported from
                       dependent module /usr/lib/libintl.a[libintl.so.8].
            0509-192 Examine .loader section symbols with the
                     'dump -Tv' command.

    The python isntallation on your client is not working properly.  I recommend that you post your remaining message about the installed python packages here as well, as we are now reaching areas of packaging and shared libraries, were I can't help you much.


    Best regards,
      Alexander





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



  • 25.  RE: Ansible setup on AIX