File tree Expand file tree Collapse file tree 5 files changed +45
-0
lines changed
roles/docker_skip_hosts_in_registry/tasks Expand file tree Collapse file tree 5 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 3
3
# so set gather_facts to no here, and run setup explicitly in the role
4
4
gather_facts : no
5
5
roles :
6
+ - role : docker_skip_hosts_in_registry
7
+ delegate_to : " {{ groups['docker_build_hosts'] | first }}"
8
+ tags :
9
+ - never
10
+ - skip-if-in-registry
11
+
6
12
- role : docker_build_gather_facts
7
13
delegate_to : " {{ groups['docker_build_hosts'] | first }}"
14
+ when : not skip_build_and_push
8
15
9
16
- role : docker_image_build
10
17
delegate_to : " {{ groups['docker_build_hosts'] | first }}"
18
+ when : not skip_build_and_push
Original file line number Diff line number Diff line change @@ -48,3 +48,6 @@ role_build_variants:
48
48
- build_vars :
49
49
primary_build : false
50
50
tag : " {{ version }}-standalone"
51
+
52
+ # skip_build_and_push is overrideable by using the skip-if-in-registry tag, but defaults to false to always perform the build
53
+ skip_build_and_push : false
Original file line number Diff line number Diff line change 2
2
# nothing here should rely on gathered facts
3
3
gather_facts : no
4
4
roles :
5
+ - role : docker_skip_hosts_in_registry
6
+ delegate_to : " {{ groups['docker_build_hosts'] | first }}"
7
+ tags :
8
+ - never
9
+ - skip-if-in-registry
10
+
5
11
- role : docker_image_push
6
12
delegate_to : " {{ groups['docker_build_hosts'] | first }}"
13
+ when : not skip_build_and_push
Original file line number Diff line number Diff line change
1
+ - block :
2
+ - name : " check if {{ repository_push_image }} is missing from the registry"
3
+ command : " docker manifest inspect {{ repository_push_image }}"
4
+ become : " {{ docker_become_user is defined }}"
5
+ become_user : " {{ docker_become_user|default(omit) }}"
6
+ environment :
7
+ DOCKER_CLI_EXPERIMENTAL : enabled
8
+ # we don't need to keep checking after clearing skip_build_and_push
9
+ # only build variants that are configured to push with this configuration should be checked
10
+ when : (build_vars.push_when | default(false)) and skip_build_and_push
11
+
12
+ # when the image doesn't exist in the registry the above returns a non-zero, causing an exception
13
+ rescue :
14
+ - name : image is missing, clear skip_build_and_push
15
+ set_fact :
16
+ skip_build_and_push : false
Original file line number Diff line number Diff line change
1
+ - name : set default to skip build and push
2
+ set_fact :
3
+ skip_build_and_push : true
4
+
5
+ - name : run clear_skip_if_missing for each variant
6
+ include_tasks : clear_skip_if_missing.yml
7
+ vars :
8
+ build_vars : " {{ build_variant.build_vars }}"
9
+ loop : " {{ build_variants }}"
10
+ loop_control :
11
+ loop_var : build_variant
You can’t perform that action at this time.
0 commit comments