summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-13 14:16:15 +0000
committerGerrit Code Review <review@openstack.org>2018-11-13 14:16:15 +0000
commit04745a1f88647686076446113e8f946c5e740f4c (patch)
tree3d12ac806633bba3ddfba8d47d6b24158c382a6f
parent96e2b073f3f66506a46014646473d5e5d97b25ab (diff)
parent3524908910f7dcb44fd6a10996cdffdeb7514e1b (diff)
Merge "Blacklist Packages as an Extention of Apt"
-rw-r--r--divingbell/templates/bin/_apt.sh.tpl13
-rw-r--r--divingbell/values.yaml7
-rwxr-xr-xtools/gate/scripts/020-test-divingbell.sh17
3 files changed, 36 insertions, 1 deletions
diff --git a/divingbell/templates/bin/_apt.sh.tpl b/divingbell/templates/bin/_apt.sh.tpl
index 1112981..4d0cb7c 100644
--- a/divingbell/templates/bin/_apt.sh.tpl
+++ b/divingbell/templates/bin/_apt.sh.tpl
@@ -96,6 +96,19 @@ if [ ! -z "$INSTALLED_THIS_TIME" ]; then
96 sort ${persist_path}/packages -o ${persist_path}/packages 96 sort ${persist_path}/packages -o ${persist_path}/packages
97fi 97fi
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 }}
109apt-get autoremove -y
110{{- end }}
111
99exit 0 112exit 0
100EOF 113EOF
101 114
diff --git a/divingbell/values.yaml b/divingbell/values.yaml
index 02a3594..eab75d4 100644
--- a/divingbell/values.yaml
+++ b/divingbell/values.yaml
@@ -24,6 +24,13 @@ images:
24conf: 24conf:
25 chroot_mnt_path: '/mnt' 25 chroot_mnt_path: '/mnt'
26 log_colors: False 26 log_colors: False
27 apt:
28 blacklistpkgs:
29 - telnetd
30 - inetutils-telnetd
31 - telnetd-ssl
32 - nis
33 - ntpdate
27 34
28## data.values.conf.sysctl 35## data.values.conf.sysctl
29# sysctl: 36# sysctl:
diff --git a/tools/gate/scripts/020-test-divingbell.sh b/tools/gate/scripts/020-test-divingbell.sh
index 2809f43..110ed17 100755
--- a/tools/gate/scripts/020-test-divingbell.sh
+++ b/tools/gate/scripts/020-test-divingbell.sh
@@ -54,6 +54,7 @@ APT_PACKAGE3=python-simplejson
54APT_VERSION3=3.8.1-1ubuntu2 54APT_VERSION3=3.8.1-1ubuntu2
55APT_PACKAGE4=less 55APT_PACKAGE4=less
56APT_PACKAGE5=python-setuptools 56APT_PACKAGE5=python-setuptools
57APT_PACKAGE6=telnetd
57type lshw || apt -y install lshw 58type lshw || apt -y install lshw
58nic_info="$(lshw -class network)" 59nic_info="$(lshw -class network)"
59physical_nic='' 60physical_nic=''
@@ -764,7 +765,8 @@ _test_apt_package_version(){
764 local pkg_name=$1 765 local pkg_name=$1
765 local pkg_ver=$2 766 local pkg_ver=$2
766 if [ ${pkg_ver} = "none" ]; then 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 echo "[FAIL] Package ${pkg_name} should not be installed" >> "${TEST_RESULTS}" 770 echo "[FAIL] Package ${pkg_name} should not be installed" >> "${TEST_RESULTS}"
769 return 1 771 return 1
770 fi 772 fi
@@ -846,6 +848,19 @@ test_apt(){
846 get_container_status apt expect_failure 848 get_container_status apt expect_failure
847 _test_clog_msg 'E: Unable to locate package some-random-name' 849 _test_clog_msg 'E: Unable to locate package some-random-name'
848 echo '[SUCCESS] apt test5 passed successfully' >> "${TEST_RESULTS}" 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# test daemonset value overrides for hosts and labels 866# test daemonset value overrides for hosts and labels