Added seed code for caas-kubernetes.
[ta/caas-kubernetes.git] / ansible / roles / service_account_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 # Service account distribution
27 - name: Get service-account key from caas_master1
28   shell: 'rsync -a -e "ssh -o StrictHostKeyChecking=no" {{ users.admin_user_name }}@{{ groups.caas_master[0] }}:{{ caas.cert_path }}/{{ item }} {{ caas.cert_path }}/'
29   become_user: "{{ users.admin_user_name }}"
30   with_items:
31     - "{{ _key }}"
32     - "{{ _cert }}"
33   when: not nodename | search("caas_master1")
34
35 - name: allowing users to access keys
36   acl:
37     name: "{{ item[0] }}"
38     entity: "{{ item[1] }}"
39     etype: user
40     permissions: "r"
41     state: present
42   with_nested:
43     - [ "{{ caas.cert_path }}/{{ _key }}", "{{ caas.cert_path }}/{{ _cert }}" ]
44     - "{{ add_users | default([]) }}"
45   when: not nodename | search("caas_master1")
46
47 - name: removing write permission from cert_path
48   acl:
49     name:  "{{ caas.cert_path }}"
50     entity: "{{ users.admin_user_name }}"
51     etype: user
52     permissions: rx
53     state: present
54   when: not nodename | search("caas_master1")
55   become_user: "root"
56