Browse Source

Merge "Blacklist Packages as an Extention of Apt"

Zuul 5 months ago
parent
commit
04745a1f88

+ 13
- 0
divingbell/templates/bin/_apt.sh.tpl View File

@@ -96,6 +96,19 @@ if [ ! -z "$INSTALLED_THIS_TIME" ]; then
96 96
     sort ${persist_path}/packages -o ${persist_path}/packages
97 97
 fi
98 98
 
99
+######################################################
100
+#Stage 4
101
+#Remove blacklisted packages in conf.apt.blacklistpkgs
102
+######################################################
103
+
104
+{{- if hasKey .Values.conf.apt "blacklistpkgs" }}
105
+{{- range .Values.conf.apt.blacklistpkgs }}
106
+  {{- $package := . }}
107
+  apt-get remove --autoremove -y {{ $package | squote }}
108
+{{- end }}
109
+apt-get autoremove -y
110
+{{- end }}
111
+
99 112
 exit 0
100 113
 EOF
101 114
 

+ 7
- 0
divingbell/values.yaml View File

@@ -24,6 +24,13 @@ images:
24 24
 conf:
25 25
   chroot_mnt_path: '/mnt'
26 26
   log_colors: False
27
+  apt:
28
+    blacklistpkgs:
29
+    - telnetd
30
+    - inetutils-telnetd
31
+    - telnetd-ssl
32
+    - nis
33
+    - ntpdate
27 34
 
28 35
 ##  data.values.conf.sysctl
29 36
 #  sysctl:

+ 16
- 1
tools/gate/scripts/020-test-divingbell.sh View File

@@ -54,6 +54,7 @@ APT_PACKAGE3=python-simplejson
54 54
 APT_VERSION3=3.8.1-1ubuntu2
55 55
 APT_PACKAGE4=less
56 56
 APT_PACKAGE5=python-setuptools
57
+APT_PACKAGE6=telnetd
57 58
 type lshw || apt -y install lshw
58 59
 nic_info="$(lshw -class network)"
59 60
 physical_nic=''
@@ -764,7 +765,8 @@ _test_apt_package_version(){
764 765
   local pkg_name=$1
765 766
   local pkg_ver=$2
766 767
   if [ ${pkg_ver} = "none" ]; then
767
-    if [[ $(dpkg -l | grep ${pkg_name}) ]]; then
768
+    # Does not include residual-config
769
+    if [[ $(dpkg -l | grep ${pkg_name} | grep -v ^rc) ]]; then
768 770
       echo "[FAIL] Package ${pkg_name} should not be installed" >> "${TEST_RESULTS}"
769 771
       return 1
770 772
     fi
@@ -846,6 +848,19 @@ test_apt(){
846 848
   get_container_status apt expect_failure
847 849
   _test_clog_msg 'E: Unable to locate package some-random-name'
848 850
   echo '[SUCCESS] apt test5 passed successfully' >> "${TEST_RESULTS}"
851
+
852
+  # Test blacklistpkgs
853
+  local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set1.yaml
854
+  echo "conf:
855
+  apt:
856
+    packages:
857
+    - name: $APT_PACKAGE6
858
+    blacklistpkgs:
859
+    - $APT_PACKAGE6" > "${overrides_yaml}"
860
+  install_base "--values=${overrides_yaml}"
861
+  get_container_status apt
862
+  _test_apt_package_version $APT_PACKAGE6 none
863
+  echo '[SUCCESS] apt test6 passed successfully' >> "${TEST_RESULTS}"
849 864
 }
850 865
 
851 866
 # test daemonset value overrides for hosts and labels

Loading…
Cancel
Save