-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathload-container.yml
35 lines (32 loc) · 992 Bytes
/
load-container.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---
- name: Load the container from archive if needed
block:
- name: Check for existing container
community.docker.docker_image_info:
name: "{{ img_name }}"
register: result
- name: Transfer and load the container
block:
- name: Create temp container directory
file:
path: /tmp/dj_ansible
state: directory
owner: root
group: root
mode: 0700
- name: Transfer container archive
copy:
src: "{{ item.src }}"
dest: "{{ img_path }}"
owner: root
group: root
mode: 0700
- name: Import container from archive
community.docker.docker_image:
name: "{{ img_name }}"
load_path: "{{ img_path }}"
source: load
when: not result.images
vars:
img_name: "{{ item.path | splitext | first }}"
img_path: "/tmp/dj_ansible/{{ item.path | basename }}"