From a11df3059f405a1c936bca7c46d16d95c34ea513 Mon Sep 17 00:00:00 2001 From: Trevor Bramwell Date: Tue, 26 Feb 2019 15:28:18 -0800 Subject: [PATCH] Use python3 for running Ansible in init 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 --- init/Dockerfile | 6 +++++- init/inventory.ini | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/init/Dockerfile b/init/Dockerfile index 20b5e01..9ba2891 100644 --- a/init/Dockerfile +++ b/init/Dockerfile @@ -10,7 +10,11 @@ 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"] diff --git a/init/inventory.ini b/init/inventory.ini index 2302eda..af0fa0f 100644 --- a/init/inventory.ini +++ b/init/inventory.ini @@ -1 +1 @@ -localhost ansible_connection=local +localhost ansible_connection=local ansible_python_interpreter=/usr/local/bin/python3 -- 2.16.6