Skip to content

Commit

Permalink
Add stacker tool (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok authored Mar 30, 2024
1 parent 8b90064 commit 57d4e12
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ updates:
junit-platform:
patterns:
- "org.junit*"
jetbrains-kotlin:
patterns:
- "org.jetbrains.kotlin*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
8 changes: 4 additions & 4 deletions orchestrator/ansible/images.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: ALL IMAGES
hosts: images
hosts: images:builder
tasks:
- ansible.builtin.include_tasks: # noqa: name[missing]
file: tasks/{{ inventory_hostname }}/capture.yaml
Expand All @@ -11,13 +11,13 @@
file: tasks/{{ inventory_hostname }}/build.yaml
when: hostvars[inventory_hostname].image_status is changed

# building everything without exception otherwise purely external libs will not be published
# TODO: build only changed apps and purely external libs which have no dependees
- import_playbook: binaries.yaml # noqa: name[play]
vars:
maven_phase: "{{ 'deploy' if repo_mode == 'rw' else 'install' }}"
maven_phase: "{{ 'deploy' if repo_mode == 'rw' and hostvars.app.image_status is changed else 'install' }}"
when: >-
hostvars.app.image_status is changed or
hostvars.tool.image_status is changed
hostvars.builder.image_status is changed
- name: ALL IMAGES
hosts: images
Expand Down
5 changes: 4 additions & 1 deletion orchestrator/ansible/inventory/aliases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ images:
hosts:
db:
app:
tool:
stacks:
hosts:
gear:
pipeline:
product:
tools:
hosts:
builder:
stacker:
all:
vars:
ansible_connection: local
21 changes: 11 additions & 10 deletions orchestrator/ansible/stacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- import_playbook: images.yaml # noqa: name[play]

- name: ALL STACKS
hosts: stacks
hosts: stacks:stacker
tasks:
- ansible.builtin.include_tasks: # noqa: name[missing]
file: tasks/{{ inventory_hostname }}/capture.yaml
Expand All @@ -16,12 +16,12 @@
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/ansible/check.yaml
tags: [build]
when: stack_status is changed
when: image_status is changed
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/gear/build.yaml
tags: [build]
when: >-
stack_status is changed and
image_status is changed and
is_virtual.rc != 0
- name: PIPELINE STACK
Expand All @@ -30,7 +30,7 @@
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/yaml/check.yaml
tags: [build]
when: stack_status is changed
when: image_status is changed

- name: PRODUCT STACK
hosts: product
Expand All @@ -41,21 +41,22 @@
file: tasks/product/build.yaml
tags: [build]
when: >-
hostvars.product.stack_status is changed or
hostvars.gear.stack_status is changed
hostvars.product.image_status is changed or
hostvars.stacker.image_status is changed
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/product/check.yaml
tags: [check]
when: >-
hostvars.product.stack_status is changed or
hostvars.gear.stack_status is changed
hostvars.product.image_status is changed or
hostvars.stacker.image_status is changed or
hostvars.builder.image_status is changed
- name: ALL STACKS
hosts: stacks
hosts: stacks:tools
tasks:
- ansible.builtin.include_tasks: # noqa: name[missing]
file: tasks/{{ inventory_hostname }}/publish.yaml
apply:
tags: [publish]
tags: [publish]
when: hostvars[inventory_hostname].stack_status is changed
when: hostvars[inventory_hostname].image_status is changed
1 change: 1 addition & 0 deletions orchestrator/ansible/tasks/builder/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# build right before publishing
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@
image_context: .
image_key: "tool/builder/{{ devenv }}"
image_tag: "tool/builder:{{ devenv }}"

- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: publish
vars:
image_source_tag: "tool/builder:{{ devenv }}"
image_target_tags:
- "{{ image_ns }}/tool/builder:{{ hostvars.builder.package_tag }}"
6 changes: 4 additions & 2 deletions orchestrator/ansible/tasks/gear/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
ansible.builtin.command:
cmd: git hash-object --stdin
stdin: |
{{ lookup('ansible.builtin.pipe', 'git rev-parse :pom.xml') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=tool') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=test') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=orchestrator') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=stack/gear/env/' ~ devenv) }}
Expand All @@ -17,10 +19,10 @@
- name: Capture statuses
ansible.builtin.command:
cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ item }}
register: stack_status
register: image_status
failed_when: false
changed_when:
- stack_status.rc != 0
- image_status.rc != 0
loop:
- "{{ gear.image }}:{{ stack_tag }}"

Expand Down
4 changes: 2 additions & 2 deletions orchestrator/ansible/tasks/pipeline/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
- name: Capture statuses
ansible.builtin.command:
cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ item }}
register: stack_status
register: image_status
failed_when: false
changed_when:
- stack_status.rc != 0
- image_status.rc != 0
loop:
- "{{ pipeline.image }}:{{ stack_tag }}"
4 changes: 2 additions & 2 deletions orchestrator/ansible/tasks/product/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
- name: Capture statuses
ansible.builtin.command:
cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ item }}
register: stack_status
register: image_status
failed_when: false
changed_when:
- stack_status.rc != 0
- image_status.rc != 0
loop:
- "{{ product.image }}:{{ stack_tag }}"

Expand Down
25 changes: 25 additions & 0 deletions orchestrator/ansible/tasks/stacker/capture.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Capture CID
ansible.builtin.command:
cmd: git hash-object --stdin
stdin: |
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=test') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=stack/gear/env/' ~ devenv) }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=orchestrator/ansible/tasks/product') }}
register: package_cid
changed_when: false

- name: Declare tag
ansible.builtin.set_fact:
package_tag: "{{ devenv }}-{{ package_cid.stdout[:7] }}"
changed_when: false

- name: Capture status
ansible.builtin.command:
cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ item }}
register: image_status
failed_when: false
changed_when:
- image_status.rc != 0
loop:
- "tool/stacker:{{ package_tag }}"
24 changes: 24 additions & 0 deletions orchestrator/ansible/tasks/stacker/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: clean
vars:
image_keys:
- "tool/stacker/{{ devenv }}"

- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: build
vars:
image_home: "{{ project.dir }}/tool"
image_context: .
image_key: "tool/stacker/{{ devenv }}"
image_tag: "tool/stacker:{{ devenv }}"

- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: publish
vars:
image_source_tag: "tool/stacker:{{ devenv }}"
image_target_tags:
- "{{ image_ns }}/tool/stacker:{{ hostvars.stacker.package_tag }}"
8 changes: 0 additions & 8 deletions orchestrator/ansible/tasks/tool/publish.yaml

This file was deleted.

0 comments on commit 57d4e12

Please sign in to comment.