Added seed code for caas-kubernetes.
[ta/caas-kubernetes.git] / ansible / roles / kube_secret_key_creation / 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: check instance secret
17   stat:
18     path: "{{ caas.cert_path }}/{{ caas._secrets_conf }}"
19   register: secrets_conf
20
21 - name: Generate key
22   command: "bash -c \"head -c 32 /dev/urandom | base64 -i - \""
23   register: kube_secret_enc_key
24   no_log: True
25   when: not secrets_conf.stat.exists
26
27 - name: template secrets.conf
28   template:
29     src: "secrets.conf"
30     dest: "{{ caas.cert_path }}/{{ caas._secrets_conf }}"
31     mode: 0000
32   when: not secrets_conf.stat.exists
33
34 - name: adding default acl read to {{ users.admin_user_name }} to {{ caas.cert_path }}/{{ caas._secrets_conf }}
35   acl:
36     name:  "{{ caas.cert_path }}/{{ caas._secrets_conf }}"
37     entity: "{{ users.admin_user_name }}"
38     etype: user
39     permissions: rx
40     state: present
41   when: not secrets_conf.stat.exists