Open robinsg opened 3 years ago
After setting up open source on IBM i, yum is not added to $PATH by default.
Below is a workaround
‘’‘ tasks:
file: src: /Qopensys/pkgs/bin/yum dest: /usr/bin/yum state: link
name: set python interpreter to python 2 temporarily to run yum set_fact: ansible_python_interpreter_in_inventory: "{{ansible_python_interpreter}}"
name: set python interpreter to python 2 temporarily to run yum set_fact: ansible_python_interpreter: "/Qopensys/pkgs/bin/python2"
name: Install the latest version of itoolkit yum: name: python3-itoolkit state: latest
name: set python interpreter to python 2 temporarily to run yum set_fact: ansible_python_interpreter: "{{ansible_python_interpreter_in_inventory}}" ’‘’
Thanks for that.
I have managed to get around this by doing the following:
- name: Update packages
yum:
name: "*"
state: present:
use_backend: yum
environment:
PATH: "/QOpenSys/pkgs/bin://QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin"
The issue is that /QOpenSys/pkgs/bin is not in that path when Ansible connects to the system. When I log in via ssh /etc/profile is executed which prepends /QOpenSys/pkgs/bin to the PATH.
How can I add /QOpenSys/pkgs/bin to the path of all sessions?
I tried changing the PASE_PATH environment variable at the *SYS level but it didn't help.
Ansible isn't really doing things through the shell, it's transferring modules and executing scripts that it transfers, not using a login shell. It's not a continuous shell environment basically, nor is it logging in and typing commands and things.
In your cases, you may set an environment in your playbook, for example,
- name: Miscs
hosts: all
gather_facts: false
collections:
- ibm.power_ibmi
environment:
PATH: "/QOpenSys/pkgs/bin://QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin"
tasks:
- name: try yum
command: yum --help
- name: try rpm
command: rpm --help
Just started using Ansible-on-i and ran into this issue. I got it working with @LiJunBJZhu solution to temporary switch python3 with python2 combined with @robinsg use_backend=yum
I'm not sure if this an Ansible for i or an IBM Open Source issue but I thought I'd start here.
Issue:
I'm running a number of playbooks using core and power_ibmi modules which work fine, except yum or package.
I have a role which uses yum to update all packages and another to install some additional packages. When these run I get an error message saying that yum is not found and that ansible.pkg_mgr is unknown.
If I log in to the LPAR using ssh and run yum install vim -y this works fine.
The yum executable is located in /QOpenSys/pkgs/bin and this is in PATH, as you can see below.
The LPARs have V7R3 installed with the latest PTFs and the latest repo updates.
How do I set yum as the ansible.pkg_mgr?
Attempts to workaround I noticed that Ansible was executing /bin/sh on the LPAR so I have overridden this with ansible_shell_executable=/QOpenSys/pkgs/bin/bash.
I also noticed that /QOpenSys/pkgs/bin wasn't in the PATH when I ran an ad-hoc command or playbook. I added a PATH environment variable to the playbook, see the path shown below.
I've also tried using the package module specifying use: yum
Neither of these three made any difference.
Recreate the issue
$ ansible mylpar -m yum -a "name=vim state=present" -vvvv
Output
Ansible Facts