Added seed code for caas-kubernetes.
[ta/caas-kubernetes.git] / ansible / roles / kube_secret_key_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: adding acl read to write cert_path
17   acl:
18     name:  "{{ caas.cert_path }}"
19     entity: "{{ users.admin_user_name }}"
20     etype: user
21     permissions: rwx
22     state: present
23   when: not nodename | search("caas_master1")
24   become_user: "root"
25
26 # Kube secrets distribution
27 - name: Get kube secrets.conf
28   shell: 'rsync -a -e "ssh -o StrictHostKeyChecking=no" {{ users.admin_user_name }}@{{ groups.caas_master[0] }}:{{ caas.cert_path }}/{{ caas._secrets_conf }} {{ caas.cert_path }}/'
29   become_user: "{{ users.admin_user_name }}"
30   when: not nodename | search("caas_master1")
31
32 - file:
33     path: "{{ caas.cert_path }}/{{ caas._secrets_conf }}"
34     owner: root
35     group: root
36   become_user: "root"
37
38 - name: allowing users to access keys
39   acl:
40     name: "{{ item[0] }}"
41     entity: "{{ item[1] }}"
42     etype: user
43     permissions: "r"
44     state: present
45   with_nested:
46     - [ "{{ caas.cert_path }}/{{ caas._secrets_conf }}" ]
47     - "{{ caas.kubernetes_secret_users | default([]) }}"
48   become_user: "root"
49
50 - name: removing write permission from cert_path
51   acl:
52     name:  "{{ caas.cert_path }}"
53     entity: "{{ users.admin_user_name }}"
54     etype: user
55     permissions: rx
56     state: present
57   when: not nodename | search("caas_master1")
58   become_user: "root"
59