From 60c8e5207958d4a33053d431cc4d68e1c411d780 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Thu, 3 May 2018 15:50:31 +1200 Subject: [PATCH] rename modified_image_prefix to target_image, use set_fact for timestamp If set_fact is not used, the lookup(pipe) is evaluated every time it is referenced, which means potentially different timestamps being used. --- README.md | 5 +++-- defaults/main.yml | 4 +--- tasks/main.yml | 2 ++ tasks/modify_image.yml | 7 ++++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e6e92a4..1b485d8 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ A role to allow modification to container images built for the TripleO project. | `source_image` | `[undefined]` | Mandatory fully qualified reference to the source image to be modified. The supplied Dockerfile will be copied and modified to make the FROM directive match this variable. | | `modify_dir_path` | `[undefined]` | Mandatory path to the directory containing the Dockerfile to modify the image | | `modified_append_tag` | `date +-modified-%Y%m%d%H%M%S` | String to be appended after the tag to indicate this is a modified version of the source image. | -| `modified_image_prefix` | `''` | If set, the modified image will be tagged with this reference. If the purpose of the image is not changing, it may be enough to rely on `modified_append_tag` to identify that this is a modified version of the source image. `modified_append_tag` will still be appended to this reference. | +| `target_image` | `[undefined]` | If set, the modified image will be tagged with `target_image + modified_append_tag`. If `target_image` is not set, the modified image will be tagged with `source_image + modified_append_tag`. If the purpose of the image is not changing, it may be enough to rely on the `source_image + modified_append_tag` tag to identify that this is a modified version of the source image. | + **Variables used for yum update** @@ -19,7 +20,7 @@ A role to allow modification to container images built for the TripleO project. |-------------------|---------------------|----------------------| | `source_image` | `[undefined]` | See modify image variables | | `modified_append_tag` | `date +-modified-%Y%m%d%H%M%S` | See modify image variables | -| `modified_image_prefix` | `''` | See modify image variables | +| `target_image` | `''` | See modify image variables | | `yum_repos_dir_path` | `None` | Optional path of directory to be used as `/etc/yum.repos.d` during the update | | `compare_host_packages` | `False` | If `True`, skip yum update when package versions match host package versions | diff --git a/defaults/main.yml b/defaults/main.yml index c4fecd3..64dc291 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1 @@ -modified_image_prefix: '' -modified_append_tag: "{{ lookup('pipe','date +-modified-%Y%m%d%H%M%S') }}" -compare_host_packages: no +compare_host_packages: false diff --git a/tasks/main.yml b/tasks/main.yml index cbdfef3..95ead2f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,3 +1,5 @@ - import_tasks: precheck.yml tags: - always + +- import_tasks: "{{ tasks_from | default('modify_image.yml') }}" diff --git a/tasks/modify_image.yml b/tasks/modify_image.yml index 647aa4b..fe2528d 100644 --- a/tasks/modify_image.yml +++ b/tasks/modify_image.yml @@ -2,6 +2,11 @@ tags: - always +- name: Set default modified_append_tag + set_fact: + modified_append_tag: "{{ lookup('pipe','date +-modified-%Y%m%d%H%M%S') }}" + when: modified_append_tag is undefined + - name: Copy Dockerfile to Dockerfile.modified copy: src: "{{ modify_dir_path }}/Dockerfile" @@ -21,7 +26,7 @@ - name: Modify image docker_image: - name: "{{ modified_image_prefix }}{{ modified_append_tag }}" + name: "{{ target_image | default(source_image) }}{{ modified_append_tag }}" path: "{{ modify_dir_path }}" dockerfile: Dockerfile.modified