blob: 672d25b4d1c3e94885a3d1a491ad3da51135db0f (
plain)
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
|
---
- name: Create local temp dir for OpenShift hosted templates copy
local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX
register: copy_hosted_templates_mktemp
run_once: True
# AUDIT:changed_when: not set here because this task actually
# creates something
- name: Create local temp dir for OpenShift examples copy
local_action: command chmod 755 "{{ copy_hosted_templates_mktemp.stdout }}"
run_once: True
- name: Create tar of OpenShift examples
local_action: command tar -C "{{ role_path }}/files/{{ content_version }}/{{ hosted_deployment_type }}" -cvf "{{ copy_hosted_templates_mktemp.stdout }}/openshift-hosted-templates.tar" .
args:
# Disables the following warning:
# Consider using unarchive module rather than running tar
warn: no
- name: Create local temp dir for OpenShift examples copy
local_action: command chmod 744 "{{ copy_hosted_templates_mktemp.stdout }}/openshift-hosted-templates.tar"
run_once: True
- name: Create remote OpenShift hosted templates directory
file:
dest: "{{ hosted_base }}"
state: directory
mode: 0755
- name: Unarchive the OpenShift hosted templates on the remote
unarchive:
src: "{{ copy_hosted_templates_mktemp.stdout }}/openshift-hosted-templates.tar"
dest: "{{ hosted_base }}/"
- name: Cleanup the OpenShift hosted templates temp dir
local_action: file dest="{{ copy_hosted_templates_mktemp.stdout }}" state=absent
- name: Modify registry paths if registry_url is not registry.access.redhat.com
shell: >
find {{ hosted_base }} -type f | xargs -n 1 sed -i 's|registry.access.redhat.com|{{ registry_host | quote }}|g'
when: registry_host != '' and openshift_hosted_modify_imagestreams | default(openshift_examples_modify_imagestreams | default(False)) | bool
- name: Create temp directory for kubeconfig
command: mktemp -d /tmp/openshift-ansible-XXXXXX
register: mktemp
changed_when: False
- name: Record kubeconfig tmp dir
set_fact:
openshift_hosted_templates_kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
- name: Copy the admin client config(s)
command: >
cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ openshift_hosted_templates_kubeconfig }}
changed_when: False
- name: Create or update hosted templates
command: >
{{ openshift_client_binary }} {{ openshift_hosted_templates_import_command }}
-f {{ hosted_base }}
--config={{ openshift_hosted_templates_kubeconfig }}
-n openshift
register: oht_import_templates
failed_when: "'already exists' not in oht_import_templates.stderr and oht_import_templates.rc != 0"
changed_when: "'created' in oht_import_templates.stdout"
- name: Delete temp directory
file:
name: "{{ mktemp.stdout }}"
state: absent
changed_when: False
|