blob: 7cdc9b7556b86a56b047652db4e4b555e44708aa [file] [log] [blame]
Mohammed Naserfef44b12023-01-14 03:36:10 -05001- name: Check if file already exists
2 when: image_manifest_force is false
3 block:
4 - name: Get details about file
5 ansible.builtin.stat:
6 path: "{{ image_manifest_path }}"
7 register: _stat
8
9 - name: Stop if file already exists
10 ansible.builtin.fail:
11 msg: "File {{ image_manifest_path }} already exists, use -e image_manifest_force=true to overwrite"
12 when: _stat.stat.exists
13
14- name: Mirror images
15 when: image_manifest_mirror
Oleksandr Kozachenko39978032023-02-07 04:03:07 +010016 changed_when: false
Mohammed Naserfef44b12023-01-14 03:36:10 -050017 ansible.builtin.command:
Michiel Piscaer03ddc8e2024-04-01 20:56:48 +020018 crane copy {{ atmosphere_images[item] }} {{ image_manifest_data['atmosphere_images'][item] | regex_replace('@sha256:[a-z0-9]+', '') }}
Mohammed Naserfef44b12023-01-14 03:36:10 -050019 loop: |
20 {%- if image_manifest_images is string -%}
21 {{ image_manifest_images | split(',') }}
22 {%- else -%}
23 {{ image_manifest_images }}
24 {%- endif -%}
25
26- name: Write file with image list
27 ansible.builtin.copy:
28 dest: "{{ image_manifest_path }}"
29 content: "{{ image_manifest_data | to_nice_yaml(indent=2) }}"
Tadas Sutkaitis4ace4182023-02-27 04:31:52 +020030 mode: "0644"