eg_mep install playbook images tag added
[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 config file
25   include_vars:
26     file: ../../../config.yml
27     name: vardata
28
29 - name: Create mep namespace
30   command: kubectl create ns mep
31   args:
32     chdir: /tmp/
33
34 - name: Create generic pg secret
35   # yamllint disable rule:line-length
36   command: kubectl -n mep create secret generic pg-secret --from-literal=pg_admin_pwd={{ vardata.mepadminpwd.name}} --from-literal=kong_pg_pwd={{ vardata.mepkongpgpwd.name}} --from-file=server.key=/tmp/.mep_tmp_cer/server_tls.key --from-file=server.crt=/tmp/.mep_tmp_cer/server_tls.crt
37   # yamllint disable rule:line-length
38   args:
39     chdir: /tmp/
40
41 - name: Create mep generic for mep ssl
42   # yamllint disable rule:line-length
43   command: kubectl -n mep create secret generic mep-ssl --from-literal=cert_pwd={{ vardata.mepcertpwd.name}} --from-file=server.cer=/tmp/.mep_tmp_cer/server_tls.crt --from-file=server_key.pem=/tmp/.mep_tmp_cer/server_encryptedtls.key --from-file=trust.cer=/tmp/.mep_tmp_cer/ca.crt
44   # yamllint disable rule:line-length
45   args:
46     chdir: /tmp/
47
48 - name: Create mep seret generic
49   # yamllint disable rule:line-length
50   command: kubectl -n mep create secret generic mepauth-secret --from-file=server.crt=/tmp/.mep_tmp_cer/server_tls.crt --from-file=server.key=/tmp/.mep_tmp_cer/server_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
51   # yamllint disable rule:line-length
52   args:
53     chdir: /tmp/
54
55 - debug:
56     msg: Deploy_dns_metallb execution start
57
58 - name: Eg_Mep deployment execution of namesapce
59   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/metallb/namespace.yaml
60   args:
61     chdir: /tmp/eg_mep/deploy/
62
63 - name: Eg_Mep deployment execution of metallb
64   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/metallb/metallb.yaml
65   args:
66     chdir: /tmp/eg_mep/deploy/
67
68 - name: Eg_Mep deployment create secret
69   command: kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
70   args:
71     chdir: /tmp/eg_mep/deploy/
72
73 - name: Eg_Mep deployment execution of config-mep
74   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/metallb/config-map.yaml
75   args:
76     chdir: /tmp/eg_mep/deploy/
77
78 - debug:
79     msg: Deploy_network_isolation_multus execution start
80
81 - name: Running multus yaml files
82   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/network-isolation/multus.yaml
83   args:
84     chdir: /tmp/eg_mep/deploy/
85
86 - name: Running eg-sp-rbac yaml files
87   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/network-isolation/eg-sp-rbac.yaml
88   args:
89     chdir: /tmp/eg_mep/deploy/
90
91 - name: Replacing image
92   replace:
93     path: /tmp/eg_mep/deploy/conf/edge/network-isolation/eg-sp-controller.yaml
94     regexp: 'edgegallery/edgegallery-secondary-ep-controller:{{ vardata.egepcontroller.name}}'
95     replace: "swr.ap-southeast-1.myhuaweicloud.com/edgegallery/edgegallery-secondary-ep-controller:{{ vardata.cloudegepcontroller.name}}"
96
97 - name: Running eg-sp-controller yaml files
98   command: kubectl apply -f /tmp/eg_mep/deploy/conf/edge/network-isolation/eg-sp-controller.yaml
99   args:
100     chdir: /tmp/eg_mep/deploy/
101
102 - debug:
103     msg: Setup_interfaces execution start
104
105 - name: Link eg mep macvlan
106   command: ip link add eg-mp1 link {{ vardata.systeminterface1.name}} type macvlan mode bridge
107   args:
108     chdir: /tmp/eg_mep/deploy/
109   ignore_errors: yes
110   no_log: True
111
112 - name: Link eg mep macvlan
113   command: ip addr add {{ vardata.ipaddregmepmacvlan.name}} dev eg-mp1
114   args:
115     chdir: /tmp/eg_mep/deploy/
116   ignore_errors: yes
117   no_log: True
118
119 - name: Link eg me1 up
120   command: ip link set dev eg-mp1 up
121   args:
122     chdir: /tmp/eg_mep/deploy/
123   ignore_errors: yes
124   no_log: True
125
126 - name: Link eg eg mm5 with eth1
127   command: ip link add eg-mm5 link {{ vardata.systeminterface2.name}} type macvlan mode bridge
128   args:
129     chdir: /tmp/eg_mep/deploy/
130   ignore_errors: yes
131   no_log: True
132
133 - name: Link eg eg mm5 ip addr
134   command: ip addr add {{ vardata.ipaddregmep5.name}} dev eg-mm5
135   args:
136     chdir: /tmp/eg_mep/deploy/
137   ignore_errors: yes
138   no_log: True
139
140 - name: Link eg eg mm5 set dev
141   command: ip link set dev eg-mm5 up
142   args:
143     chdir: /tmp/eg_mep/deploy/
144   ignore_errors: yes
145   no_log: True
146
147 - debug:
148     msg: Pull helm repo start
149
150 - name: Edge gallery mep installation pull chart
151   # yamllint disable rule:line-length
152   command: helm install --wait mep-edgegallery edgegallery/mep --set networkIsolation.phyInterface.mp1={{ vardata.systeminterface1.name}} --set networkIsolation.phyInterface.mm5={{ vardata.systeminterface2.name}} --set images.mep.tag={{ vardata.mepimagetag.name}} --set images.mepauth.tag={{ vardata.mepauthimagetag.name}} --set images.dns.tag={{ vardata.mepdnsimagetag.name}} --set ssl.secretName=mep-ssl
153   # yamllint disable rule:line-length
154   args:
155     chdir: /tmp/eg_mep/deploy/
156   ignore_errors: yes
157   no_log: True