Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unixPb: run the updatepackage.sh script via dockerhost playbook #3152

Merged
merged 3 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
#!/bin/bash
#!/bin/bash
set -u

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
containerIds=$(docker ps -q)

commonPackages="gnupg fakeroot"
fedoraPackages="procps-ng hostname shared-mime-info"
debianPackages=""
alpinePackages=""

for container in $containerIds
do
OS=$(docker exec -it $container sh -c "cat /etc/os-release" | head -n 1)
if [[ $OS =~ "CentOS" || $OS =~ "Fedora" || $OS=~ "Red Hat Enterprise Linux" ]]; then
installCommand="yum -y update"
elif [[ $OS =~ "Ubuntu" || $OS =~ "Debian" ]]; then
installCommand="apt-get update && apt-get -y upgrade"
elif [[ $OS =~ "Alpine" ]]; then
installCommand="apk update && apk upgrade"
if [[ "$OS" == *"CentOS"* ]] || [[ "$OS" == *"Fedora"* ]] || [[ "$OS" == *"Red Hat Enterprise Linux"* ]]; then
installCommand="yum -y update && yum -y install $commonPackages $fedoraPackages"
elif [[ "$OS" == *"Ubuntu"* ]] || [[ "$OS" == *"Debian"* ]]; then
installCommand="apt-get update && apt-get -y upgrade && apt-get -y install $commonPackages $debianPackages"
elif [[ "$OS" == *"Alpine"* ]]; then
installCommand="apk update && apk upgrade && apk --update add $commonPackages $alpinePackages"
else
echo "Unrecognised OS, skipping package update"
continue
fi
echo "Updating packages for container $container"
echo "Running $installCommand"
docker exec -it $container sh -c "$installCommand"
echo "=============================================="
done
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@
regexp: kernel_core_pattern
line: kernel.core_pattern=core.%p

- name: Copy updatepackages.sh script to remote cron.daily directory
copy:
src: scripts/updatepackages.sh
dest: /etc/cron.daily/updatepackages.sh
owner: root
group: root
mode: +x
- name: Run updatePackage.sh script
script: scripts/updatepackages.sh
args:
executable: bash
tags:
- updateContainers
- never