Use python3 for running Ansible in init 04/14704/1
authorTrevor Bramwell <tbramwell@linuxfoundation.org>
Tue, 26 Feb 2019 23:28:18 +0000 (15:28 -0800)
committerTrevor Bramwell <tbramwell@linuxfoundation.org>
Tue, 26 Feb 2019 23:31:41 +0000 (15:31 -0800)
Because the python docker container installs python to a location other
than /usr/bin, ansible doesn't know it have python3 available. Setting
this flag allows the build to use python3 and fix a pip error.

An extra setting ANSIBLE_STDOUT_CALLBACK=yaml is added to add clearer
output when running ansible, and can be overridden in the
docker-compose.yaml file.

Change-Id: I9dfc1aa0be17fb93d73e3ce321330558b44f7829
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
init/Dockerfile
init/inventory.ini

index 20b5e01..9ba2891 100644 (file)
 FROM python:3
 
 ENV CI_SYSTEM=jenkins
+ENV ANSIBLE_STDOUT_CALLBACK=yaml
 
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -yq \
+  python3-apt \
+  && apt-get clean
 RUN pip install --no-cache-dir ansible docker-py
 
 RUN mkdir /etc/ansible
@@ -18,4 +22,4 @@ RUN mkdir /usr/src/ansible
 
 WORKDIR /usr/src/ansible
 
-CMD ["ansible-playbook", "/usr/src/ansible/site.yaml", "-i", "/etc/ansible/inventory.ini"]
+CMD ["ansible-playbook", "-v", "/usr/src/ansible/site.yaml", "-i", "/etc/ansible/inventory.ini"]
index 2302eda..af0fa0f 100644 (file)
@@ -1 +1 @@
-localhost ansible_connection=local
+localhost ansible_connection=local ansible_python_interpreter=/usr/local/bin/python3