Added seed code for caas-kubernetes.
[ta/caas-kubernetes.git] / ansible / roles / kube_token_distribution / 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: Create directory for kube token
17   file:
18     path: "{{ caas.cert_path }}"
19     state: directory
20     recurse: yes
21
22 - name: Check token
23   stat:
24     path: "{{ caas.cert_path }}/{{ caas.token_filename }}"
25   register: token_file
26   when: not nodename | search("caas_master")
27
28 - name: adding acl read to write cert_path
29   acl:
30     name:  "{{ caas.cert_path }}"
31     entity: "{{ users.admin_user_name }}"
32     etype: user
33     permissions: rwx
34     state: present
35
36 - name: Send kube token
37   synchronize:
38     src: "{{ caas.cert_path }}/{{ caas.token_filename }}"
39     dest: "{{ caas.cert_path }}/{{ caas.token_filename }}"
40     rsync_opts:
41       - "-A"
42       - "-X"
43   when: not nodename | search("caas_master") and not token_file.stat.exists
44
45 - name: Check token
46   stat:
47     path: "{{ caas.cert_path }}/{{ caas.tokenscsv_filename }}"
48   register: tokencsv_file
49   when: nodename | search("caas_master") and not nodename | search("caas_master1")
50
51 - name: Get kube tokens.csv
52   synchronize:
53     src: "{{ caas.cert_path }}/{{ caas.tokenscsv_filename }}"
54     dest: "{{ caas.cert_path }}/{{ caas.tokenscsv_filename }}"
55     rsync_opts:
56       - "-A"
57       - "-X"
58   when: nodename | search("caas_master") and not nodename | search("caas_master1") and not tokencsv_file.stat.exists
59
60 - name: remove acl read to write cert_path
61   acl:
62     name:  "{{ caas.cert_path }}"
63     entity: "{{ users.admin_user_name }}"
64     etype: user
65     permissions: rx
66     state: present