apt: chart update: allow conf.apt.packages as map
This change allows conf.apt.packages to be defined as a map of lists, allowing for logical grouping and easier substitution when values.yaml is being assembled from multiple sources. The existing format (conf.apt.packages as a list) is still supported. Change-Id: I4d4c09723b2e9ac1f0ecf847e786d991cc6e669a
This commit is contained in:
parent
524c1b1e32
commit
788501e806
|
@ -90,8 +90,20 @@ apt-get update
|
||||||
{{- if hasKey .Values.conf.apt "packages" }}
|
{{- if hasKey .Values.conf.apt "packages" }}
|
||||||
apt-get update
|
apt-get update
|
||||||
|
|
||||||
|
{{/* Build a unified list of packages */}}
|
||||||
|
{{- $all_apt_packages := list }}
|
||||||
|
{{- if kindIs "map" .Values.conf.apt.packages }}
|
||||||
|
{{- range $k, $v := .Values.conf.apt.packages }}
|
||||||
|
{{- range $v }}
|
||||||
|
{{- $all_apt_packages = . | append $all_apt_packages }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
{{- $all_apt_packages = .Values.conf.apt.packages }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
# Set all debconf selections up front
|
# Set all debconf selections up front
|
||||||
{{- range .Values.conf.apt.packages }}
|
{{- range $all_apt_packages }}
|
||||||
{{- $pkg_name := .name }}
|
{{- $pkg_name := .name }}
|
||||||
{{- range .debconf }}
|
{{- range .debconf }}
|
||||||
debconf-set-selections <<< "{{ $pkg_name }} {{ .question }} {{ .question_type }} {{ .answer }}"
|
debconf-set-selections <<< "{{ $pkg_name }} {{ .question }} {{ .question_type }} {{ .answer }}"
|
||||||
|
@ -102,7 +114,7 @@ apt-get update
|
||||||
dpkg --configure -a
|
dpkg --configure -a
|
||||||
|
|
||||||
# Perform package installs
|
# Perform package installs
|
||||||
{{- range .Values.conf.apt.packages }}
|
{{- range $all_apt_packages }}
|
||||||
{{- $pkg_name := .name }}
|
{{- $pkg_name := .name }}
|
||||||
if [[ "${CURRENT_PACKAGES[{{ .name | squote }}]+isset}" != "isset"{{- if .version }} || "${CURRENT_PACKAGES[{{ .name | squote }}]}" != {{ .version }}{{- end }} ]]; then
|
if [[ "${CURRENT_PACKAGES[{{ .name | squote }}]+isset}" != "isset"{{- if .version }} || "${CURRENT_PACKAGES[{{ .name | squote }}]}" != {{ .version }}{{- end }} ]]; then
|
||||||
# Run this in case some package installation was interrupted
|
# Run this in case some package installation was interrupted
|
||||||
|
|
|
@ -124,6 +124,37 @@ Here is an example configuration for it::
|
||||||
allow_downgrade: true
|
allow_downgrade: true
|
||||||
- name: <PACKAGE2>
|
- name: <PACKAGE2>
|
||||||
|
|
||||||
|
It is also permissible to use ``conf.apt.packages`` as a map, in which case all
|
||||||
|
the packages from the different groups will be installed. This is primary useful
|
||||||
|
for logical organization. The keys of the map are ignored, and the values are a
|
||||||
|
list of the same format as the packages list above. No deduplication or other
|
||||||
|
processing is performed, just a simple concatenation (without any ordering
|
||||||
|
guarantees). For example::
|
||||||
|
|
||||||
|
conf:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
group1:
|
||||||
|
- name: <PACKAGE1>
|
||||||
|
version: <VERSION1>
|
||||||
|
allow_downgrade: true
|
||||||
|
- name: <PACKAGE2>
|
||||||
|
group2:
|
||||||
|
- name: <PACKAGE3>
|
||||||
|
- name: <PACKAGE4>
|
||||||
|
|
||||||
|
Is equivalent to::
|
||||||
|
|
||||||
|
conf:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- name: <PACKAGE1>
|
||||||
|
version: <VERSION1>
|
||||||
|
allow_downgrade: true
|
||||||
|
- name: <PACKAGE2>
|
||||||
|
- name: <PACKAGE3>
|
||||||
|
- name: <PACKAGE4>
|
||||||
|
|
||||||
There is a possibility to blacklist packages, e.g. ``telnetd`` and ``nis``::
|
There is a possibility to blacklist packages, e.g. ``telnetd`` and ``nis``::
|
||||||
|
|
||||||
conf:
|
conf:
|
||||||
|
|
|
@ -79,6 +79,8 @@ APT_VERSION3="$(apt-cache show $APT_PACKAGE3 | grep Version: | tail -1 | awk '{p
|
||||||
APT_PACKAGE4=less
|
APT_PACKAGE4=less
|
||||||
APT_PACKAGE5=python-setuptools
|
APT_PACKAGE5=python-setuptools
|
||||||
APT_PACKAGE6=telnetd
|
APT_PACKAGE6=telnetd
|
||||||
|
APT_PACKAGE7=sudoku
|
||||||
|
APT_PACKAGE8=ninvaders
|
||||||
APT_REPOSITORY1="http://us.archive.ubuntu.com/ubuntu/"
|
APT_REPOSITORY1="http://us.archive.ubuntu.com/ubuntu/"
|
||||||
APT_DISTRIBUTIONS1="[ xenial ]"
|
APT_DISTRIBUTIONS1="[ xenial ]"
|
||||||
APT_COMPONENTS1="[ main, universe, restricted, multiverse ]"
|
APT_COMPONENTS1="[ main, universe, restricted, multiverse ]"
|
||||||
|
@ -1281,7 +1283,7 @@ test_apt(){
|
||||||
echo '[SUCCESS] apt test5 passed successfully' >> "${TEST_RESULTS}"
|
echo '[SUCCESS] apt test5 passed successfully' >> "${TEST_RESULTS}"
|
||||||
|
|
||||||
# Test blacklistpkgs
|
# Test blacklistpkgs
|
||||||
local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set1.yaml
|
local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set5.yaml
|
||||||
echo "conf:
|
echo "conf:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
|
@ -1294,7 +1296,7 @@ test_apt(){
|
||||||
echo '[SUCCESS] apt test6 passed successfully' >> "${TEST_RESULTS}"
|
echo '[SUCCESS] apt test6 passed successfully' >> "${TEST_RESULTS}"
|
||||||
|
|
||||||
# Test add several repositories with gpg keys
|
# Test add several repositories with gpg keys
|
||||||
local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set5.yaml
|
local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set6.yaml
|
||||||
echo "conf:
|
echo "conf:
|
||||||
apt:
|
apt:
|
||||||
repositories:
|
repositories:
|
||||||
|
@ -1326,7 +1328,7 @@ $(printf '%s' "$APT_GPGKEY3" | awk '{printf " %s\n", $0}')" > "${overri
|
||||||
echo '[SUCCESS] apt test7 passed successfully' >> "${TEST_RESULTS}"
|
echo '[SUCCESS] apt test7 passed successfully' >> "${TEST_RESULTS}"
|
||||||
|
|
||||||
# Test add same gpg key two times
|
# Test add same gpg key two times
|
||||||
local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set6.yaml
|
local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set7.yaml
|
||||||
echo "conf:
|
echo "conf:
|
||||||
apt:
|
apt:
|
||||||
repositories:
|
repositories:
|
||||||
|
@ -1349,6 +1351,21 @@ $(printf '%s' "$APT_GPGKEY1" | awk '{printf " %s\n", $0}')" > "${overri
|
||||||
_test_apt_repositories "$APT_REPOSITORY1 $APT_REPOSITORY2"
|
_test_apt_repositories "$APT_REPOSITORY1 $APT_REPOSITORY2"
|
||||||
_test_apt_keys "$APT_GPGKEYID1"
|
_test_apt_keys "$APT_GPGKEYID1"
|
||||||
echo '[SUCCESS] apt test8 passed successfully' >> "${TEST_RESULTS}"
|
echo '[SUCCESS] apt test8 passed successfully' >> "${TEST_RESULTS}"
|
||||||
|
|
||||||
|
# Test groups of packages using a map
|
||||||
|
local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set8.yaml
|
||||||
|
echo "conf:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
fun:
|
||||||
|
- name: $APT_PACKAGE7
|
||||||
|
funner:
|
||||||
|
- name: $APT_PACKAGE8" > "${overrides_yaml}"
|
||||||
|
install_base "--values=${overrides_yaml}"
|
||||||
|
get_container_status apt
|
||||||
|
_test_apt_package_version $APT_PACKAGE7 any
|
||||||
|
_test_apt_package_version $APT_PACKAGE8 any
|
||||||
|
echo '[SUCCESS] apt test9 passed successfully' >> "${TEST_RESULTS}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# test exec module
|
# test exec module
|
||||||
|
|
Loading…
Reference in New Issue