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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 - name: concat certs for apiserver part 1
17 shell: "cat {{ caas.cert_path }}/apiserver{{ nodeindex }}.pem > {{ caas.cert_path }}/tls-cert.pem"
20 - name: concat certs for apiserver part 2
21 shell: "cat {{ caas.cert_path }}/ca.pem >> {{ caas.cert_path }}/tls-cert.pem"
24 - name: reducing permission of key file and cert file
26 path: "{{ caas.cert_path }}/tls-cert.pem"
30 - name: adding default acl read to {{ users.admin_user_name }} to {{ caas.cert_path }}/tls-cert.epm
32 name: "{{ caas.cert_path }}/tls-cert.pem"
33 entity: "{{ users.admin_user_name }}"
39 - name: adding default acl read to kube to {{ cert_path }}/tls-cert.epm
41 name: "{{ caas.cert_path }}/tls-cert.pem"
48 - name: set permission ca.pem and ca-key.pem
56 - "/etc/openssl/ca.pem"
57 - "/etc/openssl/ca-key.pem"
60 - name: create directory for kubernetes_audit_log
62 path: /var/log/audit/kube_apiserver
64 owner: "{{ caas.uid.kube }}"
65 group: "{{ caas.uid.kube }}"
69 - name: create directory for audit policy
71 path: "{{ caas.caas_policy_directory }}"
76 - name: template audit policy
78 src: audit-policy.yaml
79 dest: "{{ caas.caas_policy_directory }}/audit-policy.yaml"
83 - name: set permission to audit-policy.yaml
85 name: "{{ caas.caas_policy_directory }}/audit-policy.yaml"
91 - "{{ caas.uid.kube }}"
92 - "{{ users.admin_user_name }}"
95 - name: template apiserver
97 apiserver: "{{ ansible_host }}"
98 apiserver_port: "{{ caas.apiserver_secure_port }}"
101 dest: /etc/kubernetes/manifests/apiserver.yml
104 - name: wait for container to start
106 host: "{{ ansible_host }}"
107 port: "{{ caas.apiserver_secure_port }}"
109 timeout: "{{ caas.container_wait_timeout }}"
111 - name: check for namespace
112 command: '/usr/bin/curl -I
113 https://{{ ansible_host }}:{{ caas.apiserver_secure_port }}/api/v1/namespaces/kube-system
114 --key /etc/kubernetes/ssl/kubelet{{ nodeindex }}-key.pem
115 --cert /etc/kubernetes/ssl/kubelet{{ nodeindex }}.pem
116 --cacert /etc/openssl/ca.pem'
117 register: namespace_check
120 - name: insert namespace
121 command: '/usr/bin/curl -i
122 https://{{ ansible_host }}:{{ caas.apiserver_secure_port }}/api/v1/namespaces
124 -H "Content-Type: application/json"
125 --key /etc/kubernetes/ssl/kubelet{{ nodeindex }}-key.pem
126 --cert /etc/kubernetes/ssl/kubelet{{ nodeindex }}.pem
127 --cacert /etc/openssl/ca.pem
128 -d ''{"apiVersion":"v1","kind":"Namespace","metadata":{"name":"kube-system"}}'''
129 when: namespace_check.stdout.find('200 OK') != -1
131 - name: template manifests
133 apiserver: "{{ caas.apiserver_svc_ip }}"
134 apiserver_port: "{{ caas.apiserver_svc_port }}"
137 dest: "/etc/kubernetes/manifests/{{ item }}"