Mohammed Naser | fef44b1 | 2023-01-14 03:36:10 -0500 | [diff] [blame] | 1 | - 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 Kozachenko | 3997803 | 2023-02-07 04:03:07 +0100 | [diff] [blame] | 16 | changed_when: false |
Mohammed Naser | fef44b1 | 2023-01-14 03:36:10 -0500 | [diff] [blame] | 17 | ansible.builtin.command: |
Michiel Piscaer | 03ddc8e | 2024-04-01 20:56:48 +0200 | [diff] [blame] | 18 | crane copy {{ atmosphere_images[item] }} {{ image_manifest_data['atmosphere_images'][item] | regex_replace('@sha256:[a-z0-9]+', '') }} |
Mohammed Naser | fef44b1 | 2023-01-14 03:36:10 -0500 | [diff] [blame] | 19 | 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 Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 30 | mode: "0644" |