Browse Source

Add possibility to add repository and GPG key

The PS adds possibility to add repository and GPG key.

Change-Id: Ie4bfc3ba9501b8af484515e9d2946725bd9eff4b
Dmitrii Kabanov 1 month ago
parent
commit
8f102a878a
2 changed files with 310 additions and 1 deletions
  1. 34
    1
      divingbell/templates/bin/_apt.sh.tpl
  2. 276
    0
      tools/gate/scripts/020-test-divingbell.sh

+ 34
- 1
divingbell/templates/bin/_apt.sh.tpl View File

@@ -54,10 +54,43 @@ load_package_list_with_versions $(dpkg -l | awk 'NR>5 {print $2"="$3}')
54 54
 
55 55
 ################################################
56 56
 #Stage 2
57
-#Install new packages
57
+#Add repositories and install new packages
58 58
 ################################################
59 59
 
60 60
 {{- if hasKey .Values.conf "apt" }}
61
+{{- if hasKey .Values.conf.apt "repositories" }}
62
+  {{- $repository := list }}
63
+echo -n "" > /etc/apt/trusted.gpg.d/divindbell_temp.gpg
64
+  {{- range .Values.conf.apt.repositories }}
65
+    {{- $url := .url }}
66
+    {{- $components := .components | join " " }}
67
+    {{- $subrepos := .subrepos | default list }}
68
+    {{- range .distributions }}
69
+      {{- $distribution := . }}
70
+      {{- $repository = append $repository ( printf "deb %s %s %s" $url $distribution $components ) }}
71
+      {{- if $subrepos }}
72
+        {{- range $subrepos }}
73
+          {{- $repository = append $repository ( printf "deb %s %s-%s %s" $url $distribution . $components ) }}
74
+        {{- end }}
75
+      {{- end }}
76
+    {{- end }}
77
+    {{- if hasKey . "gpgkey" }}
78
+apt-key --keyring /etc/apt/trusted.gpg.d/divindbell_temp.gpg add - <<"ENDKEY"
79
+{{ .gpgkey }}
80
+ENDKEY
81
+    {{- end }}
82
+  {{- end }}
83
+echo "#The list of repositories managed by Divingbell" > /etc/apt/sources.list.divingbell
84
+  {{- range $repository }}
85
+echo "{{ . }}" >>/etc/apt/sources.list.divingbell
86
+  {{- end }}
87
+mv /etc/apt/sources.list.divingbell /etc/apt/sources.list
88
+rm -rf /etc/apt/sources.list.d/*
89
+mv /etc/apt/trusted.gpg.d/divindbell_temp.gpg /etc/apt/trusted.gpg.d/divindbell.gpg
90
+rm -f /etc/apt/trusted.gpg
91
+find /etc/apt/trusted.gpg.d/ -type f ! -name 'divindbell.gpg' -exec rm {{ "{}" }} \;
92
+apt-get update
93
+{{- end }}
61 94
 {{- if hasKey .Values.conf.apt "packages" }}
62 95
 apt-get update
63 96
 

+ 276
- 0
tools/gate/scripts/020-test-divingbell.sh View File

@@ -55,6 +55,191 @@ APT_VERSION3=3.8.1-1ubuntu2
55 55
 APT_PACKAGE4=less
56 56
 APT_PACKAGE5=python-setuptools
57 57
 APT_PACKAGE6=telnetd
58
+APT_REPOSITORY1="http://us.archive.ubuntu.com/ubuntu/"
59
+APT_DISTRIBUTIONS1="[ xenial ]"
60
+APT_COMPONENTS1="[ main, universe, restricted, multiverse ]"
61
+APT_SUBREPOS1="[ backports, updates ]"
62
+APT_GPGKEYID1="437D05B5"
63
+APT_GPGKEY1="-----BEGIN PGP PUBLIC KEY BLOCK-----
64
+Version: GnuPG v1
65
+
66
+mQGiBEFEnz8RBAC7LstGsKD7McXZgd58oN68KquARLBl6rjA2vdhwl77KkPPOr3O
67
+YeSBH/voUsqausJfDNuTNivOfwceDe50lbhq52ODj4Mx9Jg+4aHn9fmRkIk41i2J
68
+3hZiIGPACY/FsSlRq1AhBH2wZG1lQ45W/p77AeARRehYKJP9HY+1h/uihwCgrVE2
69
+VzACJLuZWHbDsPoJaNQjiFcEAKbUF1rMyjd1xJM7bZeXbs8c+ohUo/ywSI/OIr8n
70
+OfUswy08tsCof1KU0JBGLBCn0lHAYkAAcSr2pQ+k/odwdLQSjgm/JcUbi2ll16Wy
71
+7qFbUAUJ5xO+iP61vL3z4pJGcK1pMH6kBLA4CPBchJU/hh3f7vtX2oFdWw8tWqvm
72
+m/W7BACE7h0p86OP2G3ZJBjNYNQTK1LFYa+3G0spsVi9wl+Ih49ImPbSsUc2CSMA
73
+fDlGpYU8FuUKCgQnS3UZz6e0NwrHbZTHBy0ksRwT9jf7qSAEKEN2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CggqQyo+w1
137
+Twx6DKLF+3rF5nf1F3Q=
138
+=PBAe
139
+-----END PGP PUBLIC KEY BLOCK-----"
140
+APT_REPOSITORY2="http://security.ubuntu.com/ubuntu/"
141
+APT_DISTRIBUTIONS2="[ xenial ]"
142
+APT_COMPONENTS2="[ main, universe, restricted, multiverse ]"
143
+APT_SUBREPOS2="[ security ]"
144
+APT_GPGKEYID2="C0B21F32"
145
+APT_GPGKEY2="-----BEGIN PGP PUBLIC KEY BLOCK-----
146
+Version: GnuPG v1
147
+
148
+mQINBE+tgXgBEADfiL1KNFHT4H4Dw0OR9LemR8ebsFl+b9E44IpGhgWYDufj0gaM
149
+/UJ1Ti3bHfRT39VVZ6cv1P4mQy0bnAKFbYz/wo+GhzjBWtn6dThYv7n+KL8bptSC
150
+Xgg1a6en8dCCIA/pwtS2Ut/g4Eu6Z467dvYNlMgCqvg+prKIrXf5ibio48j3AFvd
151
+1dDJl2cHfyuON35/83vXKXz0FPohQ7N7kPfI+qrlGBYGWFzC/QEGje360Q2Yo+rf
152
+MoyDEXmPsoZVqf7EE8gjfnXiRqmz/Bg5YQb5bgnGbLGiHWtjS+ACIdLUq/h+jlSp
153
+57jw8oQktMh2xVMX4utDM0UENeZnPllVJSlR0b+ZmZz7paeSar8Yxn4wsNlL7GZb
154
+pW5A/WmcmWfuMYoPhBo5Fq1V2/siKNU3UKuf1KH+X0p1oZ4oOcZ2bS0Zh3YEG8IQ
155
+ce9Bferq4QMKsekcG9IKS6WBIU7BwaElI2ILD0gSwu8KzvNSEeIJhYSsBIEzrWxI
156
+BXoN2AC9PCqqXkWlI5Xr/86RWllB3CsoPwEfO8CLJW2LlXTen/Fkq4wT+apdhHei
157
+WiSsq/J5OEff0rKHBQ3fK7fyVuVNrJFb2CopaBLyCxTupvxs162jjUNopt0c7OqN
158
+BoPoUoVFAxUSpeEwAw6xrM5vROyLMSeh/YnTuRy8WviRapZCYo6naTCY5wARAQAB
159
+tEJVYnVudHUgQXJjaGl2ZSBBdXR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OCOf6+ntvQaGa3BrnRs9CemDKa
191
+VyWwjNJEXboS8+LwBpWmNw/idWgLzf9N7XF1+GfrF61FeYccltcB1X8M4ElI/Cch
192
+vk52+OG8j6USemCOL1OSirbYqvj8UroQabVUwe90TZrboOL06Q2dPeX0fBIk837U
193
+XRDJpzKYexZvWg9kg7Ibf9MYuodt5bkG+6slwmbN7W1I4UAgrIj4EhlE9wsmdsMc
194
+2eNXk6DOClN8sseXPx490nL623SQSx4tbYpukzaEXREXOQT2uY5GHvDVMv7biQIc
195
+BBABAgAGBQJPrYqXAAoJENfD8TGrKpH1rJAQAJr+AfdLW5oB95I68tZIYVwvqZ41
196
+wU8pkf8iXuNmT4C26wdj204jQl86iSJlf8EiuqswzD0eBrY/QNPOL6ABcKvhO4Kl
197
+uaRiULruaXI7odkmIDAty5gYe04nD7E3wv55lQOTrT7u7QZnfy//yY+3Qw4Ea6Me
198
+SeGW+s3REpmAPSl+iaWkqYiox/tmCQOQJK0jzxTcYyHcLzoNaJ+IqANZUM8URCrb
199
+RapRbm3XxA9FeD0Zlg77NGCZyT1pw6XkG7kLlE4BvUmzS/dIQkx8qnpJhchLQ20l
200
+xqcBaT1buRTxktvflWPeVhPy0MLl72l/Bdhly21YcQbmbClkbWMGgLctbqN25HwH
201
+8Lo6guUk9oWlqvtuXOEI31lZgSestpsCz/JvlfYuyevBa33srUoRTFNnZshGNzkT
202
+20GXjnx7WDb6mHxwcpAZFCCC2ktfDwd+/U0mU6+02zYHby6OIjRHnAvbCGhz51Ed
203
+PfE362W3CY021ktEgu9xYpIGOfREncrjo0AoOwqoWQhEoLG3ihF8LMUryVNac0ew
204
+srGY7gxFCnP+aHtXzaa8mMW8dkWgNwi6RfJfphrgHkdgKVjKukkIqRrZrDoD5O7A
205
+18oTb3iMrBKHdSVZp0icpmAHb0ddBNlY9zun7akuBrVzM5aKuo21l/Qs9z3UK5k4
206
+DjfegedFClqpn37b
207
+=rDTH
208
+-----END PGP PUBLIC KEY BLOCK-----"
209
+APT_REPOSITORY3="https://download.ceph.com/debian-mimic/"
210
+APT_DISTRIBUTIONS3="[ xenial ]"
211
+APT_COMPONENTS3="[ main ]"
212
+APT_GPGKEYID3="460F3994"
213
+APT_GPGKEY3="-----BEGIN PGP PUBLIC KEY BLOCK-----
214
+Version: GnuPG v1
215
+
216
+mQINBFX4hgkBEADLqn6O+UFp+ZuwccNldwvh5PzEwKUPlXKPLjQfXlQRig1flpCH
217
+E0HJ5wgGlCtYd3Ol9f9+qU24kDNzfbs5bud58BeE7zFaZ4s0JMOMuVm7p8JhsvkU
218
+C/Lo/7NFh25e4kgJpjvnwua7c2YrA44ggRb1QT19ueOZLK5wCQ1mR+0GdrcHRCLr
219
+7Sdw1d7aLxMT+5nvqfzsmbDullsWOD6RnMdcqhOxZZvpay8OeuK+yb8FVQ4sOIzB
220
+FiNi5cNOFFHg+8dZQoDrK3BpwNxYdGHsYIwU9u6DWWqXybBnB9jd2pve9PlzQUbO
221
+eHEa4Z+jPqxY829f4ldaql7ig8e6BaInTfs2wPnHJ+606g2UH86QUmrVAjVzlLCm
222
+nqoGymoAPGA4ObHu9X3kO8viMBId9FzooVqR8a9En7ZE0Dm9O7puzXR7A1f5sHoz
223
+JdYHnr32I+B8iOixhDUtxIY4GA8biGATNaPd8XR2Ca1hPuZRVuIiGG9HDqUEtXhV
224
+fY5qjTjaThIVKtYgEkWMT+Wet3DPPiWT3ftNOE907e6EWEBCHgsEuuZnAbku1GgD
225
+LBH4/a/yo9bNvGZKRaTUM/1TXhM5XgVKjd07B4cChgKypAVHvef3HKfCG2U/DkyA
226
+LjteHt/V807MtSlQyYaXUTGtDCrQPSlMK5TjmqUnDwy6Qdq8dtWN3DtBWQARAQAB
227
+tCpDZXBoLmNvbSAocmVsZWFzZSBrZXkpIDxzZWN1cml0eUBjZXBoLmNvbT6JAjgE
228
+EwECACIFAlX4hgkCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOhKwsBG
229
+DzmUXdIQAI8YPcZMBWdv489q8CzxlfRIRZ3Gv/G/8CH+EOExcmkVZ89mVHngCdAP
230
+DOYCl8twWXC1lwJuLDBtkUOHXNuR5+Jcl5zFOUyldq1Hv8u03vjnGT7lLJkJoqpG
231
+l9QD8nBqRvBU7EM+CU7kP8+09b+088pULil+8x46PwgXkvOQwfVKSOr740Q4J4nm
232
+/nUOyTNtToYntmt2fAVWDTIuyPpAqA6jcqSOC7Xoz9cYxkVWnYMLBUySXmSS0uxl
233
+3p+wK0lMG0my/gb+alke5PAQjcE5dtXYzCn+8Lj0uSfCk8Gy0ZOK2oiUjaCGYN6D
234
+u72qDRFBnR3jaoFqi03bGBIMnglGuAPyBZiI7LJgzuT9xumjKTJW3kN4YJxMNYu1
235
+FzmIyFZpyvZ7930vB2UpCOiIaRdZiX4Z6ZN2frD3a/vBxBNqiNh/BO+Dex+PDfI4
236
+TqwF8zlcjt4XZ2teQ8nNMR/D8oiYTUW8hwR4laEmDy7ASxe0p5aijmUApWq5UTsF
237
++s/QbwugccU0iR5orksM5u9MZH4J/mFGKzOltfGXNLYI6D5Mtwrnyi0BsF5eY0u6
238
+vkdivtdqrq2DXY+ftuqLOQ7b+t1RctbcMHGPptlxFuN9ufP5TiTWSpfqDwmHCLsT
239
+k2vFiMwcHdLpQ1IH8ORVRgPPsiBnBOJ/kIiXG2SxPUTjjEGOVgeA
240
+=/Tod
241
+-----END PGP PUBLIC KEY BLOCK-----"
242
+#deb https://download.ceph.com/debian-mimic/ xenial main
58 243
 EXEC_DIR=/var/${NAME}/exec
59 244
 # this used in test_overrides to check amount of daemonsets defined
60 245
 EXPECTED_NUMBER_OF_DAEMONSETS=17
@@ -940,6 +1125,40 @@ _test_apt_package_version(){
940 1125
   fi
941 1126
 }
942 1127
 
1128
+_test_apt_repositories(){
1129
+  local repositories=$1
1130
+  local remaining_repos
1131
+  for repository in $repositories
1132
+  do
1133
+    if ! grep -qrh "$repository" /etc/apt/sources.list /etc/apt/sources.list.d/*
1134
+    then
1135
+      echo "[FAIL] The repository (${repository}) was not added."
1136
+      #return 1
1137
+    fi
1138
+  done
1139
+  remaining_repos=$(grep -rh "^deb" /etc/apt/sources.list /etc/apt/sources.list.d/* | sort -u | grep -v "${repositories// /\\|}" | awk '{print$2}')
1140
+  for repo in $remaining_repos
1141
+  do
1142
+    echo "[FAIL] Repository ${repo} should not be added."
1143
+  done
1144
+}
1145
+
1146
+_test_apt_keys(){
1147
+  local keys=$1
1148
+  for key in $keys
1149
+  do
1150
+    if ! apt-key list | grep -q "$key"
1151
+    then
1152
+      echo "[FAIL] The gpg key (${key}) was not installed"
1153
+    fi
1154
+  done
1155
+  remaining_keys=$(apt-key list | grep "^pub" | grep -v "${keys// /\\|}" | awk '{print$2}')
1156
+  for rkey in $remaining_keys
1157
+  do
1158
+    echo "[FAIL] The gpg key (${rkey}) should not be installed"
1159
+  done
1160
+}
1161
+
943 1162
 test_apt(){
944 1163
   # Test the valid set of packages
945 1164
   local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set1.yaml
@@ -1031,6 +1250,63 @@ test_apt(){
1031 1250
   get_container_status apt
1032 1251
   _test_apt_package_version $APT_PACKAGE6 none
1033 1252
   echo '[SUCCESS] apt test6 passed successfully' >> "${TEST_RESULTS}"
1253
+
1254
+  # Test add several repositories with gpg keys
1255
+  local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set5.yaml
1256
+  echo "conf:
1257
+  apt:
1258
+    repositories:
1259
+      repository_name1:
1260
+        url: $APT_REPOSITORY1
1261
+        distributions: $APT_DISTRIBUTIONS1
1262
+        components: $APT_COMPONENTS1
1263
+        subrepos: $APT_SUBREPOS1
1264
+        gpgkey: |-
1265
+$(printf '%s' "$APT_GPGKEY1" | awk '{printf "          %s\n", $0}')
1266
+      repository_name2:
1267
+        url: $APT_REPOSITORY2
1268
+        distributions: $APT_DISTRIBUTIONS2
1269
+        components: $APT_COMPONENTS2
1270
+        subrepos: $APT_SUBREPOS2
1271
+        gpgkey: |-
1272
+$(printf '%s' "$APT_GPGKEY2" | awk '{printf "          %s\n", $0}')
1273
+      repository_name3:
1274
+        url: $APT_REPOSITORY3
1275
+        distributions: $APT_DISTRIBUTIONS3
1276
+        components: $APT_COMPONENTS3
1277
+        subrepos: $APT_SUBREPOS3
1278
+        gpgkey: |-
1279
+$(printf '%s' "$APT_GPGKEY3" | awk '{printf "          %s\n", $0}')" > "${overrides_yaml}"
1280
+  install_base "--values=${overrides_yaml}"
1281
+  get_container_status apt
1282
+  _test_apt_repositories "$APT_REPOSITORY1 $APT_REPOSITORY2 $APT_REPOSITORY3"
1283
+  _test_apt_keys "$APT_GPGKEYID1 $APT_GPGKEYID2 $APT_GPGKEYID3"
1284
+  echo '[SUCCESS] apt test7 passed successfully' >> "${TEST_RESULTS}"
1285
+
1286
+  # Test add same gpg key two times
1287
+  local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set6.yaml
1288
+  echo "conf:
1289
+  apt:
1290
+    repositories:
1291
+      repository_name1:
1292
+        url: $APT_REPOSITORY1
1293
+        distributions: $APT_DISTRIBUTIONS1
1294
+        components: $APT_COMPONENTS1
1295
+        subrepos: $APT_SUBREPOS1
1296
+        gpgkey: |-
1297
+$(printf '%s' "$APT_GPGKEY1" | awk '{printf "          %s\n", $0}')
1298
+      repository_name2:
1299
+        url: $APT_REPOSITORY2
1300
+        distributions: $APT_DISTRIBUTIONS2
1301
+        components: $APT_COMPONENTS2
1302
+        subrepos: $APT_SUBREPOS2
1303
+        gpgkey: |-
1304
+$(printf '%s' "$APT_GPGKEY1" | awk '{printf "          %s\n", $0}')" > "${overrides_yaml}"
1305
+  install_base "--values=${overrides_yaml}"
1306
+  get_container_status apt
1307
+  _test_apt_repositories "$APT_REPOSITORY1 $APT_REPOSITORY2"
1308
+  _test_apt_keys "$APT_GPGKEYID1"
1309
+  echo '[SUCCESS] apt test8 passed successfully' >> "${TEST_RESULTS}"
1034 1310
 }
1035 1311
 
1036 1312
 # test exec module

Loading…
Cancel
Save