Software-Updates für zwei-bis-viele Systeme Chemnitzer Linux-Tage 2015 Dipl.-Ing. Thomas Liske mailto:liske@ibh.de IBH IT-Service GmbH Gostritzer Straße 67a 01217 Dresden https://www.ibh.de/ www.ibh.de
Einleitung
`whoami` Thomas Liske > 15 Jahre Erfahrung mit GNU/Linux OSS-Projekte: apt-dater, imvirt, needrestart, seit 2008 bei IBH IT-Service GmbH in Dresden IBH IT-Service GmbH ISP, Hosting-Anbieter und Systemhaus: erster sächsischer ISP seit August 2014 (AS15372) 5 Rechenzentren und mehrere Netzknoten in Dresden
GNU/Linux @ IBH Betrieb von mehr als 100 GNU/Linux-Systemen: ISP-Betrieb interne Systeme Hosting-Dienste Kunden-Systeme typische Herausforderungen: Hosts mit ausstehenden Updates? Protokollierung & Zeiterfassung mehrere gleichzeitige Nutzer Suche nach: Distri / Release Virtualisierung installierten Paketen / Versionen Debian wheezy Debian squeeze Debian jessie andere
Entwicklung 2008: Freigabe auf SF.NET und Debian Upload Entwickler: Andre Ellguth (a.d.) Thomas Liske zahlreiche Mitwirkende: Bug Reports, Feature Requests, Lokalisierung [de, it, pt] Debian Version ITP 0.6 lenny 0.7 squeeze wheezy 0.5 0.8 0.9 2008 2010 2012 2014
Architektur
Management Host zentrale Verwaltungskonsole Verwendung eines Nutzer-Logins durch verschiedene Benutzer ncurses-basierendes Frontend screen(1) zur Sessionverwaltung
Managed Hosts Kommunikation via SSH unterstützte Paketverwaltungen: <dpkg> + <apt aptitude> <rpm> + [rug yum zypper] <wua>* *) Windows Update Agent: FOR DEMONSTRATION PURPOSE ONLY!
apt-dater
als root: # apt-get install apt-dater Installation als Nutzer: $ apt-dater ** Message: Creating file /home/liske/.config/apt-dater/hosts.conf ** Message: Creating file /home/liske/.config/apt-dater/screenrc ** Message: Creating file /home/liske/.config/apt-dater/apt-dater.conf TODO: SSH-Schlüssel generieren (ssh-keygen) SSH-Schlüssel verteilen (ssh-copy-id) hosts.conf anpassen und apt-dater-host verteilen
UI
Sessions
Host Details
apt-dater.conf glib's Key File Format Grundeinstellungen Konfiguration [Paths] # Default: $XDG_CONFIG_HOME/apt-dater/hosts.conf #HostsFile=path-to/hosts.conf # Default: $XDG_DATA_HOME/apt-dater #StatsDir=path-to/stats [SSH] # SSH binary Cmd=/usr/bin/ssh OptionalCmdFlags=-t # SFTP binary SFTPCmd=/usr/bin/sftp #[Screen] ## Default: $XDG_CONFIG_HOME/apt-dater/screenrc #RCFile=path-to/screenrc # ## Default: %m # %u@%h:%p #Title=%m # %U%H #
hosts.conf Konfiguration glib's Key File Format Definition von Gruppen mit Hosts # Syntax: # # [Group] # Hosts=([OptionalUser@]host.domain[:OptionalPort];)* # [Localdomain] Hosts=localhost; [IBH] Hosts=example1.ibh.net;example2.ibh.net;test@example3.ibh.net:62222; [Customer] Hosts=foo@bar.com; IdentityFile=/path/to/id_rsa
screenrc Konfiguration angepasste Konfiguration für screen(1) startup_message off # define a bigger scrollback, default is 100 lines defscrollback 2048 # Remove some stupid / dangerous key bindings bind ^k #bind L bind ^\ # Make them better bind \\ quit bind K kill bind I login on bind O login off bind } history # Sessions should stay until destroyed by pressing q zombie 'q' # Add caption line with clock, window title and window flags. caption always "%{b bg}%c%=%t%=%f"
apt-dater-host
als root: # apt-get install apt-dater-host Installation Konfiguration anpassen: /etc/sudoers.d/apt-dater-host ~/.ssh/authorized_keys /etc/apt-dater-host.conf (optional) Test als Nutzer: $ apt-dater-host refresh
apt-dater-host Perl-Skript: für Paketverwaltung spezifisches Skript in $PATH /etc/apt-dater-host.conf # front-end for dpkg to use (apt-get, aptitude) $DPKGTOOL="apt-get"; # Method to do upgrades, possible values (depends on $DPKGTOOL): $APTUPGRADE='dist-upgrade'; # enable use of --assume-yes on safe-upgrade $ASSUMEYES=1; # use this command to become root $GETROOT="sudo"; # the installation UUID $UUIDFILE = '/etc/apt-dater-host.uuid'; # Check if needrestart is available. $NEEDRESTART = (-x'/usr/sbin/needrestart'?'/usr/sbin/needrestart':undef); # prevent apt-dater-host from upgrading packages #$FORBID_UPGRADE=1;
Aufruf als normaler Nutzer apt-dater-host # apt-dater-host sudoers.d config file # ------------------------------------ # Keep apt-dater's MAINTAINER environment variable #Defaults env_keep += MAINTAINER # Allow members of group adm to execute the apt-get command %adm ALL=NOPASSWD: /usr/bin/apt-get,/usr/sbin/needrestart genutzte Kommandos: $ apt-dater-host refresh $ apt-dater-host upgrade # apt-get update # apt-get dist-upgrade -y $ apt-dater-host install $PKG # apt-get install $PKG
apt-dater-host $ apt-dater-host refresh ADPROTO: 0.7 Get:19 http://ftp.de.debian.org jessie/main 2015-03-14-1445.37.pdiff Get:20 http://ftp.de.debian.org jessie/main i386 2015-03-14-1445.37.pdiff Get:21 http://ftp.de.debian.org jessie/main 2015-03-14-1445.37.pdiff Fetched 403 kb in 3s (119 kb/s) Reading package lists... Done LSBREL: Debian 8.0 jessie VIRT: Physical UNAME: Linux x86_64 FORBID: 0 UUID: 40a437f0-9f1e-11de-a398-001a4d577e31 NEEDRESTART-VER: 1.2 NEEDRESTART-KCUR: 3.19.0-tl1 NEEDRESTART-KEXP: 3.19.2-tl1+ NEEDRESTART-KSTA: 3 NEEDRESTART-SVC: bind9.service NEEDRESTART-SVC: cron.service STATUS: hostname 3.15 i STATUS: libc6 2.19-15 i STATUS: libc6:i386 2.19-15 i STATUS: patch 2.7.1-6 u=2.7.5-1 STATUS: linux-headers-3.16.0-4-amd64 3.16.7-ckt4-3 u=3.16.7-ckt7-1 STATUS: emacs24 24.4+1-4.1 u=24.4+1-5 STATUS: libasound2:i386 1.0.28-1 i KERNELINFO: 2 3.19.0-tl1
Features
XML Report $ apt-dater -[n]r <?xml version="1.0"?> <report> <timestamp>1426007924</timestamp> <group name="ibh"> <host hostname="foo.ibh-dialin.net"> <status status="1">up to date</status> <ssh/> <kernel reboot="1">2.6.32-5-686-bigmem</kernel> <lsb> <distri>debian</distri> <release>6.0.10</release> <codename>squeeze</codename> </lsb> <uname> <kernel>linux</kernel> <machine>i686</machine> </uname> <virt>xen</virt> <uuid>7271e348-b280-11de-b52e-00200f79a0c</uuid> <history> </history> <packages> <pkg name="adduser" version="3.112+nmu2"/> </packages> </host> 0.6.0
TCL Filter 0.6.0
History Aufzeichnung interaktiver Sitzungen Hinweis auf Fehler bei Upgrades apt-dater.conf: [History] ErrPattern 0.8.0
Clusters Serialisierung von Updates gedacht für Cluster, Load Balancer o.ä. Konfiguration auf Hosts (apt-dater-host.conf): # If this host is part of (multiple) cluster(s), you might set a # symbolic name. Hosts with the same cluster name won't be upgraded # simultaneously by apt-dater (requires apt-dater 0.9 or above). @CLUSTERS = qw(my-db-cluster); 0.9.0
Backstage
Hooks Ausführen vor und nach Aktionen: Aktion Pfad connect install refresh /etc/apt-dater/pre-con.d/ /etc/apt-dater/post-con.d/ /etc/apt-dater/pre-ins.d/ /etc/apt-dater/post-ins.d/ /etc/apt-dater/pre-ref.d/ /etc/apt-dater/post-ref.d/ update /etc/apt-dater/pre-upd.d/ /etc/apt-dater/post-upd.d/ Host-Informationen via Umgebungsvariablen (AD_*): AD_HOSTNAME AD_GROUP AD_KERNEL AD_LSB_RELEASE 0.8.1
Plugins Unterstützung von alternativen Verbindungen statt ssh(1) apt-dater.conf [Hooks] PluginDir = /etc/apt-dater/plugins hosts.conf # # [Group] # Hosts=([OptionalUser@]host.domain[:OptionalPort];)* # 0.8.1 [IBH] Hosts=foo.ibh-dialin.net; Type=my-bar-plugin
Plugins /etc/apt-dater/plugins/my-bar-plugin #!/bin/sh case "$AD_ACTION" in connect) ;; refresh) ;; esac *) echo 'Oops!' 1>&2 exit 1; ;;
Hooks & Plugins
apt-dater protocol (ADP) Schnittstelle zwischen apt-dater und apt-dater-host: möglichst rückwärtskompatibel zeilenorientiert unbekannte Schlüsselwörter werden ignoriert Plugins können direkte ADP-Schnittstelle implementieren ADP version ADPROTO: 0.7 lsb_release LSBREL: Debian 7.8 wheezy clusters CLUSTER: my-pgsql-cluster virtualization VIRT: Xen PV uname -s uname -m UNAME: Linux x86_64 package lines STATUS: libsasl2-modules:i386 2.1.26.dfsg1-12 u=2.1.26.dfsg1-13
Vorschau
apt-dater 1.x XML-basiertes Konfigurationsformat Einbinden weiterer Konfigdateien via Xinclude Vererbung von Parametern <hosts xmlns:xi="http://www.w3.org/2001/xinclude" ssh-user="ibh-support"> <!-- Include global config file if available. --> <xi:include href="file:///etc/apt-dater/hosts.xml" xpointer="xpointer(/hosts/*)"> <xi:fallback /> </xi:include> <group name="ibh Web Services" ssh-id="/etc/apt-dater/ssh/id_www"> <host name="worker-01" ssh-host="2a01:7700:0:2059::8001"/> <host name="worker-02" ssh-host="2a01:7700:0:2059::8002"/> <host name="worker-03" ssh-host="2a01:7700:0:2059::8003"/> </group> </hosts>
apt-dater apt-dater 1.x Ausbau Filterfunktionen Unterstützung geteilter Sitzungen zwischen Nutzern Klassifizierung von Updates (Security, Upstream, 3rd Party) apt-dater-host Unterstützung verschiedener Paketverwaltungen in einem Skript Hooks
End-Of-Talk
imvirt Verwandte Projekte Homepage http://micky.ibh.net/~liske/imvirt.html Debian Pakete https://packages.debian.org/imvirt VCS https://github.com/de-ibh/imvirt needrestart Homepage https://fiasko-nw.net/~thomas/tag/needrestart.html Debian Pakete https://packages.debian.org/needrestart VCS https://github.com/liske/needrestart https://github.com/liske/needrestart-session
apt-dater Projektseite: https://www.ibh.de/apt-dater/ Quellen: https://github.com/de-ibh/apt-dater offizielle Debian-Pakete: https://packages.debian.org/apt-dater squeeze: 0.8.4 squeeze-backports: 0.9.0 wheezy: 0.9.0 jessy: 0.9.0 sid: 1.0.1+ Slide powered by Chart.js highlight.js impress.js impress.js-progress impress-console vis.js