diff --git a/.gitmodules b/.gitmodules index a1fd09b..e8321cc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,7 @@ +[submodule "roles/catatonit"] + path = roles/catatonit + url = https://github.com/alvistack/ansible-role-catatonit.git + branch = develop [submodule "roles/gosu"] path = roles/gosu url = https://github.com/alvistack/ansible-role-gosu.git @@ -18,7 +22,3 @@ path = roles/timezone url = https://github.com/alvistack/ansible-role-timezone.git branch = develop -[submodule "roles/tini"] - path = roles/tini - url = https://github.com/alvistack/ansible-role-tini.git - branch = develop diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b16dad..be4165d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,16 @@ # Docker Image Packaging for mitmproxy -## 5.0.1-XalvistackY - TBC +## 5.1.1-XalvistackY - TBC ### Major Changes +## 5.1.1-4alvistack2 - 2020-06-10 + +### Major Changes + + - Revamp `create`, `side_effect`, `verify` and `destroy` logic + - Install with static binary archive + - Replace `tini` with `catatonit` - Rename `post_tasks.yml` as `side_effect.yml` - Upgrade base image to Ubuntu 20.04 diff --git a/README.md b/README.md index 2dd8c23..f6882c3 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Based on [Official Ubuntu Docker Image](https://hub.docker.com/_/ubuntu/) with s - Minimized `Dockerfile` for meta data definition - Provision by Ansible and Molecule Docker driver in single layer - - Handle `ENTRYPOINT` with [tini](https://github.com/krallin/tini) + - Handle `ENTRYPOINT` with [catatonit](https://github.com/openSUSE/catatonit) ### Quick Start diff --git a/molecule/5.1/Dockerfile.j2 b/molecule/5.1/Dockerfile.j2 index 4c3ca85..4936a49 100644 --- a/molecule/5.1/Dockerfile.j2 +++ b/molecule/5.1/Dockerfile.j2 @@ -45,5 +45,5 @@ ENV MITMPROXY_VERSION "{{ mitmproxy_version }}" EXPOSE 8080 EXPOSE 8081 -ENTRYPOINT [ "tini", "-g", "--", "docker-entrypoint.sh" ] +ENTRYPOINT [ "catatonit", "-g", "--", "docker-entrypoint.sh" ] CMD [ "mitmdump", "--mode transparent", "--showhost" ] diff --git a/molecule/default/destroy.yml b/molecule/default/destroy.yml index 42f81e5..82dc2a5 100644 --- a/molecule/default/destroy.yml +++ b/molecule/default/destroy.yml @@ -20,6 +20,30 @@ become: true gather_facts: false tasks: + - name: docker image inspect + docker_image_info: + name: "{{ molecule_ephemeral_directory | regex_replace('^.*/([^/]*/[^/]*)$', '\\1') }}:{{ item.name }}" + loop_control: + label: "{{ item.name }}" + loop: "{{ molecule_yml.platforms }}" + register: result + + - name: docker commit + shell: | + set -o pipefail + docker inspect {{ item.name }} && docker commit \ + --change 'CMD ["{{ result.results[i].images[0].Config.Cmd | join('", "') }}"]' \ + --change 'ENTRYPOINT ["{{ result.results[i].images[0].Config.Entrypoint | join('", "') }}"]' \ + {{ item.name }} {{ molecule_ephemeral_directory | regex_replace('^.*/([^/]*/[^/]*)$', '\1') }}:{{ item.name }}-commit + args: + executable: "/bin/bash" + loop_control: + label: "{{ item.name }}" + index_var: i + with_items: "{{ molecule_yml.platforms }}" + changed_when: false + ignore_errors: true + - name: docker rm docker_container: name: "{{ item.name }}" diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 2ade667..c0e030c 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -14,70 +14,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -- hosts: all - remote_user: root - become: true - gather_facts: false - tasks: - - name: rm -rf /root/.ansible/tmp/* - raw: | - set -ex - rm -rf /root/.ansible/tmp/* - rm -rf /root/.cache/* - rm -rf /tmp/* - changed_when: false - ignore_errors: true - - - name: debian | apt-get clean - raw: | - set -ex - apt-get clean - rm -rf /var/lib/apt/lists/* - changed_when: false - ignore_errors: true - - - name: redhat | yum clean all - raw: | - set -ex - yum clean all - rm -rf /var/cache/yum/* - changed_when: false - ignore_errors: true - - - name: suse | zypper clean --all - raw: | - set -ex - zypper clean --all - rm -rf /var/cache/zypper/* - changed_when: false - ignore_errors: true - -- hosts: localhost - connection: local - remote_user: root - become: true - gather_facts: false - tasks: - - name: docker image inspect - docker_image_info: - name: "{{ molecule_ephemeral_directory | regex_replace('^.*/([^/]*/[^/]*)$', '\\1') }}:{{ item.name }}" - loop_control: - label: "{{ item.name }}" - loop: "{{ molecule_yml.platforms }}" - register: result - - - name: docker commit - shell: | - set -o pipefail - docker inspect {{ item.name }} && docker commit \ - --change 'CMD ["{{ result.results[i].images[0].Config.Cmd | join('", "') }}"]' \ - --change 'ENTRYPOINT ["{{ result.results[i].images[0].Config.Entrypoint | join('", "') }}"]' \ - {{ item.name }} {{ molecule_ephemeral_directory | regex_replace('^.*/([^/]*/[^/]*)$', '\1') }}:{{ item.name }}-commit - args: - executable: "/bin/bash" - loop_control: - label: "{{ item.name }}" - index_var: i - with_items: "{{ molecule_yml.platforms }}" - changed_when: false - ignore_errors: true +- import_playbook: ../../playbooks/verify.yml diff --git a/playbooks/converge.yml b/playbooks/converge.yml index bdb13fb..4a943d9 100644 --- a/playbooks/converge.yml +++ b/playbooks/converge.yml @@ -88,7 +88,7 @@ name: timezone - include_role: - name: tini + name: catatonit - include_role: name: gosu diff --git a/playbooks/side_effect.yml b/playbooks/side_effect.yml index a565d73..28b3b72 100644 --- a/playbooks/side_effect.yml +++ b/playbooks/side_effect.yml @@ -33,3 +33,36 @@ paths: - "./vars" ignore_errors: true + + - name: rm -rf /root/.ansible/tmp/* + raw: | + set -ex + rm -rf /root/.ansible/tmp/* + rm -rf /root/.cache/* + rm -rf /tmp/* + changed_when: false + ignore_errors: true + + - name: debian | apt-get clean + raw: | + set -ex + apt-get clean + rm -rf /var/lib/apt/lists/* + changed_when: false + ignore_errors: true + + - name: redhat | yum clean all + raw: | + set -ex + yum clean all + rm -rf /var/cache/yum/* + changed_when: false + ignore_errors: true + + - name: suse | zypper clean --all + raw: | + set -ex + zypper clean --all + rm -rf /var/cache/zypper/* + changed_when: false + ignore_errors: true diff --git a/playbooks/verify.yml b/playbooks/verify.yml new file mode 100644 index 0000000..a565d73 --- /dev/null +++ b/playbooks/verify.yml @@ -0,0 +1,35 @@ +--- + +# (c) Wong Hoi Sing Edison +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- hosts: all + remote_user: root + tasks: + - name: include default variables + include_vars: "./vars/main.yml" + + - name: include release specific variables + include_vars: "{{ lookup('first_found', _params) }}" + vars: + _params: + files: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + paths: + - "./vars" + ignore_errors: true diff --git a/roles/catatonit b/roles/catatonit new file mode 160000 index 0000000..4832596 --- /dev/null +++ b/roles/catatonit @@ -0,0 +1 @@ +Subproject commit 483259686cf871df760a42d63288860896b7fc41 diff --git a/roles/gosu b/roles/gosu index 46a530d..f7b02c3 160000 --- a/roles/gosu +++ b/roles/gosu @@ -1 +1 @@ -Subproject commit 46a530daaee2847d6a9f64951e17e383fc8a6634 +Subproject commit f7b02c3d866a86c484bc45a91113f792115f0a21 diff --git a/roles/locales b/roles/locales index 9e4f591..4890173 160000 --- a/roles/locales +++ b/roles/locales @@ -1 +1 @@ -Subproject commit 9e4f5916a3a822903ffee2feb57e8d03a0856b8b +Subproject commit 48901738d029cb6d565a8a860a2adbc333387375 diff --git a/roles/mitmproxy b/roles/mitmproxy index adbc6cf..351897c 160000 --- a/roles/mitmproxy +++ b/roles/mitmproxy @@ -1 +1 @@ -Subproject commit adbc6cfc3a2e26586720f13a79df51616cdb3215 +Subproject commit 351897c4dfca5f5746854f580451dc0b2427bd44 diff --git a/roles/python b/roles/python index db06934..47fea7f 160000 --- a/roles/python +++ b/roles/python @@ -1 +1 @@ -Subproject commit db069349007897cf05438d7464c2dfc73711824e +Subproject commit 47fea7f8d532a4327a8ed55f985d4107ec1a110b diff --git a/roles/timezone b/roles/timezone index b6a6fbd..e044aef 160000 --- a/roles/timezone +++ b/roles/timezone @@ -1 +1 @@ -Subproject commit b6a6fbdc740cdf1f2d2f93b03c32353236cf8a71 +Subproject commit e044aef3962abca499189ac6a1fa1aa6b1181c5c diff --git a/roles/tini b/roles/tini deleted file mode 160000 index 56ae2d0..0000000 --- a/roles/tini +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 56ae2d0d0c625b20b141febaa2c0c5a0aea63499