1 # Copyright 2020 Huawei Technologies Co., Ltd.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 - name: Doing deployment setup for edge gallery
23 - name: Import config file
25 file: ../../../config.yml
28 - name: Remove old dir
29 command: rm -rf /tmp/.mep_tmp_cer
34 command: mkdir -p /tmp/.mep_tmp_cer
38 - name: Openssl genrsa
39 command: openssl genrsa -out ca.key 2048
41 chdir: /tmp/.mep_tmp_cer/
44 # yamllint disable rule:line-length
45 command: openssl req -new -key ca.key -subj /C=CN/ST=Peking/L=Beijing/O=edgegallery/CN=edgegallery -out ca.csr
46 # yamllint disable rule:line-length
48 chdir: /tmp/.mep_tmp_cer/
50 - name: Sing key with ca key and ca crt
51 # yamllint disable rule:line-length
52 command: openssl x509 -req -days 365 -in ca.csr -extensions v3_ca -signkey ca.key -out ca.crt
53 # yamllint disable rule:line-length
55 chdir: /tmp/.mep_tmp_cer/
57 - name: Openssl genrsa
58 command: openssl genrsa -out mepserver_tls.key 2048
60 chdir: /tmp/.mep_tmp_cer/
62 - name: Openssl rsa mep tls with common pwd
63 # yamllint disable rule:line-length
64 command: openssl rsa -in mepserver_tls.key -aes256 -passout pass:{{ vardata.common_pwd.name}} -out mepserver_encryptedtls.key
65 # yamllint disable rule:line-length
67 chdir: /tmp/.mep_tmp_cer/
68 when: '{{ vardata.common_pwd.name}}'
70 - name: Openssl rsa mep tls
71 # yamllint disable rule:line-length
72 command: openssl rsa -in mepserver_tls.key -aes256 -passout pass:{{ vardata.mep_cert_pwd.name}} -out mepserver_encryptedtls.key
73 # yamllint disable rule:line-length
75 chdir: /tmp/.mep_tmp_cer/
76 when: '{{ vardata.mep_cert_pwd.name}}'
78 - name: Openssl req new key mepserver tls key
79 # yamllint disable rule:line-length
80 command: openssl req -new -key mepserver_tls.key -subj /C=CN/ST=Beijing/L=Beijing/O=edgegallery/CN=edgegallery -out mepserver_tls.csr
81 # yamllint disable rule:line-length
83 chdir: /tmp/.mep_tmp_cer/
85 - name: Openssl mepserver tls csr
86 # yamllint disable rule:line-length
87 command: openssl x509 -req -in mepserver_tls.csr -extensions v3_req -CA ca.crt -CAkey ca.key -CAcreateserial -out mepserver_tls.crt
88 # yamllint disable rule:line-length
90 chdir: /tmp/.mep_tmp_cer/
92 - name: Openssl genrsa out
93 command: openssl genrsa -out jwt_privatekey 2048
95 chdir: /tmp/.mep_tmp_cer/
97 - name: Openssl rsa jwt privatekey
98 command: openssl rsa -in jwt_privatekey -pubout -out jwt_publickey
100 chdir: /tmp/.mep_tmp_cer/
102 - name: Openssl rsa in jwt with common pwd
103 # yamllint disable rule:line-length
104 command: openssl rsa -in jwt_privatekey -aes256 -passout pass:{{ vardata.common_pwd.name}} -out jwt_encrypted_privatekey
105 # yamllint disable rule:line-length
107 chdir: /tmp/.mep_tmp_cer/
108 when: '{{ vardata.common_pwd.name}}'
110 - name: Openssl rsa in jwt
111 # yamllint disable rule:line-length
112 command: openssl rsa -in jwt_privatekey -aes256 -passout pass:{{ vardata.mep_cert_pwd.name}} -out jwt_encrypted_privatekey
113 # yamllint disable rule:line-length
115 chdir: /tmp/.mep_tmp_cer/
116 when: '{{ vardata.mep_cert_pwd.name}}'
118 - name: Create mep namespace
119 command: kubectl create ns mep
123 - name: Create generic pg secret with common pwd
124 # yamllint disable rule:line-length
125 command: kubectl -n mep create secret generic pg-secret --from-literal=pg_admin_pwd={{ vardata.common_pwd.name}} --from-literal=kong_pg_pwd={{ vardata.common_pwd.name}}
126 --from-file=server.key=/tmp/.mep_tmp_cer/mepserver_tls.key --from-file=server.crt=/tmp/.mep_tmp_cer/mepserver_tls.crt
127 # yamllint disable rule:line-length
130 when: '{{ vardata.common_pwd.name}}'
132 - name: Create generic pg secret
133 # yamllint disable rule:line-length
134 command: kubectl -n mep create secret generic pg-secret --from-literal=pg_admin_pwd={{ vardata.mep_pg_admin_pwd.name}} --from-literal=kong_pg_pwd={{ vardata.mep_kong_pg_pwd.name}}
135 --from-file=server.key=/tmp/.mep_tmp_cer/mepserver_tls.key --from-file=server.crt=/tmp/.mep_tmp_cer/mepserver_tls.crt
136 # yamllint disable rule:line-length
139 when: '{{ vardata.mep_pg_admin_pwd.name}}'
141 - name: Create mep generic for mep ssl with common pwd
142 # yamllint disable rule:line-length
143 command: kubectl -n mep create secret generic mep-ssl --from-literal=cert_pwd={{ vardata.common_pwd.name}} --from-file=server.cer=/tmp/.mep_tmp_cer/mepserver_tls.crt
144 --from-file=server_key.pem=/tmp/.mep_tmp_cer/mepserver_encryptedtls.key --from-file=trust.cer=/tmp/.mep_tmp_cer/ca.crt
145 # yamllint disable rule:line-length
148 when: '{{ vardata.common_pwd.name}}'
150 - name: Create mep generic for mep ssl
151 # yamllint disable rule:line-length
152 command: kubectl -n mep create secret generic mep-ssl --from-literal=cert_pwd={{ vardata.mep_cert_pwd.name}} --from-file=server.cer=/tmp/.mep_tmp_cer/mepserver_tls.crt
153 --from-file=server_key.pem=/tmp/.mep_tmp_cer/mepserver_encryptedtls.key --from-file=trust.cer=/tmp/.mep_tmp_cer/ca.crt
154 # yamllint disable rule:line-length
157 when: '{{ vardata.mep_cert_pwd.name}}'
159 - name: Create mep seret generic
160 # yamllint disable rule:line-length
161 command: kubectl -n mep create secret generic mepauth-secret --from-file=server.crt=/tmp/.mep_tmp_cer/mepserver_tls.crt --from-file=server.key=/tmp/.mep_tmp_cer/mepserver_tls.key
162 --from-file=ca.crt=/tmp/.mep_tmp_cer/ca.crt --from-file=jwt_publickey=/tmp/.mep_tmp_cer/jwt_publickey --from-file=jwt_encrypted_privatekey=/tmp/.mep_tmp_cer/jwt_encrypted_privatekey
163 # yamllint disable rule:line-length
167 - name: Remove directory
168 command: rm -rf /tmp/.mep_tmp_cer
173 msg: Deploy_dns_metallb execution start
175 - name: Eg_Mep deployment execution of namesapce
176 command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/metallb/namespace.yaml
178 chdir: /tmp/eg_mep/deploy/
180 - name: Eg_Mep deployment execution of metallb
181 command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/metallb/metallb.yaml
183 chdir: /tmp/eg_mep/deploy/
185 - name: Eg_Mep deployment create secret
186 # yamllint disable rule:line-length
187 command: kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
188 # yamllint disable rule:line-length
190 chdir: /tmp/eg_mep/deploy/
192 - name: Eg_Mep deployment execution of config-mep
193 command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/metallb/config-map.yaml
195 chdir: /tmp/eg_mep/deploy/
198 msg: Deploy_network_isolation_multus execution start
200 - name: Running multus yaml files
201 command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/network-isolation/multus.yaml
203 chdir: /tmp/eg_mep/deploy/
205 - name: Running eg-sp-rbac yaml files
206 command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/network-isolation/eg-sp-rbac.yaml
208 chdir: /tmp/eg_mep/deploy/
210 - name: Replacing image
212 path: /tmp/eg_mep/deploy/conf/edge/network-isolation/eg-sp-controller.yaml
213 regexp: 'edgegallery/edgegallery-secondary-ep-controller:latest'
214 replace: "swr.ap-southeast-1.myhuaweicloud.com/edgegallery/edgegallery-secondary-ep-controller:latest"
216 - name: Running eg-sp-controller yaml files
217 # yamllint disable rule:line-length
218 command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/network-isolation/eg-sp-controller.yaml
220 chdir: /tmp/eg_mep/deploy/
223 msg: Setup_interfaces execution start
225 - name: Link eg mep macvlan
226 # yamllint disable rule:line-length
227 command: ip link add eg-mp1 link {{ vardata.edge_management_interface.name}} type macvlan mode bridge
229 chdir: /tmp/eg_mep/deploy/
233 - name: Link eg mep macvlan
234 command: ip addr add {{ vardata.eg-management-address.name}} dev eg-mp1
236 chdir: /tmp/eg_mep/deploy/
240 - name: Link eg me1 up
241 command: ip link set dev eg-mp1 up
243 chdir: /tmp/eg_mep/deploy/
247 - name: Link eg eg mm5 with eth1
248 # yamllint disable rule:line-length
249 command: ip link add eg-mm5 link {{ vardata.edge_dataplane_interface.name}} type macvlan mode bridge
251 chdir: /tmp/eg_mep/deploy/
255 - name: Link eg eg mm5 ip addr
256 command: ip addr add {{ vardata.eg-dataplane-address.name}} dev eg-mm5
258 chdir: /tmp/eg_mep/deploy/
262 - name: Link eg eg mm5 set dev
263 command: ip link set dev eg-mm5 up
265 chdir: /tmp/eg_mep/deploy/
270 msg: Pull helm repo start
272 - name: Edge gallery mep installation pull chart and image
273 # yamllint disable rule:line-length
274 command: helm install mep-edgegallery edgegallery/mep --set networkIsolation.phyInterface.mp1={{ vardata.edge_management_interface.name}} --set networkIsolation.phyInterface.mm5={{ vardata.edge_dataplane_interface.name}} --set images.mep.repository={{ vardata.private_repo_ip.name}}:{{ vardata.docker_registry_port.name}}/edgegallery/mep --set images.mepauth.repository={{ vardata.private_repo_ip.name}}:{{ vardata.docker_registry_port.name}}/edgegallery/mepauth --set images.dns.repository={{ vardata.private_repo_ip.name}}:{{ vardata.docker_registry_port.name}}/edgegallery/mep-dns-server --set images.kong.repository={{ vardata.private_repo_ip.name}}:{{ vardata.docker_registry_port.name}}/kong --set images.postgres.repository={{ vardata.private_repo_ip.name}}:{{ vardata.docker_registry_port.name}}/postgres --set images.mep.tag={{ vardata.eg_image_tag.name}} --set images.mepauth.tag={{ vardata.eg_image_tag.name}} --set images.dns.tag={{ vardata.eg_image_tag.name}} --set images.mep.pullPolicy=IfNotPresent --set images.mepauth.pullPolicy=IfNotPresent --set images.dns.pullPolicy=IfNotPresent --set images.kong.pullPolicy=IfNotPresent --set images.postgres.pullPolicy=IfNotPresent --set ssl.secretName=mep-ssl
275 # yamllint disable rule:line-length