[Ansible] – How to create an Ubi/rhel7 image with ansible and python3?

Following an example over how to install ansible with python3 in a centos/rhel7 docker image.

FROM registry.access.redhat.com/ubi7/ubi
...
RUN mkdir -p /etc/ansible \
    && echo "localhost-py3 ansible_host=localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3" > /etc/ansible/hosts \
    && echo '[defaults]' > /etc/ansible/ansible.cfg \
    && echo 'roles_path = /opt/ansible/roles' >> /etc/ansible/ansible.cfg \
    && echo 'library = /usr/share/ansible/openshift' >> /etc/ansible/ansible.cfg

RUN yum clean all && rm -rf /var/cache/yum/* \
 && (yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm || true) \
 && yum install -y python36-devel python36-pip gcc inotify-tools \
 && pip3 install --upgrade setuptools pip \
 && pip install --no-cache-dir --ignore-installed ipaddress \
      ansible-runner==1.3.4 \
      ansible-runner-http==1.0.0 \
      openshift==0.8.9 \
      ansible==2.8.5 \

# Ensure directory permissions are properly set
RUN mkdir -p /opt/ansible/.ansible/tmp \
 && chown -R 1001:0 /opt/ansible \
 && chmod -R ug+rwx /opt/ansible
...
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s