Rename the main task to modify_image.yaml

There will be other tasks in this role.
This commit is contained in:
Steve Baker 2018-05-02 11:08:24 +12:00
parent a51e542cd6
commit cad6e42217
3 changed files with 30 additions and 28 deletions

View File

@ -35,6 +35,7 @@ The following playbook will produce a modified image tagged with
- name: include tripleo-modify-image
import_role:
name: tripleo-modify-image
tasks_from: modify_image.yml
vars:
source_image: docker.io/tripleomaster/centos-binary-nova-api:latest
modify_dir_path: /path/to/example_modify_dir

View File

@ -1,28 +1 @@
- name: Copy Dockerfile to Dockerfile.modified
copy:
src: "{{ modify_dir_path }}/Dockerfile"
dest: "{{ modify_dir_path }}/Dockerfile.modified"
- 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 or modified_append_tag == None
- name: Replace FROM directive
lineinfile:
path: "{{ modify_dir_path }}/Dockerfile.modified"
regexp: "^FROM "
line: "FROM {{ source_image }}"
- name: Add LABEL modified_append_tag={{ modified_append_tag }}
lineinfile:
path: "{{ modify_dir_path }}/Dockerfile.modified"
insertafter: "^FROM "
line: "LABEL modified_append_tag={{ modified_append_tag }}"
- name: Modify image
docker_image:
name: "{{ modified_image }}{{ modified_append_tag }}"
path: "{{ modify_dir_path }}"
dockerfile: Dockerfile.modified
---

28
tasks/modify_image.yml Normal file
View File

@ -0,0 +1,28 @@
- name: Copy Dockerfile to Dockerfile.modified
copy:
src: "{{ modify_dir_path }}/Dockerfile"
dest: "{{ modify_dir_path }}/Dockerfile.modified"
- 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 or modified_append_tag == None
- name: Replace FROM directive
lineinfile:
path: "{{ modify_dir_path }}/Dockerfile.modified"
regexp: "^FROM "
line: "FROM {{ source_image }}"
- name: Add LABEL modified_append_tag={{ modified_append_tag }}
lineinfile:
path: "{{ modify_dir_path }}/Dockerfile.modified"
insertafter: "^FROM "
line: "LABEL modified_append_tag={{ modified_append_tag }}"
- name: Modify image
docker_image:
name: "{{ modified_image }}{{ modified_append_tag }}"
path: "{{ modify_dir_path }}"
dockerfile: Dockerfile.modified