-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassing-image.yaml
More file actions
executable file
·77 lines (65 loc) · 2.01 KB
/
passing-image.yaml
File metadata and controls
executable file
·77 lines (65 loc) · 2.01 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env ansible-playbook
- hosts: staging
gather_facts: True
vars_files:
- ./variables/common.yaml
tasks:
- name: Print variable
debug:
msg: "{{ ansible_fqdn }}"
- name: Docker login and pull image from Github registry
shell: |
echo {{ access_token }} | docker login -u {{ access_user }} {{ registry_image }} --password-stdin
docker pull {{ registry_image }}:{{ version }}
args:
executable: /bin/bash
register: shell_result
- name: Print Result
debug:
msg: "{{ shell_result.stdout }}"
- name: Archive docker image
shell: |
echo {{ access_token }} | docker login -u {{ access_user }} {{ registry_image }} --password-stdin
docker save -o /tmp/{{ container_name }}.tar {{ registry_image }}:{{ version }}
du -shx /tmp/{{ container_name }}.tar
args:
executable: /bin/bash
register: shell_result
- name: Print Result
debug:
msg: "{{ shell_result.stdout }}"
- name: Fetch achived image to local container
fetch:
src: /tmp/{{ container_name }}.tar
dest: /tmp/{{ container_name }}.tar
flat: yes
- name: Remove achived image remote
file:
path: /tmp/{{ container_name }}.tar
state: absent
force: yes
- hosts: "{{ kubernetes_node4 }}"
gather_facts: True
vars_files:
- ./variables/common.yaml
tasks:
- name: Print variable
debug:
msg: "{{ ansible_fqdn }}"
- name: Copy achived image from container to remote Kubernetes node"
copy:
src: /tmp/{{ container_name }}.tar
dest: /tmp/{{ container_name }}.tar
owner: root
group: root
- name: Docker load achived image
shell: |
docker load --input {{ container_name }}.tar
docker images | grep {{ container_name }}
args:
chdir: /tmp
executable: /bin/bash
register: shell_result
- name: Print Result
debug:
msg: "{{ shell_result.stdout }}"