Move swift authentication data to cm
[ta/caas-lcm.git] / deploy / roles / clean_chart / tasks / main.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: authenticate on swift
17   uri:
18     url: "{{ caas.swift }}/auth/v1.0"
19     headers:
20       X_Auth_User: admin:admin
21       X_Auth_Key: "{{ caas.swift_credential.password }}"
22   register: auth
23
24 - name: clean charts list file if exists
25   file:
26     path: /tmp/charts_list
27     state: absent
28
29 - name: get current charts list
30   shell: "curl -H'X_Auth_Token: {{ auth.x_auth_token }}' {{ caas.swift }}/v1.0/AUTH_admin/packages > /tmp/charts_list"
31
32 - name: chart_pattern
33   set_fact:
34     chart_pattern: "{{ chart_name | replace('*', '.*') }}"
35
36 - name: version_pattern
37   set_fact:
38     version_pattern: "{{ chart_version | replace('*', '[0-9]+') }}"
39
40 - name: search
41   shell: cat /tmp/charts_list | egrep "charts/{{ chart_pattern }}-[0-9]+\.[0-9]+\.[0-9]+" | egrep "{{ version_pattern }}\.tgz"
42   register: chart_matched
43
44 - name: delete the chart from swift
45   shell: "curl -XDELETE {{ caas.chart_repo }}/{{ item }}"
46   with_items: "{{ chart_matched.stdout_lines }}"
47
48 - name: helm repo update
49   shell: helm repo update default {{ caas.chart_repo }}/charts
50