Compare commits

...

12 commits

Author SHA1 Message Date
Benoît S. a66f736cfe newkernel: No accent in subject
Some checks reported errors
continuous-integration/drone/pr Build encountered an error
continuous-integration/drone/push Build is passing
2019-08-22 17:59:26 +02:00
Benoît S. bebfd11917 newkernel: Fix date and subject in script
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build encountered an error
2019-08-22 17:57:43 +02:00
Benoît S. bb2bf2f453 newkernel: main.yml using right name
Some checks reported errors
continuous-integration/drone/pr Build encountered an error
continuous-integration/drone/push Build is passing
2019-08-22 17:44:11 +02:00
Benoît S. 8dc8cbe432 newkernel: cron running every first day of month
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build is failing
2019-08-22 17:43:09 +02:00
Benoît S. f93c7bb1c0 newkernel: Better mail text
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build encountered an error
2019-08-22 17:41:21 +02:00
Benoît S. a155bac12c newkernel: Text align
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build encountered an error
2019-08-22 17:39:27 +02:00
Benoît S. c4ae3afa89 newkernel: Oops wrong comment.
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build encountered an error
2019-08-22 17:36:25 +02:00
Benoît S. b80801b1e3 newkernel: Compute the date
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build encountered an error
2019-08-22 17:33:26 +02:00
Benoît S. d8dd5a2847 newkernel: Update README
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build is failing
2019-08-22 17:09:08 +02:00
Benoît S. 4b5801c5f1 newkernel: Remove listupgrade scripts
Some checks reported errors
continuous-integration/drone/pr Build encountered an error
continuous-integration/drone/push Build is passing
2019-08-22 17:05:40 +02:00
Benoît S. 28e5b95be3 newkernel: Remove kitchen tests
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build encountered an error
2019-08-22 17:03:36 +02:00
Benoît S. 59995ca92e Init newkernel role
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build is failing
2019-08-16 16:48:35 +02:00
7 changed files with 166 additions and 0 deletions

8
newkernel/README.md Normal file
View file

@ -0,0 +1,8 @@
# newkernel
Installs and configures a script to help manages to reboot on a new kernel.
This script will send an mail when a new kernel is available to plan a reboot.
## Tasks
Installation and configuration are performed via `tasks/main.yml`.

View file

@ -0,0 +1,3 @@
---
general_alert_email: "root@localhost"
listupgrade_alert_email: Null

28
newkernel/meta/main.yml Normal file
View file

@ -0,0 +1,28 @@
galaxy_info:
author: Evolix
description: Installation and configuration of the listupgrade script
issue_tracker_url: https://gitea.evolix.org/evolix/ansible-roles/issues
license: GPLv2
min_ansible_version: 2.2
platforms:
- name: Debian
versions:
- jessie
galaxy_tags: []
# List tags for your role here, one per line. A tag is
# a keyword that describes and categorizes the role.
# Users find roles by searching for tags. Be sure to
# remove the '[]' above if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of
# alphanumeric characters. Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line.
# Be sure to remove the '[]' above if you add dependencies
# to this list.

54
newkernel/tasks/main.yml Normal file
View file

@ -0,0 +1,54 @@
---
- include_role:
name: remount-usr
- name: Scripts dir is present
file:
path: "/usr/share/scripts"
state: directory
owner: root
group: root
mode: "0700"
- name: Copy newkernel script
template:
src: newkernel.sh.j2
dest: "/usr/share/scripts/newkernel.sh"
mode: "0700"
owner: root
group: root
force: yes
- name: Create /etc/evolinux
file:
path: /etc/evolinux
state: directory
owner: root
group: root
mode: "0700"
- name: Copy newkernel config
template:
src: newkernel.cnf.j2
dest: /etc/evolinux/newkernel.cnf
mode: "0600"
owner: root
group: root
force: no
- name: Cron.d is present
file:
path: "/etc/cron.d"
state: directory
mode: "0755"
owner: root
group: root
- name: Enable newkernel cron
template:
src: newkernel_cron.j2
dest: /etc/cron.d/newkernel
mode: "0600"
owner: root
group: root

View file

@ -0,0 +1,4 @@
#date="entre 18h00 et 23h00"
#clientmail="client@evolix.net"
#mailto="{{ listupgrade_alert_email or general_alert_email | mandatory }}"
#hostname=""

View file

@ -0,0 +1,68 @@
#!/bin/bash
set -e
configFile="/etc/evolinux/newkernel.cnf"
template=$(mktemp --tmpdir=/tmp evoupdate.XXX)
clientmail=$(grep EVOMAINTMAIL /etc/evomaintenance.cf | cut -d'=' -f2)
mailto=$clientmail
# By default, plan the reboot next month thursday
date="$(date --date="next thursday + 3 weeks" +%A\ %d\ %B)"
hour="entre 18h00 et 23h00"
hostname=$(grep HOSTNAME /etc/evomaintenance.cf | cut -d'=' -f2)
hostname=${hostname%%.evolix.net}
# If hostname is composed with -, remove the first part.
if [[ $hostname =~ "-" ]]; then
hostname=$(echo $hostname | cut -d'-' -f2-)
fi
# Edit $configFile to override some variables.
[ -r $configFile ] && . $configFile
# Remove temporary files on exit.
trap "rm $template" EXIT
# No updates? Exit!
nextKernel=$(grep -m1 -aEo "#1 SMP Debian .* \([0-9]{4}-[0-9]{2}-[0-9]{2}\)" /vmlinuz)
currentKernel=$(uname -v)
if [ "$nextKernel" = "$currentKernel" ]; then
exit 0
fi
#To: ${clientmail}
cat << EOT > $template
Content-Type: text/plain; charset="utf-8"
Reply-To: equipe@evolix.fr
From: equipe@evolix.net
To: $clientmail
Subject: Prochain creneau pour redemarrage de votre serveur $hostname
X-Date: $date
Bonjour,
Le noyau de votre serveur doit être mis à jour. Pour cela nous devons
redémarrer votre machine ${hostname}.
Sauf indication contraire de votre part, le prochain créneau prévu pour
mettre à jour le noyau de votre serveur est :
Le ${date}, ${hour}.
Si nous intervenons, un redémarrage complet du serveur sera réalisé, entraînant
plusieurs minutes de coupures. Nous nous assurerons de vérifier le bon
démarrage de la machine ainsi que de ses services. Si nous ne sommes pas
intervenus sur ce créneau, vous recevrez une nouvelle notification le mois
prochain.
Votre version actuelle du noyau : $currentKernel
Après redémarrage votre version sera : $nextKernel
N'hésitez pas à nous faire toute remarque sur ce créneau d'intervention le plus
tôt possible.
Cordialement,
--
Équipe Evolix <equipe@evolix.fr>
Evolix - Hébergement et Infogérance Open Source http://www.evolix.fr/
EOT
<$template /usr/sbin/sendmail $mailto

View file

@ -0,0 +1 @@
42 9 1 * * root /usr/share/scripts/newkernel.sh