Skip to content

Commit 6d4f622

Browse files
authored
Merge pull request #193 from stackhpc/container-promote-mk3
Promote multiple tags simultaneously based on Kayobe config
2 parents f5ae43f + e6dd548 commit 6d4f622

9 files changed

+356
-69
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: Promote container repositories (pre-Zed)
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
filter:
7+
description: Space-separated list of regular expressions matching images to promote
8+
type: string
9+
required: false
10+
default: ""
11+
distros:
12+
description: Space-separated list of base distributions to promote
13+
type: string
14+
required: false
15+
default: ""
16+
tag:
17+
description: Container image tag to promote
18+
required: true
19+
promote-old-images:
20+
description: Whether to promote images for Yoga and older
21+
type: boolean
22+
default: true
23+
promote-new-images:
24+
description: Whether to promote images for Zed and newer
25+
type: boolean
26+
default: true
27+
28+
env:
29+
ANSIBLE_FORCE_COLOR: True
30+
ANSIBLE_VAULT_PASSWORD_FILE: ${{ github.workspace }}/vault-pass
31+
jobs:
32+
container-promote:
33+
name: Promote container repositories
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v3
38+
39+
- name: Setup Release Train & dependencies
40+
uses: ./.github/actions/setup
41+
with:
42+
vault-password: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
43+
vault-password-file: ${{ env.ANSIBLE_VAULT_PASSWORD_FILE }}
44+
45+
- name: Promote images from stackhpc-dev to stackhpc namespace in Ark
46+
run: |
47+
ansible-playbook -i ansible/inventory \
48+
ansible/dev-pulp-container-promote-old.yml \
49+
-e dev_pulp_repository_container_promotion_tag="$TAG" \
50+
-e kolla_container_image_filter="'$FILTER'" \
51+
-e kolla_base_distros_override="'$DISTROS'" \
52+
-e sync_old_images="'$PROMOTE_OLD_IMAGES'" \
53+
-e sync_new_images="'$PROMOTE_NEW_IMAGES'"
54+
env:
55+
TAG: ${{ github.event.inputs.tag }}
56+
FILTER: ${{ github.event.inputs.filter }}
57+
DISTROS: ${{ github.event.inputs.distros }}
58+
PROMOTE_OLD_IMAGES: ${{ github.event.inputs.promote-old-images }}
59+
PROMOTE_NEW_IMAGES: ${{ github.event.inputs.promote-new-images }}

.github/workflows/container-promote.yml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@ on:
88
type: string
99
required: false
1010
default: ""
11-
distros:
12-
description: Space-separated list of base distributions to promote
13-
type: string
14-
required: false
15-
default: ""
16-
tag:
17-
description: Container image tag to promote
11+
kayobe_config_branch:
1812
required: true
19-
promote-old-images:
20-
description: Whether to promote images for Yoga and older
21-
type: boolean
22-
default: true
23-
promote-new-images:
24-
description: Whether to promote images for Zed and newer
13+
description: Branch of StackHPC Kayobe configuration to use
14+
check_mode:
15+
description: Check mode
2516
type: boolean
26-
default: true
17+
required: false
18+
default: false
2719

2820
env:
2921
ANSIBLE_FORCE_COLOR: True
@@ -42,18 +34,25 @@ jobs:
4234
vault-password: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
4335
vault-password-file: ${{ env.ANSIBLE_VAULT_PASSWORD_FILE }}
4436

37+
- name: Clone StackHPC Kayobe configuration repository
38+
uses: actions/checkout@v3
39+
with:
40+
repository: stackhpc/stackhpc-kayobe-config
41+
ref: refs/heads/${{ github.event.inputs.kayobe_config_branch }}
42+
path: stackhpc-kayobe-config
43+
4544
- name: Promote images from stackhpc-dev to stackhpc namespace in Ark
4645
run: |
46+
args=""
47+
if [[ $CHECK_MODE = true ]]; then
48+
args="$args --check --diff"
49+
fi
4750
ansible-playbook -i ansible/inventory \
51+
ansible/dev-pulp-container-tag-query-kayobe.yml \
4852
ansible/dev-pulp-container-promote.yml \
49-
-e dev_pulp_repository_container_promotion_tag="$TAG" \
5053
-e kolla_container_image_filter="'$FILTER'" \
51-
-e kolla_base_distros_override="'$DISTROS'" \
52-
-e sync_old_images="'$PROMOTE_OLD_IMAGES'" \
53-
-e sync_new_images="'$PROMOTE_NEW_IMAGES'"
54+
-e kayobe_config_repo_path=./stackhpc-kayobe-config/ \
55+
$args
5456
env:
55-
TAG: ${{ github.event.inputs.tag }}
5657
FILTER: ${{ github.event.inputs.filter }}
57-
DISTROS: ${{ github.event.inputs.distros }}
58-
PROMOTE_OLD_IMAGES: ${{ github.event.inputs.promote-old-images }}
59-
PROMOTE_NEW_IMAGES: ${{ github.event.inputs.promote-new-images }}
58+
CHECK_MODE: ${{ inputs.check_mode }}

.github/workflows/package-promote.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
required: false
1313
description: Branch of StackHPC Kayobe configuration to use
1414
default: stackhpc/wallaby
15+
check_mode:
16+
description: Check mode
17+
type: boolean
18+
required: false
19+
default: false
1520

1621
env:
1722
ANSIBLE_FORCE_COLOR: True
@@ -39,11 +44,18 @@ jobs:
3944

4045
- name: Promote package repositories in Ark to release
4146
run: |
47+
args=""
48+
if [[ $CHECK_MODE = true ]]; then
49+
args="$args --check --diff"
50+
fi
51+
source venv/bin/activate &&
4252
ansible-playbook -i ansible/inventory \
4353
ansible/dev-pulp-repo-version-query-kayobe.yml \
4454
ansible/dev-pulp-repo-promote.yml \
4555
-e deb_package_repo_filter="'$FILTER'" \
4656
-e rpm_package_repo_filter="'$FILTER'" \
47-
-e kayobe_config_repo_path=./stackhpc-kayobe-config/
57+
-e kayobe_config_repo_path=./stackhpc-kayobe-config/ \
58+
$args
4859
env:
4960
FILTER: ${{ github.event.inputs.filter }}
61+
CHECK_MODE: ${{ inputs.check_mode }}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
# This playbook promotes images in the development namespace (stackhpc-dev) to
3+
# the release namespace (stackhpc). This makes them available to clients.
4+
# Images with a tag defined by dev_pulp_repository_container_promotion_tag are
5+
# promoted.
6+
7+
- name: Promote dev Pulp containers
8+
hosts: localhost
9+
gather_facts: false
10+
tasks:
11+
- name: Fail if container image to promote is not defined
12+
fail:
13+
msg: >
14+
The container image to promote must be specified via
15+
'dev_pulp_repository_container_promotion_tag'
16+
when: dev_pulp_repository_container_promotion_tag is not defined
17+
18+
- debug:
19+
msg: "Promoting tag {{ dev_pulp_repository_container_promotion_tag }}"
20+
21+
# Copy tags from stackhpc-dev to stackhpc repositories.
22+
- import_role:
23+
name: stackhpc.pulp.pulp_container_content
24+
vars:
25+
pulp_url: "{{ dev_pulp_url }}"
26+
pulp_username: "{{ dev_pulp_username }}"
27+
pulp_password: "{{ dev_pulp_password }}"
28+
pulp_container_content: >-
29+
{%- set contents = [] -%}
30+
{%- if sync_old_images | bool -%}
31+
{%- for base_distro in kolla_base_distros -%}
32+
{%- for image in kolla_container_images_filtered -%}
33+
{%- if image not in kolla_unbuildable_images.old_scheme[base_distro] -%}
34+
{%- set src_image_repo = "stackhpc-dev/" ~ base_distro ~ "-source-" ~ image -%}
35+
{%- set dest_image_repo = "stackhpc/" ~ base_distro ~ "-source-" ~ image -%}
36+
{%- set content = {
37+
"allow_missing": True,
38+
"src_repo": src_image_repo,
39+
"src_is_push": true,
40+
"repository": dest_image_repo,
41+
"tags": [dev_pulp_repository_container_promotion_tag],
42+
} -%}
43+
{%- set _ = contents.append(content) -%}
44+
{%- endif -%}
45+
{%- endfor -%}
46+
{%- endfor -%}
47+
{%- endif -%}
48+
{%- if sync_new_images | bool -%}
49+
{%- for image in kolla_container_images_filtered -%}
50+
{%- if image not in kolla_unbuildable_images.new_scheme -%}
51+
{%- set src_image_repo = "stackhpc-dev/" ~ image -%}
52+
{%- set dest_image_repo = "stackhpc/" ~ image -%}
53+
{%- set content = {
54+
"allow_missing": True,
55+
"src_repo": src_image_repo,
56+
"src_is_push": true,
57+
"repository": dest_image_repo,
58+
"tags": [dev_pulp_repository_container_promotion_tag],
59+
} -%}
60+
{%- set _ = contents.append(content) -%}
61+
{%- endif -%}
62+
{%- endfor -%}
63+
{%- endif -%}
64+
{{ contents }}
65+
pulp_container_content_wait: false
Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
---
22
# This playbook promotes images in the development namespace (stackhpc-dev) to
33
# the release namespace (stackhpc). This makes them available to clients.
4-
# Images with a tag defined by dev_pulp_repository_container_promotion_tag are
5-
# promoted.
4+
# Images with a tag defined by dev_pulp_repository_container_promotion_tags are
5+
# promoted. dev_pulp_repository_container_promotion_tags is a dict with the
6+
# following format:
7+
#
8+
# dev_pulp_repository_container_promotion_tags:
9+
# <image name>:
10+
# - <image tag 1>
11+
# - <image tag 2>
612

713
- name: Promote dev Pulp containers
814
hosts: localhost
915
gather_facts: false
1016
tasks:
11-
- name: Fail if container image to promote is not defined
17+
- name: Fail if container images to promote are not defined
1218
fail:
1319
msg: >
14-
The container image to promote must be specified via
15-
'dev_pulp_repository_container_promotion_tag'
16-
when: dev_pulp_repository_container_promotion_tag is not defined
20+
The container images to promote must be specified via
21+
'dev_pulp_repository_container_promotion_tags'
22+
when: dev_pulp_repository_container_promotion_tags is not defined
1723

18-
- debug:
19-
msg: "Promoting tag {{ dev_pulp_repository_container_promotion_tag }}"
24+
- name: Display which tags are being promoted
25+
debug:
26+
var: "dev_pulp_repository_container_promotion_tags"
2027

2128
# Copy tags from stackhpc-dev to stackhpc repositories.
2229
- import_role:
@@ -27,39 +34,17 @@
2734
pulp_password: "{{ dev_pulp_password }}"
2835
pulp_container_content: >-
2936
{%- set contents = [] -%}
30-
{%- if sync_old_images | bool -%}
31-
{%- for base_distro in kolla_base_distros -%}
32-
{%- for image in kolla_container_images_filtered -%}
33-
{%- if image not in kolla_unbuildable_images.old_scheme[base_distro] -%}
34-
{%- set src_image_repo = "stackhpc-dev/" ~ base_distro ~ "-source-" ~ image -%}
35-
{%- set dest_image_repo = "stackhpc/" ~ base_distro ~ "-source-" ~ image -%}
36-
{%- set content = {
37-
"allow_missing": True,
38-
"src_repo": src_image_repo,
39-
"src_is_push": true,
40-
"repository": dest_image_repo,
41-
"tags": [dev_pulp_repository_container_promotion_tag],
42-
} -%}
43-
{%- set _ = contents.append(content) -%}
44-
{%- endif -%}
45-
{%- endfor -%}
46-
{%- endfor -%}
47-
{%- endif -%}
48-
{%- if sync_new_images | bool -%}
49-
{%- for image in kolla_container_images_filtered -%}
50-
{%- if image not in kolla_unbuildable_images.new_scheme -%}
37+
{%- for image, tags in dev_pulp_repository_container_promotion_tags.items() -%}
5138
{%- set src_image_repo = "stackhpc-dev/" ~ image -%}
5239
{%- set dest_image_repo = "stackhpc/" ~ image -%}
5340
{%- set content = {
54-
"allow_missing": True,
41+
"allow_missing": False,
5542
"src_repo": src_image_repo,
5643
"src_is_push": true,
5744
"repository": dest_image_repo,
58-
"tags": [dev_pulp_repository_container_promotion_tag],
45+
"tags": tags,
5946
} -%}
6047
{%- set _ = contents.append(content) -%}
61-
{%- endif -%}
6248
{%- endfor -%}
63-
{%- endif -%}
6449
{{ contents }}
6550
pulp_container_content_wait: false
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
# This playbook queries the Pulp container image tags defined in a Kayobe
3+
# configuration repository (in etc/kayobe/kolla-image-tags.yml). It then sets
4+
# the 'dev_pulp_repository_container_promotion_tags' tag map variable based
5+
# upon those tags, which defines the set of container image tags that
6+
# will be promoted when the dev-pulp-container-promote.yml playbook is run.
7+
8+
- import_playbook: kayobe-container-tag-query.yml
9+
10+
- name: Set dev Pulp container image tags to promote from Kayobe config tags
11+
hosts: localhost
12+
gather_facts: true
13+
tasks:
14+
- name: Set a fact about container image tags to promote
15+
set_fact:
16+
dev_pulp_repository_container_promotion_tags: >-
17+
{{ kayobe_kolla_image_tags |
18+
dict2items |
19+
selectattr('key', 'in', kolla_container_images_filtered) |
20+
items2dict }}
21+
22+
- name: Display container promotion tags facts
23+
debug:
24+
var: dev_pulp_repository_container_promotion_tags
25+
26+
- name: Assert that tags variable is populated
27+
assert:
28+
that:
29+
- dev_pulp_repository_container_promotion_tags | length > 0
30+
msg: >-
31+
Distribution promotion tag variable
32+
'dev_pulp_repository_container_promotion_tags' is empty
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
# This playbook queries the Pulp container image tags defined in a Kayobe
3+
# configuration repository (in etc/kayobe/kolla-image-tags.yml). It then sets
4+
# the 'kayobe_pulp_container_tags' tag map variable based upon those tags.
5+
#
6+
# The kayobe-config repository path should be specified via
7+
# kayobe_config_repo_path.
8+
9+
- name: Query container image tags for Kayobe
10+
hosts: localhost
11+
gather_facts: True
12+
vars:
13+
kayobe_config_repo_path: ""
14+
tasks:
15+
- name: Fail if Kayobe config repo path is not specified
16+
fail:
17+
msg: >
18+
Kayobe config git repository path must be specified via 'kayobe_config_repo_path'.
19+
when: not kayobe_config_repo_path
20+
21+
- name: Fail if Kayobe config repo path is not a directory
22+
fail:
23+
msg: >
24+
Kayobe config git repository path {{ kayobe_config_repo_path }} is not a directory.
25+
when: kayobe_config_repo_path is not directory
26+
27+
- name: List Kayobe Kolla image tags
28+
command:
29+
cmd: >-
30+
{{ kayobe_config_repo_path | realpath }}/tools/kolla-images.py list-tags
31+
chdir: "{{ kayobe_config_repo_path | realpath }}"
32+
register: list_tags
33+
check_mode: false
34+
changed_when: false
35+
36+
- name: Set a fact about Kayobe Kolla image tags
37+
set_fact:
38+
kayobe_kolla_image_tags: "{{ list_tags.stdout | from_yaml }}"
39+
40+
- name: Display Kayobe Kolla image tags
41+
debug:
42+
var: kayobe_kolla_image_tags

0 commit comments

Comments
 (0)