IBM / ansible-for-i

the tool is to provide several customized modules for Ansible to manage IBM i systems.
GNU General Public License v3.0
55 stars 51 forks source link

Ansible Automation Platform 2.x execution environments #133

Closed aklyachkin closed 2 years ago

aklyachkin commented 2 years ago

Ansible Automation Platform 2.x provides the new way of execution of playbooks by using execution environments (https://docs.ansible.com/automation-controller/latest/html/userguide/execution_environments.html). An execution environment is a container image with all required collections.

Unfortunately it doesn't work with ibm.power_ibmi collection.

execution-environment.yml:

---
version: 1
dependencies:
  galaxy: requirements.yml

requirements.yml:

---
collections:
  - name: ibm.power_ibmi

Building of the execution environment:

$ ansible-builder build
...showing last 20 lines of output...
+ '[' -f bindep.txt ']'
+ bindep -l newline
+ sort
+ '[' centos == centos ']'
+ bindep -l newline -b epel
+ sort
+ grep -Fxvf /output/bindep/run.txt /output/bindep/stage.txt
+ true
+ rm -rf /output/bindep/stage.txt
++ bindep -b compile
++ true
+ compile_packages=python
+ '[' '!' -z python ']'
+ /usr/bin/dnf install -y python
CentOS Stream 8 - Extras common packages        9.0 kB/s | 3.1 kB     00:00
No match for argument: python
There are following alternatives for "python": python2, python36, python38, python39
Error: Unable to find a match: python
[3/3] STEP 1/5: FROM quay.io/ansible/ansible-runner:latest
Error: error building at STEP "RUN assemble": error while running runtime: exit status 1

An error occured (rc=125), see output line(s) above for details.

All other IBM Power collections (ibm.power_*) work without any problems. The problem exist only with ibm.power_ibmi collection. I didn't find anything in the source code, but the python dependency is somewhere declared wrong.

changlexc commented 2 years ago

I think the key maybe bindep in power_ibmi. power_ibmi only support python3.6 and above. What's the python version on your system, I think you may need to use python3(or python3.x) 's pip3 to install the ansible-builder to let the ansible-builder run as python3.

changlexc commented 2 years ago

I run complete without issue, this is my files, execution-environment.yml:

---
version: 1
dependencies:
  galaxy: requirements.yml
  system: bindep.txt

additional_build_steps:
  prepend: |
    RUN pip3 install --upgrade pip setuptools

requirements.yml

---
version: 1
dependencies:
  galaxy: requirements.yml
  system: bindep.txt

additional_build_steps:
  prepend: |
    RUN pip3 install --upgrade pip setuptools

bindep.txt

-# This is a cross-platform list tracking distribution packages needed by this collection;
# see https://docs.openstack.org/infra/bindep/ for additional information.

python >=3.6,<=3.8

You may need to first clean up the old one in your output context directory, for example, for me, is /Users/changle/context

aklyachkin commented 2 years ago

thank you for the response. what type of system do you use?

as for me it is RHEL 8.5:

cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.5 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.5"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.5 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/red_hat_enterprise_linux/8/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.5
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.5"

Python v3.6.8:

# python3 --version
Python 3.6.8

Ansible-builder v1.0.1:

# ansible-builder --version
1.0.1

Even with your configuration file it fails. Ansible Builder uses CentOS8-based image to build the environment:

quay.io/ansible/ansible-builder                                       latest      b0348faa7f41  2 months ago   779 MB

CentOS8 doesn't have python package! As the error message says, it has only python2, python36, python38, python39:

+ /usr/bin/dnf install -y python
CentOS Stream 8 - Extras common packages         30 kB/s | 4.0 kB     00:00
No match for argument: python
There are following alternatives for "python": python2, python36, python38, python39

bindep.txt doesn't help at all, because bindep.txt comes somehow with the collection ibm.power_i. You can test it by just installing the collection:

$ mkdir coll
$ ansible-galaxy collection install -p ./coll ibm.power_ibmi
$ cat coll/ansible_collections/ibm/power_ibmi/bindep.txt
# This is a cross-platform list tracking distribution packages needed by this collection;
# see https://docs.openstack.org/infra/bindep/ for additional information.

python >=3.6,<=3.8

the file causes the problem. it doesn't exist in any other collection.

P.S. you didn't post your requirements.yml. Do you download the collection from galaxy or from github? I can confirm, that the problem exists, when I use galaxy version of the collection, and everything works fine with the Github version.

changlexc commented 2 years ago

My requirement.yml is same as yours, so I don't post here.

I am using Mac to run the ansible-builder. I don't think it has any related with the system that you're running, because it actually docker to build the image, I think the CentOS is controlled by Docker build.

Here is the output from my terminal:

bash-3.2$ ansible-builder build
Running command:
  docker build -f context/Dockerfile -t ansible-execution-env:latest context
Complete! The build context can be found at: /Users/changle/context

And I can found the image in my docker resp

image

The important is you need to cleanup the build context directory after you changed the execution-environment.yml. I post all my configuration again:

bash-3.2$ cat requirements.yml
---
collections:
  - name: ibm.power_ibmi
bash-3.2$ cat execution-environment.yml
---
version: 1
dependencies:
  galaxy: requirements.yml
  system: bindep.txt

additional_build_steps:
  prepend: |
    RUN pip3 install --upgrade pip setuptools
bash-3.2$ cat bindep.txt
-# This is a cross-platform list tracking distribution packages needed by this collection;
# see https://docs.openstack.org/infra/bindep/ for additional information.

python >=3.6,<=3.8
aklyachkin commented 2 years ago

Thank you! I tested now on several different systems (but all RHEL8) and found the problem and the working configuration.

TL;DR - the magic is the first minus in bindep.txt. It works with it and it doesn't work without it or without bindep.txt.