Move swift authentication data to cm
[ta/caas-lcm.git] / su / roles / su_prepare / tasks / merge-charts.yml
1 ---
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 - name: pause to wait for swift-update to be ready
17   pause:
18     minutes: 1
19
20 - name: authenticate on swift-upgrade
21   uri:
22     url: "{{ caas.swift_update }}/auth/v1.0"
23     headers:
24       X_Auth_User: admin:admin
25       X_Auth_Key: "{{ caas.swift_credential.password }}"
26   register: auth
27
28 - name: get packages
29   uri:
30     url: "{{ caas.swift_update }}/v1.0/AUTH_admin/packages"
31     return_content: yes
32     headers:
33       X_Auth_Token: "{{ auth.x_auth_token }}"
34   register: packages
35
36 - name: get charts from packages
37   set_fact:
38     charts: "{{ (packages.get('content','')|trim).split('\n') | select('search', 'charts.+\\.tgz') | list }}"
39
40 - name: get value files from packages
41   set_fact:
42     value_files: "{{ (packages.get('content','')|trim).split('\n') | select('search', 'releases.+\\.yaml') | list }}"
43   ignore_errors: yes
44
45 - name: create chart directory
46   file:
47     name: /tmp/su_chart
48     state: directory
49
50 - name: download charts
51   args:
52     chdir: /tmp/su_chart
53   command: "curl -O -XGET -H'X-Auth-Token: {{ auth.x_auth_token }}' {{ caas.swift_update }}/v1.0/AUTH_admin/packages/{{ item }}"
54   with_items: "{{ charts }}"
55
56 - name: download value files
57   args:
58     chdir: /tmp/su_chart
59   command: "curl -O -XGET -H'X-Auth-Token: {{ auth.x_auth_token }}' {{ caas.swift_update }}/v1.0/AUTH_admin/packages/{{ item }}"
60   with_items: "{{ value_files }}"
61   ignore_errors: yes
62
63 - name: upload charts via chart-repo
64   args:
65     chdir: /tmp/su_chart/
66   shell: "curl -sS -XPOST --cacert /etc/chart-repo/ssl/ca.pem --cert /etc/chart-repo/ssl/chart-repo?.pem --key /etc/chart-repo/ssl/chart-repo?-key.pem -H 'Content-Type: application/gzip' --data-binary @{{ item | basename }} {{ caas.chart_repo }}/{{ item }}"
67   with_items: "{{ charts }}"
68
69 - name: helm repo update
70   shell: helm repo update default {{ caas.chart_repo }}/charts
71
72 - name: authenticate on swift
73   uri:
74     url: "{{ caas.swift }}/auth/v1.0"
75     headers:
76       X_Auth_User: admin:admin
77       X_Auth_Key: "{{ caas.swift_credential.password }}"
78   register: auth_orig
79   ignore_errors: yes
80
81 - name: upload value file via swift
82   args:
83     chdir: /tmp/su_chart/
84   shell: "curl -XPUT -H 'X-Auth-Token: {{ auth_orig.x_auth_token }}' -T {{ item | basename }} {{ caas.swift }}/v1.0/AUTH_admin/packages/{{ item }}"
85   with_items: "{{ value_files }}"
86   ignore_errors: yes