-
Notifications
You must be signed in to change notification settings - Fork 136
/
10_get_oc.yml
148 lines (133 loc) · 3.95 KB
/
10_get_oc.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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
- name: Check if creating a new disconnected registry and registry exists
set_fact:
registry_creation: true
when:
- not dra_set
- not drm_set
- registry_host_exists
- name: Find any old tmp dirs with OpenShift related binaries
find:
paths: /tmp
patterns: 'ansible.*'
file_type: directory
register: tmp_results
tags:
- cleanup
- getoc
- name: Delete any old tmp dirs with OpenShift related binaries
file:
path: "{{ item['path'] }}"
state: absent
loop: "{{ tmp_results['files'] }}"
tags:
- cleanup
- getoc
- name: Find any existing /usr/local/bin OpenShift binaries
find:
paths: /usr/local/bin
patterns: 'oc,openshift-baremetal-install,kubectl'
register: binary_results
tags:
- cleanup
- getoc
- name: Remove any existing /usr/local/bin OpenShift binaries
file:
path: "{{ item['path'] }}"
state: absent
loop: "{{ binary_results['files'] }}"
become: yes
tags:
- cleanup
- getoc
- name: Create tmp directory to store OpenShift binaries
tempfile:
state: directory
suffix: "{{ release_version }}"
register: tempdiroutput
tags: getoc
- name: Set fact for tmp directory
set_fact:
tempdir: "{{ tempdiroutput.path }}"
tags: getoc
- name: Create tmp directory to store OpenShift binaries on registry host
tempfile:
state: directory
suffix: "{{ release_version }}"
register: registryhost_tempdir
when: registry_creation|bool
delegate_to: "{{ groups['registry_host'][0] }}"
tags:
- getoc
- name: Set fact for tmp directory on registry host
set_fact:
registry_host_tempdir: "{{ registryhost_tempdir.path }}"
when: registry_creation|bool
tags:
- getoc
- name: Setting Fact of which ansible temp file to use
set_fact:
temp_directory_loc: "{{ (registry_creation) | ternary(registry_host_tempdir, tempdir) }}"
tags:
- getoc
- name: Get the ocp client tar gunzip file
get_url:
url: "{{ release_url }}/{{ version }}/openshift-client-linux-{{ release_version }}.tar.gz"
dest: "{{ temp_directory_loc }}"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'
delegate_to: "{{ registry_creation | ternary(groups['registry_host'][0], groups['provisioner'][0]) }}"
tags: getoc
#If the registry host got the tar, lets just copy it to the prov host
# 15_disconnected_registry_create.yml can handle extracting to the registry host already
- name: Get the openshift-client-linux-{{ release_version }}.tar.gz from registry host into temp file on control machine
fetch:
dest: /tmp/
flat: yes
src: "{{ temp_directory_loc }}/openshift-client-linux-{{ release_version }}.tar.gz"
when: registry_creation|bool
delegate_to: "{{ groups['registry_host'][0] }}"
tags:
- getoc
- name: Copy the openshift-client-linux-{{ release_version }}.tar.gz from control machine to the provisioner host
copy:
src: "/tmp/openshift-client-linux-{{ release_version }}.tar.gz"
dest: "{{ tempdir }}/openshift-client-linux-{{ release_version }}.tar.gz"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: 0755
become: yes
when: registry_creation|bool
tags:
- getoc
- name: Remove the temporary copy of the openshift-client-linux-{{ release_version }}.tar.gz on control machine
file:
path: "/tmp/openshift-client-linux-{{ release_version }}.tar.gz"
state: absent
when: registry_creation|bool
delegate_to: localhost
tags:
- getoc
- name: "Untar the openshift-client-linux-{{ release_version }}.tar.gz"
unarchive:
src: "{{ tempdir }}/openshift-client-linux-{{ release_version }}.tar.gz"
dest: "{{ tempdir }}"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'
remote_src: yes
tags: getoc
- name: Copy oc binary to /usr/local/bin
copy:
src: "{{ tempdir }}/{{ item }}"
dest: /usr/local/bin/
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'
remote_src: yes
become: yes
loop:
- kubectl
- oc
tags: getoc