geerlingguy / docker-centos6-ansible

CentOS 6.x Docker container for Ansible playbook and role testing.
https://hub.docker.com/r/geerlingguy/docker-centos6-ansible/
MIT License
8 stars 17 forks source link

Whither Ansible 2.7? #10

Open geerlingguy opened 5 years ago

geerlingguy commented 5 years ago

So... Ansible 2.7 has deprecated support for running on RHEL 6 / CentOS 6 as the controller (at least in the default state), because support for Python 2.6 and earlier was completely removed.

So as of right now, this image is/will be locked in at Ansible 2.6.4 for the forseeable future.

I played around with using SCL to install python27, then having every ansible* command run with scl enable python27 "ansible*", but it was extremely cumbersome, and completely different than the way you run Ansible in all my other Docker testing images.

So... it's also kinda insane to try to override the system python with 2.7, because in RHEL 6 python is intrinsically tied into yum... and yum's kinda important to have working correctly.

Related to #7 — especially since some testing tools won't install under Python 2.6 either :-/

Here's a patch for how far I got after about 2 hours trying various methods—still can't get Ansible 2.6.x to install via Pip under the system default Python 2.6.x :(

diff --git a/Dockerfile b/Dockerfile
index 4f79d9c..f39dec3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,25 +1,38 @@
 FROM centos:6
 LABEL maintainer="Jeff Geerling"

-# Install Ansible and other requirements.
+# Install requirements.
 RUN yum makecache fast \
  && yum -y install deltarpm epel-release \
  && yum -y update \
  && yum -y install \
-      ansible \
       sudo \
       which \
       initscripts \
       python-urllib3 \
       pyOpenSSL \
+      libssl-devel \
       python2-ndg_httpsclient \
       python-pyasn1 \
+      python-pip \
+      python-devel \
+      libffi-devel \
+      @development \
  && yum clean all

+# Upgrade setuptools.
+RUN pip install --upgrade setuptools==28.8.1 pycparser==2.18
+
+ENV pip_packages "ansible==2.6.4"
+
+# Install Ansible via Pip.
+RUN pip install $pip_packages
+
 # Disable requiretty.
 RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/'  /etc/sudoers

 # Install Ansible inventory file.
+RUN mkdir -p /etc/ansible
 RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts

 CMD ["/sbin/init"]