Arturo Borrero Gonzalez has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/394572 )
Change subject: apt: unattended-upgrades: add reporter script ...................................................................... apt: unattended-upgrades: add reporter script This new script reports pending upgrades by repository and what could be upgraded according to the unattended-upgrades configuration. Bug: T181647 Change-Id: I97b122e6ff0c8f9b0da2000be4ae4c26e2d9c827 Signed-off-by: Arturo Borrero Gonzalez <[email protected]> --- A modules/apt/files/report-pending-upgrades.sh M modules/apt/manifests/unattendedupgrades.pp 2 files changed, 67 insertions(+), 0 deletions(-) Approvals: Arturo Borrero Gonzalez: Looks good to me, approved Rush: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/modules/apt/files/report-pending-upgrades.sh b/modules/apt/files/report-pending-upgrades.sh new file mode 100644 index 0000000..32a53ac --- /dev/null +++ b/modules/apt/files/report-pending-upgrades.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +if [ "$(id -u)" != "0" ] ; then + echo "E: root required" >&2 + exit 1 +fi + +get_binary() +{ + BINARY=$(which $1) + if [ ! -x "$BINARY" ] ; then + echo "E: no $1 binary found" >&2 + exit 1 + fi + echo $BINARY +} + +set -e +APT_GET=$(get_binary apt-get) +APT_SHOW_VERSIONS=$(get_binary apt-show-versions) +UNATTENDED_UPGRADES=$(get_binary unattended-upgrades) +set +e + +$APT_GET update >/dev/null + +# get upgradeable packages +APT_SHOW_VERSIONS_OUTPUT=$($APT_SHOW_VERSIONS | grep upgradeable | sort -t / -k 2) +n1=$(echo "$APT_SHOW_VERSIONS_OUTPUT" | grep -v ^$ | wc -l) +if [ "$n1" != "0" ] ; then + # iterate each source repo/channel + sources=$(echo "$APT_SHOW_VERSIONS_OUTPUT" | awk -F'/' '{print $2}' | awk -F' ' '{print $1}' | uniq) + for src in $sources ; do + src_output=$(echo "$APT_SHOW_VERSIONS_OUTPUT" | grep "/$src ") + n3=$(echo "$src_output" | wc -l) + echo "I: upgradeable packages from ${src}: $n3" + echo + echo "$src_output" | sed -e 's/^/ /' # add spaces to output + echo + done +fi + +# get upgradeable packages by current unattended-upgrades config +UNATTENDED_UPGRADES_OUTPUT=$($UNATTENDED_UPGRADES --dry-run -v -d | grep "Packages that will be upgraded" | awk -F':' '{print $2}' | grep -v ^[[:space:]]*$) +n2=$(echo "$UNATTENDED_UPGARDES_OUTPUT" | grep -v ^$ | wc -l) +if [ "$n2" != "0" ] ; then + echo "I: upgradeable packages by unattended-upgrades: $n2" + echo + echo "$UNATTENDED_UPGARDES_OUTPUT" | sed -e 's/^/ /' # add spaces to output + echo +fi + +if [ "$n1" != "0" ] || [ "$n2" != "0" ] ; then + echo "I: $n1 upgradeable packages, $n2 upgradeable packages by unatteneded-upgrades" +fi diff --git a/modules/apt/manifests/unattendedupgrades.pp b/modules/apt/manifests/unattendedupgrades.pp index 414afcc..0878ac6 100644 --- a/modules/apt/manifests/unattendedupgrades.pp +++ b/modules/apt/manifests/unattendedupgrades.pp @@ -17,6 +17,10 @@ ensure => 'present', } + package { 'apt-show-versions': + ensure => 'present', + } + # dpkg tries to determine the most conservative default action in case of # conffile conflict. This tells dpkg to use that action without asking apt::conf { 'dpkg-force-confdef': @@ -66,4 +70,13 @@ value => 'origin=Wikimedia,codename=${distro_codename}-wikimedia', # lint:endignore } + + file { '/usr/local/sbin/report-pending-upgrades': + ensure => present, + owner => 'root', + group => 'root', + mode => '0755', + source => 'puppet:///modules/apt/report-pending-upgrades.sh', + require => Package['apt-show-versions'], + } } -- To view, visit https://gerrit.wikimedia.org/r/394572 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I97b122e6ff0c8f9b0da2000be4ae4c26e2d9c827 Gerrit-PatchSet: 8 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Arturo Borrero Gonzalez <[email protected]> Gerrit-Reviewer: Arturo Borrero Gonzalez <[email protected]> Gerrit-Reviewer: Rush <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
