Ansible-playbook files for SSL Support
[ealt-edge.git] / ocd / infra / playbooks / roles / mepserver / tasks / install.yml
1 # Copyright 2020 Huawei Technologies Co., Ltd.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 ---
16 - name: mep namespace
17   shell:
18     cmd: kubectl create namespace mep
19   ignore_errors: 'True'
20
21 - name: copy deploy folder to mep node to install mepserver
22   copy:
23     src: deploy
24     dest: /tmp/mepserver/
25
26 - name: Generate Certificates
27   shell:
28 # yamllint disable rule:line-length
29     cmd: openssl genrsa -out ca.key 2048
30     chdir: /tmp/mepserver/deploy/
31
32 - name: Generate Certificate - Step 2
33   shell:
34     cmd: openssl req -new -key ca.key -subj /C=CN/ST=Peking/L=Beijing/O=ealtedge/CN=www.ealtedge.org -out ca.csr
35     chdir: /tmp/mepserver/deploy/
36
37 - name: Generate Root Certificate
38   shell:
39     cmd: openssl x509 -req -days 365 -in ca.csr -extensions v3_req -signkey ca.key -out trust.cer
40     chdir: /tmp/mepserver/deploy/
41
42 - name: Generate TLS certificate and TLS Key
43   shell:
44     cmd: openssl genrsa -out server_key.pem 2048
45     chdir: /tmp/mepserver/deploy/
46
47 - name: Generate TLS Certificate and TLS Key
48   shell:
49     cmd: openssl req -new -key server_key.pem -subj /C=CN/ST=Beijing/L=Beijing/O=ealtedge/CN=www.ealtedge.org -out tls.csr
50     chdir: /tmp/mepserver/deploy/
51
52 - name: Generate TLS Certificate and TLS Key
53   shell:
54     cmd: openssl x509 -req -in tls.csr -extensions v3_req -CA trust.cer -CAkey ca.key -CAcreateserial -out server.cer
55     chdir: /tmp/mepserver/deploy/
56
57 - name: Create mepssl-secret
58   shell:
59 # yamllint disable rule:line-length
60     cmd: kubectl create secret --namespace mep generic mepssl-secret --from-file=/tmp/mepserver/deploy/server.cer --from-file=/tmp/mepserver/deploy/server_key.pem --from-file=/tmp/mepserver/deploy/trust.cer
61
62 - name: Create kongssl-secret
63   shell:
64 # yamllint disable rule:line-length
65     cmd: kubectl create secret --namespace mep generic kongssl-secret --from-file=/tmp/mepserver/deploy/server.cer --from-file=/tmp/mepserver/deploy/server_key.pem --from-file=/tmp/mepserver/deploy/trust.cer
66
67 - name: Apply mep-basic.yaml
68   shell:
69     cmd: kubectl apply -f /tmp/mepserver/deploy/mep-basic.yaml
70
71 - name: Apply mep-k8s.yaml
72   shell:
73     cmd: kubectl apply -f /tmp/mepserver/deploy/mep-k8s.yaml
74
75 - name: Apply kong-k8s.yaml
76   shell:
77     cmd: kubectl apply -f /tmp/mepserver/deploy/kong-k8s.yaml
78
79 - name: Apply postgres-k8s.yaml
80   shell:
81     cmd: kubectl apply -f /tmp/mepserver/deploy/postgres-k8s.yaml
82
83 - name: -----Configuring Kong API Gateway-----
84   shell:
85     cmd: sleep 30
86
87 - name: Configuring Kong API Gateway
88   shell:
89     cmd: chmod +x kongconfig.sh && ./kongconfig.sh
90     chdir: /tmp/mepserver/deploy/