From bdcf02b924703b1210b6e95173f14c8af0e13736 Mon Sep 17 00:00:00 2001 From: Attila Nagy Date: Wed, 18 Apr 2018 15:03:24 +0200 Subject: [PATCH 01/12] Make pip install commands ZSH compatbile in README - Fixes #902 [skip ci] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 84c75536..2ef1351c 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,14 @@ Use Ansible Container to manage the container lifecycle from development, throug Install using *pip*, the Python package manager: - $ sudo pip install ansible-container[docker,openshift] + $ sudo pip install "ansible-container[docker,openshift]" Or, to install without root privileges, use [virtualenv](https://virtualenv.pypa.io/en/stable/) to first create a Python sandbox: $ virtualenv ansible-container $ source ansible-container/bin/activate - $ pip install ansible-container[docker,openshift] + $ pip install "ansible-container[docker,openshift]" For more details, prerequisite, and instructions on installing the latest development release, please view our [Installation Guide](https://docs.ansible.com/ansible-container/installation.html). From 746de244785cb2e49c87294cfdf7ca259b871711 Mon Sep 17 00:00:00 2001 From: Zsolt Kulcsar Date: Tue, 5 Jun 2018 13:46:35 +0100 Subject: [PATCH 02/12] debug flag shall not execute different code --- container/docker/engine.py | 54 ++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/container/docker/engine.py b/container/docker/engine.py index 0e632faa..a4d2fc50 100644 --- a/container/docker/engine.py +++ b/container/docker/engine.py @@ -1123,37 +1123,29 @@ def build_conductor_image(self, base_path, base_image, prebaking=False, cache=Tr tarball_file = open(tarball_path, 'rb') logger.info('Starting Docker build of Ansible Container Conductor image (please be patient)...') # FIXME: Error out properly if build of conductor fails. - if self.debug: - for line in self.client.api.build(fileobj=tarball_file, - custom_context=True, - tag=tag, - rm=True, - decode=True, - nocache=not cache): - try: - if line.get('status') == 'Downloading': - # skip over lines that give spammy byte-by-byte - # progress of downloads - continue - elif 'errorDetail' in line: - raise exceptions.AnsibleContainerException( - "Error building conductor image: {0}".format(line['errorDetail']['message'])) - except ValueError: - pass - except exceptions.AnsibleContainerException: - raise - - # this bypasses the fancy colorized logger for things that - # are just STDOUT of a process - plainLogger.debug(text.to_text(line.get('stream', json.dumps(line))).rstrip()) - return self.get_image_id_by_tag(tag) - else: - image = self.client.images.build(fileobj=tarball_file, - custom_context=True, - tag=tag, - rm=True, - nocache=not cache) - return image.id + for line in self.client.api.build(fileobj=tarball_file, + custom_context=True, + tag=tag, + rm=True, + decode=True, + nocache=not cache): + try: + if line.get('status') == 'Downloading': + # skip over lines that give spammy byte-by-byte + # progress of downloads + continue + elif 'errorDetail' in line: + raise exceptions.AnsibleContainerException( + "Error building conductor image: {0}".format(line['errorDetail']['message'])) + except ValueError: + pass + except exceptions.AnsibleContainerException: + raise + + # this bypasses the fancy colorized logger for things that + # are just STDOUT of a process + plainLogger.debug(text.to_text(line.get('stream', json.dumps(line))).rstrip()) + return self.get_image_id_by_tag(tag) def get_runtime_volume_id(self, mount_point): try: From a4f9f8833ac5ff8eab609e2c6b154a3b88b27645 Mon Sep 17 00:00:00 2001 From: Vyacheslav Voronenko Date: Tue, 5 Jun 2018 20:07:47 +0200 Subject: [PATCH 03/12] improve(regression) syncronizing to pip changes --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fdb3593a..08a98497 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,10 @@ from setuptools import setup, find_packages from setuptools.command.test import test as TestCommand from setuptools.command.sdist import sdist as SDistCommand -from pip.req import parse_requirements +try: + from pip._internal.req import parse_requirements +except ImportError: + from pip.req import parse_requirements import container class PlaybookAsTests(TestCommand): From e8b1294779595d94437eed16952c9aea3c63c49c Mon Sep 17 00:00:00 2001 From: Vyacheslav Voronenko Date: Tue, 5 Jun 2018 20:10:27 +0200 Subject: [PATCH 04/12] improve(internalization) allow non ascii file names --- container/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/utils/__init__.py b/container/utils/__init__.py index 10168261..cc603d49 100644 --- a/container/utils/__init__.py +++ b/container/utils/__init__.py @@ -272,7 +272,7 @@ def hash_dir(hash_obj, dir_path): for root, dirs, files in os.walk(dir_path, topdown=True): for file_path in files: abs_file_path = os.path.join(root, file_path) - hash_obj.update(abs_file_path) + hash_obj.update(abs_file_path.encode('utf-8')) hash_obj.update('::') hash_file(hash_obj, abs_file_path) From d89e41f9ac73877adfa795b5323374babc2e7ef5 Mon Sep 17 00:00:00 2001 From: Vyacheslav Voronenko Date: Tue, 5 Jun 2018 20:16:06 +0200 Subject: [PATCH 05/12] chore(requirements) temporary freeze docker version due to incompabilities introduced --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index c43c5a64..5f902778 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ Jinja2>=2.9 pip>=6.0 PyYAML>=3.12 +docker==2.7.0 requests>=2 ruamel.yaml>=0.15.34 six>=1.10 From 98b3448452548ce3596721543988e3a0d3f455ac Mon Sep 17 00:00:00 2001 From: Vyacheslav Voronenko Date: Tue, 5 Jun 2018 20:18:32 +0200 Subject: [PATCH 06/12] chore(regression) prevent invalid layer names during the build --- container/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/container/core.py b/container/core.py index db6c36c2..793ce8b6 100644 --- a/container/core.py +++ b/container/core.py @@ -696,7 +696,8 @@ def _find_base_image_id(engine, service_name, service): return image_id def _intermediate_build_container_name(engine, service_name, image_fingerprint, role_name): - return u'%s-%s-%s' % (engine.container_name_for_service(service_name), image_fingerprint[:8], role_name) + safe_role_name = re.sub(r"[^a-zA-Z0-9_.-]", "_", role_name) + return u'%s-%s-%s' % (engine.container_name_for_service(service_name), image_fingerprint[:8], safe_role_name) def _run_intermediate_build_container(engine, container_name, cur_image_id, service_name, service, **kwargs): From 4962d9c0e8bce30528223a5f1139f2ae2a19a14d Mon Sep 17 00:00:00 2001 From: Vyacheslav Voronenko Date: Tue, 5 Jun 2018 20:33:22 +0200 Subject: [PATCH 07/12] improve(tests) introduced ubuntu 18.04 LTS --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bcb44082..e90285fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ env: - BASE_DISTRO: ubuntu:precise - BASE_DISTRO: ubuntu:trusty - BASE_DISTRO: ubuntu:xenial + - BASE_DISTRO: ubuntu:beaver - BASE_DISTRO: ubuntu:artful - BASE_DISTRO: alpine:3.5 - BASE_DISTRO: alpine:3.4 From 43b9d096b83ca3cd6286ab2d5adcdcaa6ec6a039 Mon Sep 17 00:00:00 2001 From: Vyacheslav Voronenko Date: Tue, 5 Jun 2018 21:00:32 +0200 Subject: [PATCH 08/12] improve(tests) fixed container names --- test/roles/validate-start-stop-restart/tasks/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/roles/validate-start-stop-restart/tasks/main.yml b/test/roles/validate-start-stop-restart/tasks/main.yml index 21437316..8be93568 100644 --- a/test/roles/validate-start-stop-restart/tasks/main.yml +++ b/test/roles/validate-start-stop-restart/tasks/main.yml @@ -24,7 +24,7 @@ - include: includes/show-output.yml output_file=./task.output registered_output="{{ output }}" - name: Wait until built containers are running - command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" register: container_run_status until: container_run_status.stdout == 'running' retries: 6 @@ -34,7 +34,7 @@ - run - name: Note start time - command: "docker inspect --format='{{'{{'}} .State.StartedAt {{'}}'}}' test{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.StartedAt {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" register: container_run_start tags: - restart @@ -53,7 +53,7 @@ - include: includes/show-output.yml output_file=./task.output registered_output="{{ output }}" - name: Wait until built containers are running - command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" register: container_restart_status until: container_restart_status.stdout == 'running' retries: 6 @@ -63,7 +63,7 @@ - run - name: Note start time - command: "docker inspect --format='{{'{{'}} .State.StartedAt {{'}}'}}' test{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.StartedAt {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" register: container_restart_start tags: - restart @@ -93,7 +93,7 @@ - include: includes/show-output.yml output_file=./task.output registered_output="{{ output }}" - name: Wait until built containers are stop - command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" register: container_stop_status until: container_stop_status.stdout != 'running' retries: 6 From da51782703e494486c6a8a53df7e667116c29abf Mon Sep 17 00:00:00 2001 From: Vyacheslav Voronenko Date: Tue, 5 Jun 2018 21:08:15 +0200 Subject: [PATCH 09/12] improve(tests) fixed container names --- test/roles/validate-start-stop-restart/tasks/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/roles/validate-start-stop-restart/tasks/main.yml b/test/roles/validate-start-stop-restart/tasks/main.yml index 8be93568..32fe8f0f 100644 --- a/test/roles/validate-start-stop-restart/tasks/main.yml +++ b/test/roles/validate-start-stop-restart/tasks/main.yml @@ -24,7 +24,7 @@ - include: includes/show-output.yml output_file=./task.output registered_output="{{ output }}" - name: Wait until built containers are running - command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test-{{ distro.name }}_{{ distro.name }}_1" register: container_run_status until: container_run_status.stdout == 'running' retries: 6 @@ -34,7 +34,7 @@ - run - name: Note start time - command: "docker inspect --format='{{'{{'}} .State.StartedAt {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.StartedAt {{'}}'}}' test-{{ distro.name }}_{{ distro.name }}_1" register: container_run_start tags: - restart @@ -53,7 +53,7 @@ - include: includes/show-output.yml output_file=./task.output registered_output="{{ output }}" - name: Wait until built containers are running - command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test-{{ distro.name }}_{{ distro.name }}_1" register: container_restart_status until: container_restart_status.stdout == 'running' retries: 6 @@ -63,7 +63,7 @@ - run - name: Note start time - command: "docker inspect --format='{{'{{'}} .State.StartedAt {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.StartedAt {{'}}'}}' test-{{ distro.name }}_{{ distro.name }}_1" register: container_restart_start tags: - restart @@ -93,7 +93,7 @@ - include: includes/show-output.yml output_file=./task.output registered_output="{{ output }}" - name: Wait until built containers are stop - command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test-{{ distro.name|replace('-','') }}_{{ distro.name }}_1" + command: "docker inspect --format='{{'{{'}} .State.Status {{'}}'}}' test-{{ distro.name }}_{{ distro.name }}_1" register: container_stop_status until: container_stop_status.stdout != 'running' retries: 6 From aedbbe1cfc5cc2088adbe0ec126cd089e8835948 Mon Sep 17 00:00:00 2001 From: Vyacheslav Voronenko Date: Tue, 5 Jun 2018 21:48:13 +0200 Subject: [PATCH 10/12] improve(conductor) newest amazonlinux:2 misses tar --- container/docker/templates/conductor-src-dockerfile.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/docker/templates/conductor-src-dockerfile.j2 b/container/docker/templates/conductor-src-dockerfile.j2 index baf5cb3d..c8a751b2 100644 --- a/container/docker/templates/conductor-src-dockerfile.j2 +++ b/container/docker/templates/conductor-src-dockerfile.j2 @@ -16,7 +16,7 @@ RUN yum update -y && \ yum clean all {% elif distro in ["amazonlinux"] %} RUN yum -y update && \ - yum -y install make git gcc python27-devel rsync libffi-devel openssl-devel && \ + yum -y install make git gcc python27-devel rsync libffi-devel openssl-devel tar && \ yum clean all {% elif "rhel" in distro %} RUN yum -y update-minimal --disablerepo "*" \ From e25bd6650e3fc26b5122a464684edc8553a74243 Mon Sep 17 00:00:00 2001 From: Greg DeKoenigsberg Date: Fri, 8 Jun 2018 10:24:29 -0400 Subject: [PATCH 11/12] Removing "not under active development" notice We've been able to merge a couple of PRs, so we're back in business. Still not moving fast, though. :) --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index c27dc936..84c75536 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ Ansible Container is a tool for building Docker images and orchestrating containers using Ansible playbooks. -**NOTE: Ansible Container is no longer under active development as of February 2018.** - ## How it works Use Ansible Container to manage the container lifecycle from development, through testing, to production: From cca680c5cce28df337bae8276c2e99a44302e5c2 Mon Sep 17 00:00:00 2001 From: Zsolt Kulcsar Date: Tue, 5 Jun 2018 13:46:35 +0100 Subject: [PATCH 12/12] debug flag shall not execute different code --- container/docker/engine.py | 54 ++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/container/docker/engine.py b/container/docker/engine.py index 0e632faa..a4d2fc50 100644 --- a/container/docker/engine.py +++ b/container/docker/engine.py @@ -1123,37 +1123,29 @@ def build_conductor_image(self, base_path, base_image, prebaking=False, cache=Tr tarball_file = open(tarball_path, 'rb') logger.info('Starting Docker build of Ansible Container Conductor image (please be patient)...') # FIXME: Error out properly if build of conductor fails. - if self.debug: - for line in self.client.api.build(fileobj=tarball_file, - custom_context=True, - tag=tag, - rm=True, - decode=True, - nocache=not cache): - try: - if line.get('status') == 'Downloading': - # skip over lines that give spammy byte-by-byte - # progress of downloads - continue - elif 'errorDetail' in line: - raise exceptions.AnsibleContainerException( - "Error building conductor image: {0}".format(line['errorDetail']['message'])) - except ValueError: - pass - except exceptions.AnsibleContainerException: - raise - - # this bypasses the fancy colorized logger for things that - # are just STDOUT of a process - plainLogger.debug(text.to_text(line.get('stream', json.dumps(line))).rstrip()) - return self.get_image_id_by_tag(tag) - else: - image = self.client.images.build(fileobj=tarball_file, - custom_context=True, - tag=tag, - rm=True, - nocache=not cache) - return image.id + for line in self.client.api.build(fileobj=tarball_file, + custom_context=True, + tag=tag, + rm=True, + decode=True, + nocache=not cache): + try: + if line.get('status') == 'Downloading': + # skip over lines that give spammy byte-by-byte + # progress of downloads + continue + elif 'errorDetail' in line: + raise exceptions.AnsibleContainerException( + "Error building conductor image: {0}".format(line['errorDetail']['message'])) + except ValueError: + pass + except exceptions.AnsibleContainerException: + raise + + # this bypasses the fancy colorized logger for things that + # are just STDOUT of a process + plainLogger.debug(text.to_text(line.get('stream', json.dumps(line))).rstrip()) + return self.get_image_id_by_tag(tag) def get_runtime_volume_id(self, mount_point): try: