blob: dc9e1009b6563f6856f16bb82f621028e32d51b9 (
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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
---
- name: fetch cloud config
ansible.builtin.fetch:
dest: /tmp/clouds.yaml
src: "{{ ansible_user_dir }}/.config/openstack/clouds.yaml"
flat: "yes"
- name: load cloud config
include_vars: /tmp/clouds.yaml
- name: initialize os_auth_url
ansible.builtin.set_fact:
os_auth_url: "{{ clouds[openstack_user_name].auth.auth_url }}"
- name: add v3 at end of os_auth_url
ansible.builtin.set_fact:
os_auth_url:
"{{ ((os_auth_url[-3:] == 'v3/') or (os_auth_url[-2:] == 'v3')) |
ternary(os_auth_url | regex_replace('/$', ''),
(os_auth_url[-1:] == '/') | ternary(
os_auth_url ~ 'v3',
os_auth_url ~ '/v3')) }}"
- name: set tenant id
ansible.builtin.set_fact:
tenant_id: "{{ clouds[openstack_user_name].auth.project_id }}"
when: clouds[openstack_user_name].auth.project_id is defined
- name: retrieve tenant id
block:
- name: load cloud config
openstack.cloud.os_client_config:
# - name: retrieve info from VNF tenant
# os_project_facts:
# cloud: "{{ openstack_user_name }}"
# name: "{{ openstack_tenant_name }}"
# register: tenant
# ISSUE with shade: You are not authorized to perform the requested action:
# identity:list_projects.
#
# - name: retrieve tenant ID
# set_fact:
# tenant_id: "{{ tenant.ansible_facts.openstack_projects.0.id }}"
- name: retrieve info from VNF tenant -- bash way
shell: >-
set -o pipefail && \
openstack --os-cloud {{ openstack_user_name }} project list -f json |
jq -r '[.[]| select(.Name=="{{ openstack_tenant_name }}") | .ID] |
first'
args:
executable: /bin/bash
changed_when: False
register: tenant
- name: retrieve tenant ID -- bash way
ansible.builtin.set_fact:
tenant_id: "{{ tenant.stdout_lines.0 }}"
when: clouds[openstack_user_name].auth.project_id is not defined
- name: generate openstack info file
ansible.builtin.copy:
content: |
openstack_user_name: {{ openstack_user_name }}
openstack_tenant_name: {{ openstack_tenant_name }}
openstack_tenant_id: {{ tenant_id }}
dest: "{{ base_dir }}/vars/openstack_infos.yml"
delegate_to: localhost
- name: generate encrypted password for robot
shell: |
set -o pipefail &&\
echo -n '{{ clouds[openstack_user_name].auth.password }}' |
openssl aes-128-ecb -e -K `cat encryption.key` -nosalt |
xxd -c 256 -p
args:
chdir: "{{ oom_path }}/kubernetes/so/resources/config/mso"
executable: /bin/bash
changed_when: false
register: shell
- name: save robot encrypted password
ansible.builtin.set_fact:
robot_encrypted_password: "{{ shell.stdout }}"
- name: set so_crypto container name
set_fact:
so_crypto: "{{ proxy_for_dockerhub }}/sdesbure/so_crypto"
when: proxy_for_dockerhub | bool
- name: set so_crypto container name
set_fact:
so_crypto: "sdesbure/so_crypto"
when: not proxy_for_dockerhub | bool
- name: generate encrypted password for so
shell: >
docker run --rm {{ so_crypto }}
{{ clouds[openstack_user_name].auth.password }}
`cat encryption.key`
args:
chdir: "{{ oom_path }}/kubernetes/so/resources/config/mso"
changed_when: False
register: shell
- name: save so encrypted password
ansible.builtin.set_fact:
encrypted_password: "{{ shell.stdout }}"
- name: create config override directory
ansible.builtin.file:
path: "{{ oom_etc_path }}"
recurse: "yes"
state: directory
- name: check if a deployment has already been done
ansible.builtin.stat:
path: "{{ deployment_file }}"
register: deployment_stat
- name: get deployment.yaml
when: deployment_stat.stat.exists
block:
- name: create temporary local file for deployment.yaml
ansible.builtin.tempfile:
state: file
suffix: temp
register: tmp_deployment
delegate_to: "127.0.0.1"
- name: fetch deployment info
ansible.builtin.fetch:
dest: "{{ tmp_deployment.path }}"
src: "{{ deployment_file }}"
flat: "yes"
- name: load deployment info
include_vars:
file: "{{ tmp_deployment.path }}"
- name: change deployment type if needed
ansible.builtin.set_fact:
deployment_type: "{{ deployment }}"
when: deployment_type == "micro" or
(deployment_type == "small" and deployment != "micro" ) or
deployment == "full"
always:
- name: destroy the local tmp_deployment
ansible.builtin.file:
path: "{{ tmp_deployment.path }}"
state: absent
delegate_to: "127.0.0.1"
- name: "generate config override template for deployment {{ deployment_type }}"
ansible.builtin.template:
src: onap-overrides.yaml.j2
dest: "{{ override_file }}"
- name: check if pre generated component override file exists
ansible.builtin.stat:
path: "{{ base_dir }}/vars/components-overrides.yml"
delegate_to: localhost
register: stat
- name: copy pre generated component override file
ansible.builtin.copy:
dest: "{{ override_components }}"
src: "{{ base_dir }}/vars/components-overrides.yml"
when: stat.stat.exists
- name: "generate config override template for deployment {{ deployment_type }}"
ansible.builtin.template:
src: components-overrides.yaml.j2
dest: "{{ override_components }}"
when: (not stat.stat.exists) and (core_onap or small_onap or medium_onap)
- name: "generate so override template"
ansible.builtin.template:
src: so-overrides.yaml.j2
dest: "{{ override_gating_component }}"
when: project == 'so'
- name: save on which step we are
ansible.builtin.copy:
content: |
---
deployment: {{ deployment_type }}
dest: "{{ deployment_file }}"
- name: "[facts retrieved] get first node IP address (case ip not defined)"
ansible.builtin.set_fact:
first_node_ip: "{{
hostvars[groups['kube-node'].0].ansible_default_ipv4.address }}"
when: gather_nodes_fact
- name: "[No Facts retrieved] get first node IP address (case ip not defined)"
ansible.builtin.set_fact:
first_node_ip: "{{ hostvars[groups['kube-node'].0].ip }}"
when: not gather_nodes_fact
- name: generate etc/hosts for utilities
become: "yes"
ansible.builtin.blockinfile:
path: /etc/hosts
marker: "# {mark} ANSIBLE MANAGED UTILITIES HOSTS"
block: |
{{ first_node_ip }} minio.minio
{{ first_node_ip }} {{ postgres_svc }}.{{ postgres_namespace }}
|