From 8ce43017eb3d9675594a1af2e370f92cc930e63c Mon Sep 17 00:00:00 2001
From: Pavel Vetokhin
Date: Thu, 22 Feb 2024 22:27:45 +0300
Subject: [PATCH] Stacks building & publishing
---
.github/workflows/beyond-doubt.yaml | 17 ++++-------
.github/workflows/convincing.yaml | 3 +-
baker/ansible/binaries.yaml | 2 +-
baker/ansible/images.yaml | 6 ++--
baker/ansible/inventory/aliases.yaml | 8 +++---
.../ansible/inventory/group_vars/all/all.yaml | 7 +++--
baker/ansible/roles/image/defaults/main.yaml | 2 --
.../image/tasks/{main.yaml => build.yaml} | 9 +++---
baker/ansible/roles/image/tasks/clean.yaml | 2 +-
baker/ansible/roles/image/tasks/publish.yaml | 20 +++++++++++++
baker/ansible/sources.yaml | 10 +++----
baker/ansible/stacks.yaml | 28 +++++++++++--------
.../tasks/app/{status.yaml => capture.yaml} | 19 +++++--------
baker/ansible/tasks/app/publish.yaml | 26 ++++++-----------
baker/ansible/tasks/db/build.yaml | 9 +++---
.../tasks/db/{status.yaml => capture.yaml} | 7 +----
baker/ansible/tasks/db/publish.yaml | 23 ++++++---------
baker/ansible/tasks/gear/build.yaml | 10 +++----
.../tasks/gear/{status.yaml => capture.yaml} | 13 +++++++--
baker/ansible/tasks/gear/package.yaml | 9 ------
baker/ansible/tasks/gear/publish.yaml | 8 ++++++
baker/ansible/tasks/product/build.yaml | 9 ++++++
.../product/{status.yaml => capture.yaml} | 6 ++--
.../tasks/product/{test.yaml => check.yaml} | 2 +-
baker/ansible/tasks/product/package.yaml | 10 -------
baker/ansible/tasks/product/publish.yaml | 8 ++++++
stack/gear/Dockerfile | 3 ++
27 files changed, 140 insertions(+), 136 deletions(-)
rename baker/ansible/roles/image/tasks/{main.yaml => build.yaml} (74%)
create mode 100644 baker/ansible/roles/image/tasks/publish.yaml
rename baker/ansible/tasks/app/{status.yaml => capture.yaml} (66%)
rename baker/ansible/tasks/db/{status.yaml => capture.yaml} (61%)
rename baker/ansible/tasks/gear/{status.yaml => capture.yaml} (76%)
delete mode 100644 baker/ansible/tasks/gear/package.yaml
create mode 100644 baker/ansible/tasks/gear/publish.yaml
rename baker/ansible/tasks/product/{status.yaml => capture.yaml} (86%)
rename baker/ansible/tasks/product/{test.yaml => check.yaml} (97%)
delete mode 100644 baker/ansible/tasks/product/package.yaml
create mode 100644 baker/ansible/tasks/product/publish.yaml
create mode 100644 stack/gear/Dockerfile
diff --git a/.github/workflows/beyond-doubt.yaml b/.github/workflows/beyond-doubt.yaml
index fe846adc..a521166a 100644
--- a/.github/workflows/beyond-doubt.yaml
+++ b/.github/workflows/beyond-doubt.yaml
@@ -9,8 +9,6 @@ on:
env:
IMAGE_NAME: stack/gear
- BINARY_REPO: maven.pkg.github.com
- IMAGE_REPO: ghcr.io
jobs:
up-to-images:
@@ -57,8 +55,7 @@ jobs:
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
ansible-playbook images.yaml -v
-e devenv=${{ matrix.env.dev }}
- -e binary_repo=${{ env.BINARY_REPO }}
- -e image_repo=${{ env.IMAGE_REPO }}
+ -e repo_mode=rw
- uses: mikepenz/action-junit-report@v4.1.0
if: ${{ !cancelled() && (steps.images.outcome == 'success' || steps.images.outcome == 'failure') }}
with:
@@ -108,7 +105,6 @@ jobs:
--workdir $(pwd)/baker/ansible
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
ansible-playbook stacks.yaml -t build
- -e image_repo=${{ env.IMAGE_REPO }}
-e devenv=${{ matrix.env.dev }}
-e purpose=${{ matrix.purpose }}
-e opsenv=${{ matrix.env.ops }}
@@ -149,7 +145,7 @@ jobs:
with:
name: product-${{ matrix.purpose }}-${{ matrix.env.ops }}
path: stack/product/target/image-context
- - name: Run ansible-playbook stacks.yaml -t test
+ - name: Run ansible-playbook stacks.yaml -t check
run: >-
docker run --rm
--network gear
@@ -158,8 +154,7 @@ jobs:
--volume /var/run/docker.sock:/var/run/docker.sock
--workdir $(pwd)/baker/ansible
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
- ansible-playbook stacks.yaml -t test
- -e image_repo=${{ env.IMAGE_REPO }}
+ ansible-playbook stacks.yaml -t check
-e devenv=${{ matrix.env.dev }}
-e purpose=${{ matrix.purpose }}
-e opsenv=${{ matrix.env.ops }}
@@ -204,7 +199,7 @@ jobs:
with:
name: product-${{ matrix.purpose }}-${{ matrix.env.ops }}
path: stack/product/target/image-context
- - name: Run ansible-playbook stacks.yaml -t package
+ - name: Run ansible-playbook stacks.yaml -t publish
run: >-
docker run --rm
--volume $(pwd):$(pwd)
@@ -212,11 +207,11 @@ jobs:
--volume ~/.docker/config.json:/root/.docker/config.json:ro
--workdir $(pwd)/baker/ansible
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
- ansible-playbook stacks.yaml -t package -v
- -e image_repo=${{ env.IMAGE_REPO }}
+ ansible-playbook stacks.yaml -t publish -v
-e devenv=${{ matrix.env.dev }}
-e purpose=${{ matrix.purpose }}
-e opsenv=${{ matrix.env.ops }}
+ -e repo_mode=rw
stack-reporting:
name: Stack reporting
diff --git a/.github/workflows/convincing.yaml b/.github/workflows/convincing.yaml
index 7f3bd1ec..31da92e8 100644
--- a/.github/workflows/convincing.yaml
+++ b/.github/workflows/convincing.yaml
@@ -53,8 +53,7 @@ jobs:
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
ansible-playbook images.yaml -v
-e devenv=${{ matrix.env.dev }}
- -e binary_repo=maven.pkg.github.com
- -e image_repo=ghcr.io
+ -e repo_mode=rw
- uses: mikepenz/action-junit-report@v4.1.0
if: ${{ !cancelled() && (steps.images.outcome == 'success' || steps.images.outcome == 'failure') }}
with:
diff --git a/baker/ansible/binaries.yaml b/baker/ansible/binaries.yaml
index fffb2092..d351e0a8 100644
--- a/baker/ansible/binaries.yaml
+++ b/baker/ansible/binaries.yaml
@@ -1,5 +1,5 @@
---
-- name: Binaries
+- name: Building & Checking
hosts: app
run_once: true
tasks:
diff --git a/baker/ansible/images.yaml b/baker/ansible/images.yaml
index d4a8c262..f636db7a 100644
--- a/baker/ansible/images.yaml
+++ b/baker/ansible/images.yaml
@@ -4,7 +4,7 @@
run_once: true
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
- file: tasks/db/status.yaml
+ file: tasks/db/capture.yaml
tags: [always]
- ansible.builtin.import_role: # noqa: name[missing]
name: image
@@ -26,7 +26,7 @@
run_once: true
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
- file: tasks/app/status.yaml
+ file: tasks/app/capture.yaml
tags: [always]
- ansible.builtin.import_role: # noqa: name[missing]
name: image
@@ -42,7 +42,7 @@
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/app/build-and-check.yaml
vars:
- maven_phase: "{{ 'install' if binary_repo == 'local' else 'deploy' }}"
+ maven_phase: "{{ 'deploy' if repo_mode == 'rw' else 'install' }}"
when: image_status is changed
- name: Publishing
diff --git a/baker/ansible/inventory/aliases.yaml b/baker/ansible/inventory/aliases.yaml
index a23bd895..de0868c7 100644
--- a/baker/ansible/inventory/aliases.yaml
+++ b/baker/ansible/inventory/aliases.yaml
@@ -4,14 +4,14 @@ sources:
java:
ansible:
github:
-stack:
- hosts:
- gear:
- product:
image:
hosts:
db:
app:
+stack:
+ hosts:
+ gear:
+ product:
all:
vars:
ansible_connection: local
diff --git a/baker/ansible/inventory/group_vars/all/all.yaml b/baker/ansible/inventory/group_vars/all/all.yaml
index a6a18b77..dae5b31f 100644
--- a/baker/ansible/inventory/group_vars/all/all.yaml
+++ b/baker/ansible/inventory/group_vars/all/all.yaml
@@ -4,9 +4,10 @@ project:
org: smecalculus
dir: "{{ playbook_dir }}/../.."
-binary_repo: local
-image_repo: local
+binary_repo: maven.pkg.github.com
+image_repo: ghcr.io
+repo_mode: n/a # values: rw, ro, n/a
image_ns: "{{ image_repo }}/{{ project.org }}/{{ project.name }}"
-docker_entity: "{{ 'image' if image_repo == 'local' else 'manifest' }}"
+docker_entity: "{{ 'image' if repo_mode == 'n/a' else 'manifest' }}"
diff --git a/baker/ansible/roles/image/defaults/main.yaml b/baker/ansible/roles/image/defaults/main.yaml
index 48f0fa1a..028f44bb 100644
--- a/baker/ansible/roles/image/defaults/main.yaml
+++ b/baker/ansible/roles/image/defaults/main.yaml
@@ -1,5 +1,3 @@
---
-image_tag: latest
image_context: .
-image_push: false
image_args: {}
diff --git a/baker/ansible/roles/image/tasks/main.yaml b/baker/ansible/roles/image/tasks/build.yaml
similarity index 74%
rename from baker/ansible/roles/image/tasks/main.yaml
rename to baker/ansible/roles/image/tasks/build.yaml
index c605b065..39a30b84 100644
--- a/baker/ansible/roles/image/tasks/main.yaml
+++ b/baker/ansible/roles/image/tasks/build.yaml
@@ -1,21 +1,22 @@
---
-- name: Enforce variables
+- name: Check inputs
ansible.builtin.assert:
quiet: true
that:
- - image_name is defined
- image_home is defined
- image_key is defined
+ - image_tag is defined
- name: Build image
ansible.builtin.command:
cmd: >-
docker build {{ image_context }}
- --file {{ image_home }}/Dockerfile
+ --file Dockerfile
--label image.key={{ image_key }}
- --tag {{ image_name }}:{{ image_tag }}
+ --tag {{ image_tag }}
{% for key, value in image_args.items() %}
--build-arg {{ key }}={{ value }}
{% endfor %}
strip_empty_ends: false
+ chdir: "{{ image_home }}"
changed_when: true
diff --git a/baker/ansible/roles/image/tasks/clean.yaml b/baker/ansible/roles/image/tasks/clean.yaml
index bd4e2511..ce462875 100644
--- a/baker/ansible/roles/image/tasks/clean.yaml
+++ b/baker/ansible/roles/image/tasks/clean.yaml
@@ -1,5 +1,5 @@
---
-- name: Enforce variables
+- name: Check inputs
ansible.builtin.assert:
quiet: true
that:
diff --git a/baker/ansible/roles/image/tasks/publish.yaml b/baker/ansible/roles/image/tasks/publish.yaml
new file mode 100644
index 00000000..b5f04d4c
--- /dev/null
+++ b/baker/ansible/roles/image/tasks/publish.yaml
@@ -0,0 +1,20 @@
+---
+- name: Check inputs
+ ansible.builtin.assert:
+ quiet: true
+ that:
+ - source_tag is defined
+ - target_tags is defined
+
+- name: Tag images
+ ansible.builtin.command:
+ cmd: docker tag {{ source_tag }} {{ item }}
+ strip_empty_ends: false
+ loop: "{{ target_tags }}"
+
+- name: Push images
+ ansible.builtin.command:
+ cmd: docker push {{ item }}
+ strip_empty_ends: false
+ loop: "{{ target_tags }}"
+ tags: [push, never]
diff --git a/baker/ansible/sources.yaml b/baker/ansible/sources.yaml
index b33d9ea5..2d213bda 100644
--- a/baker/ansible/sources.yaml
+++ b/baker/ansible/sources.yaml
@@ -1,5 +1,5 @@
---
-- name: Sources
+- name: Checking
hosts: java
run_once: true
tasks:
@@ -19,11 +19,11 @@
strip_empty_ends: false
changed_when: false
-- name: Sources
+- name: Checking
hosts: ansible
run_once: true
tasks:
- - name: Analyze
+ - name: Linting
ansible.builtin.command:
# list all top level playbooks
cmd: >-
@@ -33,11 +33,11 @@
strip_empty_ends: false
changed_when: false
-- name: Sources
+- name: Checking
hosts: github
run_once: true
tasks:
- - name: Analyze
+ - name: Linting
ansible.builtin.command:
cmd: yamllint {{ project.dir }}/.github
strip_empty_ends: false
diff --git a/baker/ansible/stacks.yaml b/baker/ansible/stacks.yaml
index 8f4a7669..2b9a44af 100644
--- a/baker/ansible/stacks.yaml
+++ b/baker/ansible/stacks.yaml
@@ -7,19 +7,23 @@
run_once: true
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
- file: tasks/product/status.yaml
+ file: tasks/product/capture.yaml
tags: [always]
-- name: Capturing
+- name: Capturing & Building
hosts: gear
run_once: true
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
- file: tasks/gear/status.yaml
+ file: tasks/gear/capture.yaml
tags: [always]
+ - ansible.builtin.import_tasks: # noqa: name[missing]
+ file: tasks/gear/build.yaml
+ tags: [build]
+ when: hostvars.gear.stack_status is changed
- name: Building & Checking
- hosts: stack
+ hosts: product
run_once: true
vars:
stack_dir: "{{ project.dir }}/stack/product"
@@ -31,8 +35,8 @@
hostvars.product.stack_status is changed or
hostvars.gear.stack_status is changed
- ansible.builtin.import_tasks: # noqa: name[missing]
- file: tasks/product/test.yaml
- tags: [test]
+ file: tasks/product/check.yaml
+ tags: [check]
when: >-
hostvars.product.stack_status is changed or
hostvars.gear.stack_status is changed
@@ -42,15 +46,15 @@
run_once: true
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
- file: tasks/product/package.yaml
- tags: [package]
- when: stack_status is changed
+ file: tasks/product/publish.yaml
+ tags: [publish]
+ when: hostvars.product.stack_status is changed
- name: Publishing
hosts: gear
run_once: true
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
- file: tasks/gear/package.yaml
- tags: [package]
- when: stack_status is changed
+ file: tasks/gear/publish.yaml
+ tags: [publish]
+ when: hostvars.gear.stack_status is changed
diff --git a/baker/ansible/tasks/app/status.yaml b/baker/ansible/tasks/app/capture.yaml
similarity index 66%
rename from baker/ansible/tasks/app/status.yaml
rename to baker/ansible/tasks/app/capture.yaml
index 0029385c..54e40080 100644
--- a/baker/ansible/tasks/app/status.yaml
+++ b/baker/ansible/tasks/app/capture.yaml
@@ -1,5 +1,5 @@
---
-- name: Capture cids
+- name: Capture CID's
ansible.builtin.command:
cmd: git hash-object --stdin
stdin: |
@@ -16,11 +16,11 @@
ansible.builtin.set_fact:
image_tags: >-
{{ dict(image_cid.results
- |map(attribute='stdout')
- |map('truncate', 7, True, '')
- |map('regex_replace', '^', devenv ~ '-')
- |zip(image_cid.results|map(attribute='app.binary'))
- |map('reverse'))
+ | map(attribute='stdout')
+ | map('truncate', 7, True, '')
+ | map('regex_replace', '^', devenv ~ '-')
+ | zip(image_cid.results|map(attribute='app.binary'))
+ | map('reverse'))
}}
- name: Capture statuses
@@ -33,9 +33,4 @@
loop: "{{ product.apps.values()|flatten }}"
loop_control:
loop_var: app
- label: "{{ app.image }}"
-
-- name: Status commands
- ansible.builtin.debug:
- msg: "{{ image_status.results|map(attribute='cmd')|map('join', ' ') }}"
- when: image_status is changed
+ label: "{{ app.image }}:{{ image_tags[app.binary] }}"
diff --git a/baker/ansible/tasks/app/publish.yaml b/baker/ansible/tasks/app/publish.yaml
index 3f5392b4..bdeaac3f 100644
--- a/baker/ansible/tasks/app/publish.yaml
+++ b/baker/ansible/tasks/app/publish.yaml
@@ -1,22 +1,12 @@
---
-- name: Tag images
- ansible.builtin.command:
- cmd: >-
- docker tag
- {{ app.image }}:{{ devenv }}
- {{ image_ns }}/{{ app.image }}:{{ image_tags[app.binary] }}
- strip_empty_ends: false
- loop: "{{ image_status.results|select('changed')|map(attribute='app') }}"
+- ansible.builtin.include_role: # noqa: name[missing]
+ name: image
+ tasks_from: publish
+ vars:
+ source_tag: "{{ app.image }}:{{ devenv }}"
+ target_tags:
+ - "{{ image_ns }}/{{ app.image }}:{{ hostvars.app.image_tags[app.binary] }}"
+ loop: "{{ hostvars.app.image_status.results|select('changed')|map(attribute='app') }}"
loop_control:
loop_var: app
label: "{{ app.image }}"
-
-- name: Push images
- ansible.builtin.command:
- cmd: docker push {{ image_ns }}/{{ app.image }}:{{ image_tags[app.binary] }}
- strip_empty_ends: false
- loop: "{{ image_status.results|select('changed')|map(attribute='app') }}"
- loop_control:
- loop_var: app
- label: "{{ app.image }}"
- tags: [push, never]
diff --git a/baker/ansible/tasks/db/build.yaml b/baker/ansible/tasks/db/build.yaml
index 2b2081e2..ce645497 100644
--- a/baker/ansible/tasks/db/build.yaml
+++ b/baker/ansible/tasks/db/build.yaml
@@ -1,13 +1,12 @@
---
-- name: Build images
- ansible.builtin.include_role:
+- ansible.builtin.include_role: # noqa: name[missing]
name: image
+ tasks_from: build
vars:
image_home: "{{ project.dir }}/{{ db.image }}"
- image_name: "{{ db.image }}"
image_key: "{{ db.image }}/{{ devenv }}"
- image_tag: "{{ devenv }}"
- loop: "{{ image_status.results|select('changed')|map(attribute='db') }}"
+ image_tag: "{{ db.image }}:{{ devenv }}"
+ loop: "{{ hostvars.db.image_status.results|select('changed')|map(attribute='db') }}"
loop_control:
loop_var: db
label: "{{ db.image }}"
diff --git a/baker/ansible/tasks/db/status.yaml b/baker/ansible/tasks/db/capture.yaml
similarity index 61%
rename from baker/ansible/tasks/db/status.yaml
rename to baker/ansible/tasks/db/capture.yaml
index a24d114a..2c61778d 100644
--- a/baker/ansible/tasks/db/status.yaml
+++ b/baker/ansible/tasks/db/capture.yaml
@@ -8,9 +8,4 @@
loop: "{{ product.databases.values() }}"
loop_control:
loop_var: db
- label: "{{ db.image }}"
-
-- name: Status commands
- ansible.builtin.debug:
- msg: "{{ image_status.results|map(attribute='cmd')|map('join', ' ') }}"
- when: image_status is changed
+ label: "{{ db.image }}:{{ db.cid }}"
diff --git a/baker/ansible/tasks/db/publish.yaml b/baker/ansible/tasks/db/publish.yaml
index f246e1b3..2a127563 100644
--- a/baker/ansible/tasks/db/publish.yaml
+++ b/baker/ansible/tasks/db/publish.yaml
@@ -1,19 +1,12 @@
---
-- name: Tag images
- ansible.builtin.command:
- cmd: docker tag {{ db.image }}:{{ devenv }} {{ image_ns }}/{{ db.image }}:{{ db.cid }}
- strip_empty_ends: false
- loop: "{{ image_status.results|select('changed')|map(attribute='db') }}"
+- ansible.builtin.include_role: # noqa: name[missing]
+ name: image
+ tasks_from: publish
+ vars:
+ source_tag: "{{ db.image }}:{{ devenv }}"
+ target_tags:
+ - "{{ image_ns }}/{{ db.image }}:{{ db.cid }}"
+ loop: "{{ hostvars.db.image_status.results|select('changed')|map(attribute='db') }}"
loop_control:
loop_var: db
label: "{{ db.image }}"
-
-- name: Push images
- ansible.builtin.command:
- cmd: docker push {{ image_ns }}/{{ db.image }}:{{ db.cid }}
- strip_empty_ends: false
- loop: "{{ image_status.results|select('changed')|map(attribute='db') }}"
- loop_control:
- loop_var: db
- label: "{{ db.image }}"
- tags: [push, never]
diff --git a/baker/ansible/tasks/gear/build.yaml b/baker/ansible/tasks/gear/build.yaml
index 35232e43..73f160ab 100644
--- a/baker/ansible/tasks/gear/build.yaml
+++ b/baker/ansible/tasks/gear/build.yaml
@@ -1,11 +1,9 @@
---
- ansible.builtin.import_role: # noqa: name[missing]
name: image
+ tasks_from: build
vars:
- image_tag: "{{ gear_tag }}"
- image_name: "{{ image_ns }}/{{ gear.image }}"
- image_home: "{{ project.dir }}/stack/gear/{{ devenv }}"
+ image_home: "{{ project.dir }}/stack/gear"
image_key: "{{ gear.image }}/{{ devenv }}"
- image_push: false
- image_args:
- DOCKER_VERSION: "{{ lookup('ansible.builtin.pipe', 'docker version --format {% raw %}{{.Client.Version}}{% endraw %}') }}" # noqa: yaml[line-length]
+ image_tag: "{{ gear.image }}:{{ devenv }}"
+ when: repo_mode != 'rw'
diff --git a/baker/ansible/tasks/gear/status.yaml b/baker/ansible/tasks/gear/capture.yaml
similarity index 76%
rename from baker/ansible/tasks/gear/status.yaml
rename to baker/ansible/tasks/gear/capture.yaml
index da51e6c3..36f09e56 100644
--- a/baker/ansible/tasks/gear/status.yaml
+++ b/baker/ansible/tasks/gear/capture.yaml
@@ -1,5 +1,5 @@
---
-- name: Capture cid
+- name: Capture CID
ansible.builtin.command:
cmd: git hash-object --stdin
stdin: |
@@ -12,11 +12,11 @@
- name: Declare tag
ansible.builtin.set_fact:
- gear_tag: "{{ devenv }}-{{ stack_cid.stdout[:7] }}"
+ stack_tag: "{{ devenv }}-{{ stack_cid.stdout[:7] }}"
- name: Capture status
ansible.builtin.command:
- cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ gear.image }}:{{ gear_tag }}
+ cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ gear.image }}:{{ stack_tag }}
register: stack_status
changed_when:
- stack_status.rc != 0
@@ -26,3 +26,10 @@
ansible.builtin.debug:
msg: "{{ stack_status.cmd|join(' ') }}"
when: stack_status is changed
+
+- name: Capture env
+ ansible.builtin.command:
+ cmd: test -f /.dockerenv
+ register: is_docker_gear
+ changed_when: false
+ failed_when: false
diff --git a/baker/ansible/tasks/gear/package.yaml b/baker/ansible/tasks/gear/package.yaml
deleted file mode 100644
index d3128bc7..00000000
--- a/baker/ansible/tasks/gear/package.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-- ansible.builtin.import_role: # noqa: name[missing]
- name: image
- vars:
- image_tag: "{{ gear_tag }}"
- image_name: "{{ image_ns }}/{{ gear.image }}"
- image_home: "{{ project.dir }}/stack/gear/{{ devenv }}"
- image_key: "{{ gear.image }}/{{ devenv }}"
- image_push: "{{ image_repo != 'local' }}"
diff --git a/baker/ansible/tasks/gear/publish.yaml b/baker/ansible/tasks/gear/publish.yaml
new file mode 100644
index 00000000..90f20e32
--- /dev/null
+++ b/baker/ansible/tasks/gear/publish.yaml
@@ -0,0 +1,8 @@
+---
+- ansible.builtin.import_role: # noqa: name[missing]
+ name: image
+ tasks_from: publish
+ vars:
+ source_tag: "{{ gear.image }}:{{ devenv }}"
+ target_tags:
+ - "{{ image_ns }}/{{ gear.image }}:{{ hostvars.gear.stack_tag }}"
diff --git a/baker/ansible/tasks/product/build.yaml b/baker/ansible/tasks/product/build.yaml
index 55302072..0db6aad7 100644
--- a/baker/ansible/tasks/product/build.yaml
+++ b/baker/ansible/tasks/product/build.yaml
@@ -25,3 +25,12 @@
lstrip_blocks: yes
trim_blocks: yes
mode: "644"
+
+- ansible.builtin.import_role: # noqa: name[missing]
+ name: image
+ tasks_from: build
+ vars:
+ image_home: "{{ project.dir }}/stack/product"
+ image_context: target/image-context
+ image_key: "{{ product.image }}/{{ opsenv }}"
+ image_tag: "{{ product.image }}:{{ opsenv }}"
diff --git a/baker/ansible/tasks/product/status.yaml b/baker/ansible/tasks/product/capture.yaml
similarity index 86%
rename from baker/ansible/tasks/product/status.yaml
rename to baker/ansible/tasks/product/capture.yaml
index 40450cd5..31959060 100644
--- a/baker/ansible/tasks/product/status.yaml
+++ b/baker/ansible/tasks/product/capture.yaml
@@ -1,5 +1,5 @@
---
-- name: Capture cid
+- name: Capture CID
ansible.builtin.command:
cmd: git hash-object --stdin
stdin: |
@@ -12,11 +12,11 @@
- name: Declare tag
ansible.builtin.set_fact:
- product_tag: "{{ purpose }}-{{ opsenv }}-{{ stack_cid.stdout[:7] }}"
+ stack_tag: "{{ opsenv }}-{{ stack_cid.stdout[:7] }}"
- name: Capture status
ansible.builtin.command:
- cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ product.image }}:{{ product_tag }}
+ cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ product.image }}:{{ stack_tag }}
register: stack_status
changed_when:
- stack_status.rc != 0
diff --git a/baker/ansible/tasks/product/test.yaml b/baker/ansible/tasks/product/check.yaml
similarity index 97%
rename from baker/ansible/tasks/product/test.yaml
rename to baker/ansible/tasks/product/check.yaml
index 0538730d..bb4110ca 100644
--- a/baker/ansible/tasks/product/test.yaml
+++ b/baker/ansible/tasks/product/check.yaml
@@ -34,7 +34,7 @@
--batch-mode
--threads 2
--projects test/e2e
- {% if image_repo != 'local' %}
+ {% if is_docker_gear.rc == 0 %}
--activate-profiles docker
{% endif %}
--also-make
diff --git a/baker/ansible/tasks/product/package.yaml b/baker/ansible/tasks/product/package.yaml
deleted file mode 100644
index 8c589bc0..00000000
--- a/baker/ansible/tasks/product/package.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
----
-- ansible.builtin.import_role: # noqa: name[missing]
- name: image
- vars:
- image_tag: "{{ product_tag }}"
- image_name: "{{ image_ns }}/{{ product.image }}"
- image_home: "{{ project.dir }}/stack/product"
- image_context: target/image-context
- image_key: "{{ product.image }}/{{ purpose }}-{{ opsenv }}"
- image_push: "{{ image_repo != 'local' }}"
diff --git a/baker/ansible/tasks/product/publish.yaml b/baker/ansible/tasks/product/publish.yaml
new file mode 100644
index 00000000..8e979015
--- /dev/null
+++ b/baker/ansible/tasks/product/publish.yaml
@@ -0,0 +1,8 @@
+---
+- ansible.builtin.import_role: # noqa: name[missing]
+ name: image
+ tasks_from: publish
+ vars:
+ source_tag: "{{ product.image }}:{{ opsenv }}"
+ target_tags:
+ - "{{ image_ns }}/{{ product.image }}:{{ hostvars.product.stack_tag }}"
diff --git a/stack/gear/Dockerfile b/stack/gear/Dockerfile
new file mode 100644
index 00000000..65f8bd1e
--- /dev/null
+++ b/stack/gear/Dockerfile
@@ -0,0 +1,3 @@
+# native environment lightweight image
+FROM scratch
+COPY Dockerfile .