12b70d3427dc74cca2fcee1db3e60618c08ab146
[ealt-edge.git] / ocd / infra / playbooks / roles / eg_mep / tasks / install.yml
1 #
2 # Copyright 2020 Huawei Technologies Co., Ltd.
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
17 ---
18
19 - name: Doing deployment setup for edge gallery
20   copy:
21     src: deploy
22     dest: /tmp/eg_mep/
23
24 - name: Import vars
25   include_vars:
26     file: ../../../config.yml
27     name: vardata
28
29 - name: Setting pull image path
30   # yamllint disable rule:line-length
31   command: kubectl create secret docker-registry swrregcred --docker-server=https://swr.ap-southeast-1.myhuaweicloud.com/v2/ --docker-username={{ vardata.swrusr.name}} --docker-password={{ vardata.swrpass.name}}
32   # yamllint disable rule:line-length
33   args:
34     chdir: /tmp/eg_mep/deploy/
35
36 - name: Copy macvln
37   command: cp -r /tmp/remote-platform/cni/macvlan /opt/cni/bin/
38   args:
39     chdir: /tmp/eg_mep/deploy/
40
41 - name: Setup local-host
42   command: cp -r /tmp/remote-platform/cni/host-local /opt/cni/bin/
43   args:
44     chdir: /tmp/eg_mep/deploy/
45
46 - name: Create mep namespace
47   command: kubectl create ns mep
48   args:
49     chdir: /tmp/
50
51 - name: Create generic pg secret
52   # yamllint disable rule:line-length
53   command: kubectl -n mep create secret generic pg-secret --from-literal=pg_admin_pwd={{ vardata.adminpwd.name}} --from-literal=kong_pg_pwd={{ vardata.kongpgpwd.name}} --from-file=server.key=/tmp/.mep_tmp_cer/mepserver_tls.key --from-file=server.crt=/tmp/.mep_tmp_cer/mepserver_tls.crt
54   # yamllint disable rule:line-length
55   args:
56     chdir: /tmp/
57
58 - name: Create mep generic for mep ssl
59   # yamllint disable rule:line-length
60   command: kubectl -n mep create secret generic mep-ssl --from-literal=cert_pwd={{ vardata.firstvar.name}} --from-file=server.cer=/tmp/.mep_tmp_cer/mepserver_tls.crt --from-file=server_key.pem=/tmp/.mep_tmp_cer/mepserver_encryptedtls.key --from-file=trust.cer=/tmp/.mep_tmp_cer/ca.crt
61   # yamllint disable rule:line-length
62   args:
63     chdir: /tmp/
64
65 - name: Create mep seret generic
66   # yamllint disable rule:line-length
67   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 --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
68   # yamllint disable rule:line-length
69   args:
70     chdir: /tmp/
71
72 - debug:
73     msg: Deploy_dns_metallb execution start
74
75 - name: Eg_Mep deployment execution of namesapce
76   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/metallb/namespace.yaml
77   args:
78     chdir: /tmp/eg_mep/deploy/
79
80 - name: Eg_Mep deployment execution of metallb
81   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/metallb/metallb.yaml
82   args:
83     chdir: /tmp/eg_mep/deploy/
84
85 - name: Eg_Mep deployment create secret
86   command: kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
87   args:
88     chdir: /tmp/eg_mep/deploy/
89
90 - name: Eg_Mep deployment execution of config-mep
91   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/metallb/config-map.yaml
92   args:
93     chdir: /tmp/eg_mep/deploy/
94
95 - debug:
96     msg: Deploy_network_isolation_multus execution start
97
98 - name: Running multus yaml files
99   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/network-isolation/multus.yaml
100   args:
101     chdir: /tmp/eg_mep/deploy/
102
103 - name: Running eg-sp-rbac yaml files
104   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/network-isolation/eg-sp-rbac.yaml
105   args:
106     chdir: /tmp/eg_mep/deploy/
107
108 - name: Replacing image
109   replace:
110     path: /tmp/eg_mep/deploy/conf/edge/network-isolation/eg-sp-controller.yaml
111     regexp: 'edgegallery/edgegallery-secondary-ep-controller:latest'
112     replace: "swr.ap-southeast-1.myhuaweicloud.com/edgegallery/edgegallery-secondary-ep-controller:latest"
113
114 - name: Running eg-sp-controller yaml files
115   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/network-isolation/eg-sp-controller.yaml
116   args:
117     chdir: /tmp/eg_mep/deploy/
118
119 - debug:
120     msg: Setup_interfaces execution start
121
122 - name: Link eg mep macvlan
123   command: ip link add eg-mp1 link {{ vardata.interface1.name}} type macvlan mode bridge
124   args:
125     chdir: /tmp/eg_mep/deploy/
126   ignore_errors: yes
127   no_log: True
128
129 - name: Link eg mep macvlan
130   command: ip addr add {{ vardata.ipaddregmep1.name}} dev eg-mp1
131   args:
132     chdir: /tmp/eg_mep/deploy/
133   ignore_errors: yes
134   no_log: True
135
136 - name: Link eg me1 up
137   command: ip link set dev eg-mp1 up
138   args:
139     chdir: /tmp/eg_mep/deploy/
140   ignore_errors: yes
141   no_log: True
142
143 - name: Link eg eg mm5 with eth1
144   command: ip link add eg-mm5 link {{ vardata.interface2.name}} type macvlan mode bridge
145   args:
146     chdir: /tmp/eg_mep/deploy/
147   ignore_errors: yes
148   no_log: True
149
150 - name: Link eg eg mm5 ip addr
151   command: ip addr add {{ vardata.ipaddregmep5.name}} dev eg-mm5
152   args:
153     chdir: /tmp/eg_mep/deploy/
154   ignore_errors: yes
155   no_log: True
156
157 - name: Link eg eg mm5 set dev
158   command: ip link set dev eg-mm5 up
159   args:
160     chdir: /tmp/eg_mep/deploy/
161   ignore_errors: yes
162   no_log: True
163
164 - name: Delete mep name space
165   command: kubectl delete ns mep
166   args:
167     chdir: /tmp/eg_mep/deploy/
168   ignore_errors: yes
169   no_log: True
170
171 - debug:
172     msg: Pull helm repo start
173
174 - name: Edge gallery mep installation pull chart
175   # yamllint disable rule:line-length
176   command: helm install mep-edgegallery edgegallery/mep --set networkIsolation.phyInterface.mp1={{ vardata.interface1.name}} --set networkIsolation.phyInterface.mm5={{ vardata.interface2.name}} --set ssl.secretName=mep-ssl
177   # yamllint disable rule:line-length
178   args:
179     chdir: /tmp/eg_mep/deploy/
180   ignore_errors: yes
181   no_log: True