summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-15 23:09:50 +0000
committerGerrit Code Review <review@openstack.org>2018-11-15 23:09:50 +0000
commit9c2ca300016e5603175004026ca45e9c43c0994f (patch)
tree71ae7a5204ee9d30cf840ad142d1c5ce026df35c
parentf3a9306404854259287d22e0f1ae09b9e5eedf54 (diff)
parentda532c32aa4df51ba3ddce36e2e6776b0f8400ea (diff)
Merge "Add options to apt-get install call"
-rw-r--r--divingbell/templates/bin/_apt.sh.tpl22
-rw-r--r--doc/source/index.rst12
-rwxr-xr-xtools/gate/scripts/020-test-divingbell.sh15
3 files changed, 46 insertions, 3 deletions
diff --git a/divingbell/templates/bin/_apt.sh.tpl b/divingbell/templates/bin/_apt.sh.tpl
index 4d0cb7c..293bb98 100644
--- a/divingbell/templates/bin/_apt.sh.tpl
+++ b/divingbell/templates/bin/_apt.sh.tpl
@@ -59,9 +59,25 @@ load_package_list_with_versions $(dpkg -l | awk 'NR>5 {print $2"="$3}')
59 59
60{{- if hasKey .Values.conf "apt" }} 60{{- if hasKey .Values.conf "apt" }}
61{{- if hasKey .Values.conf.apt "packages" }} 61{{- if hasKey .Values.conf.apt "packages" }}
62apt-get update
63
64# Set all debconf selections up front
65{{- range .Values.conf.apt.packages }}
66{{- $pkg_name := .name }}
67{{- range .debconf }}
68 debconf-set-selections <<< "{{ $pkg_name }} {{ .question }} {{ .question_type }} {{ .answer }}"
69{{- end }}
70{{- end }}
71
72# Run dpkg in case of interruption of previous dpkg operation
73dpkg --configure -a
74
75# Perform package installs
62{{- range .Values.conf.apt.packages }} 76{{- range .Values.conf.apt.packages }}
63if [[ "${CURRENT_PACKAGES[{{ .name | squote }}]+isset}" != "isset"{{- if .version }} || "${CURRENT_PACKAGES[{{ .name | squote }}]}" != {{ .version | squote }}{{- end }} ]]; then 77{{- $pkg_name := .name }}
64 apt-get install -y{{ if .repo }} -t {{ .repo | squote }}{{ end }} {{ .name | squote -}} {{- if .version }}={{ .version | squote }}{{ end }} 78if [[ "${CURRENT_PACKAGES[{{ .name | squote }}]+isset}" != "isset"{{- if .version }} || "${CURRENT_PACKAGES[{{ .name | squote }}]}" != {{ .version }}{{- end }} ]]; then
79 # Run this in case some package installation was interrupted
80 DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold{{- if .repo }} -t {{ .repo }}{{ end }} {{ .name -}} {{- if .version }}={{ .version }}{{ end }}
65 INSTALLED_THIS_TIME="$INSTALLED_THIS_TIME {{ .name }}" 81 INSTALLED_THIS_TIME="$INSTALLED_THIS_TIME {{ .name }}"
66fi 82fi
67REQUESTED_PACKAGES="$REQUESTED_PACKAGES {{ .name }}" 83REQUESTED_PACKAGES="$REQUESTED_PACKAGES {{ .name }}"
@@ -80,6 +96,7 @@ if [ -f ${persist_path}/packages ]; then
80 TO_DELETE=$(comm -23 ${persist_path}/packages ${persist_path}/packages.requested) 96 TO_DELETE=$(comm -23 ${persist_path}/packages ${persist_path}/packages.requested)
81 TO_KEEP=$(echo "$TO_DELETE" | comm -23 ${persist_path}/packages -) 97 TO_KEEP=$(echo "$TO_DELETE" | comm -23 ${persist_path}/packages -)
82 if [ ! -z "$TO_DELETE" ]; then 98 if [ ! -z "$TO_DELETE" ]; then
99 dpkg --configure -a
83 for pkg in "$TO_DELETE"; do 100 for pkg in "$TO_DELETE"; do
84 apt-get purge -y $pkg 101 apt-get purge -y $pkg
85 done 102 done
@@ -102,6 +119,7 @@ fi
102###################################################### 119######################################################
103 120
104{{- if hasKey .Values.conf.apt "blacklistpkgs" }} 121{{- if hasKey .Values.conf.apt "blacklistpkgs" }}
122dpkg --configure -a
105{{- range .Values.conf.apt.blacklistpkgs }} 123{{- range .Values.conf.apt.blacklistpkgs }}
106 {{- $package := . }} 124 {{- $package := . }}
107 apt-get remove --autoremove -y {{ $package | squote }} 125 apt-get remove --autoremove -y {{ $package | squote }}
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 2546e72..2fa9353 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -158,6 +158,18 @@ Here is an example configuration for it::
158 version: <VERSION1> 158 version: <VERSION1>
159 - name: <PACKAGE2> 159 - name: <PACKAGE2>
160 160
161It is also possible to provide debconf settings for packages the following
162way::
163
164 conf:
165 apt:
166 packages:
167 - name: openssh-server
168 debconf:
169 - question: openssh-server/permit-root-login
170 question_type: boolean
171 answer: false
172
161Operations 173Operations
162---------- 174----------
163 175
diff --git a/tools/gate/scripts/020-test-divingbell.sh b/tools/gate/scripts/020-test-divingbell.sh
index 110ed17..1f57bea 100755
--- a/tools/gate/scripts/020-test-divingbell.sh
+++ b/tools/gate/scripts/020-test-divingbell.sh
@@ -49,7 +49,7 @@ USERNAME4=userfour
49USERNAME4_SUDO=false 49USERNAME4_SUDO=false
50APT_PACKAGE1=python-pbr 50APT_PACKAGE1=python-pbr
51APT_VERSION1=1.8.0-4ubuntu1 51APT_VERSION1=1.8.0-4ubuntu1
52APT_PACKAGE2=python-yaml 52APT_PACKAGE2=mysql-server
53APT_PACKAGE3=python-simplejson 53APT_PACKAGE3=python-simplejson
54APT_VERSION3=3.8.1-1ubuntu2 54APT_VERSION3=3.8.1-1ubuntu2
55APT_PACKAGE4=less 55APT_PACKAGE4=less
@@ -804,12 +804,25 @@ test_apt(){
804 apt: 804 apt:
805 packages: 805 packages:
806 - name: $APT_PACKAGE2 806 - name: $APT_PACKAGE2
807 debconf:
808 - question: mysql-server/root_password
809 question_type: password
810 answer: rootpw
811 - question: mysql-server/root_password_again
812 question_type: password
813 answer: rootpw
807 - name: $APT_PACKAGE3 814 - name: $APT_PACKAGE3
808 version: $APT_VERSION3" > "${overrides_yaml}" 815 version: $APT_VERSION3" > "${overrides_yaml}"
809 install_base "--values=${overrides_yaml}" 816 install_base "--values=${overrides_yaml}"
810 get_container_status apt 817 get_container_status apt
811 _test_apt_package_version $APT_PACKAGE1 none 818 _test_apt_package_version $APT_PACKAGE1 none
812 _test_apt_package_version $APT_PACKAGE2 any 819 _test_apt_package_version $APT_PACKAGE2 any
820 # Each entry in passwords.dat contains question value in Name and Template
821 # field, so grepping root_password should return 4 lines
822 if [[ $(grep root_password /var/cache/debconf/passwords.dat | wc -l) != 4 ]]; then
823 echo "[FAIL] Package $APT_PACKAGE2 should have debconf values configured" >> "${TEST_RESULTS}"
824 return 1
825 fi
813 _test_apt_package_version $APT_PACKAGE3 $APT_VERSION3 826 _test_apt_package_version $APT_PACKAGE3 $APT_VERSION3
814 echo '[SUCCESS] apt test2 passed successfully' >> "${TEST_RESULTS}" 827 echo '[SUCCESS] apt test2 passed successfully' >> "${TEST_RESULTS}"
815 828