Skip to content

Provide a way to replicate Ansible/Python environment of Docker image #4237

@dalbani

Description

@dalbani

Feature Request

Describe the problem you need a feature to resolve.

In order to run the ansible-operator locally for development purposes (with make run), one has to setup an Ansible / Python (virtual) environment.
Ideally, it would have to be identical to the one found in the Docker image quay.io/operator-framework/ansible-operator which is then deployed on production.
However, due to how the Python dependencies are declared in the Dockerfile, it is difficult to do so accurately.
See https://github.com/operator-framework/operator-sdk/blob/master/images/ansible-operator/Dockerfile#L19:

RUN yum clean all && rm -rf /var/cache/yum/* \
  && yum -y update \
  && yum install -y libffi-devel openssl-devel python36-devel gcc python3-pip python3-setuptools \
  && pip3 install --no-cache-dir \
    ipaddress \
    ansible-runner==1.3.4 \
    ansible-runner-http==1.0.0 \
    openshift~=0.10.0 \
    ansible~=2.9 \
    jmespath \
  && yum remove -y gcc libffi-devel openssl-devel python36-devel \
  && yum clean all \
  && rm -rf /var/cache/yum

The first solution is of course to track down the Dockerfile on Github and copy/paste the pip3 install ... command locally.
It works, but it's not very elegant and requires manual work which would be tricky to automate reliably.

Then I thought that I could simply extract the list of installed Python packages with pip install $(docker run --rm -ti --entrypoint bash quay.io/operator-framework/ansible-operator:v1.2.0 -c 'pip3 freeze').
But I ran into the problem of system packages: the freeze list also contains Python packages installed system-wide via YUM.
Which means I ended up getting gpg==1.13.1 in the freeze list, for example, because the RPM package gpg is present on the system. And gpg==1.13.1 is not a package available on PyPI...

So the pip freeze command becomes a bit more complicated (and still depending on the content of the Dockerfile!):

$ pip3 freeze | grep -E '^ipaddress|ansible-runner|openshift|ansible|jmespath'

This solution works quite well, even though it's not perfect: there's always the possibility of locally installing a different version of some dependencies of those packages, should a new release be made since the Docker image has been built for example.

Describe the solution you'd like.

My suggestion would be to have a requirements.txt file available in the Docker image at a documented location.
And that the packages mentioned inside would have to be pinned to specific versions for reproducibility purposes.
So one can easily set up a local environment with:

pip install $(docker run --rm -ti --entrypoint cat quay.io/operator-framework/ansible-operator:v1.2.0 /path/to/requirements.txt)

Any other idea?

/language ansible

Metadata

Metadata

Assignees

Labels

kind/documentationCategorizes issue or PR as related to documentation.language/ansibleIssue is related to an Ansible operator project

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions