From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id AEzsHC/27l+NZAAA0tVLHw (envelope-from ) for ; Fri, 01 Jan 2021 10:15:11 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id yNGOGC/27l/oIwAAbx9fmQ (envelope-from ) for ; Fri, 01 Jan 2021 10:15:11 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6623594050C for ; Fri, 1 Jan 2021 10:15:10 +0000 (UTC) Received: from localhost ([::1]:33184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kvHSf-0000Pk-AH for larch@yhetil.org; Fri, 01 Jan 2021 05:15:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvHSY-0000PO-5w for guix-patches@gnu.org; Fri, 01 Jan 2021 05:15:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:43815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kvHSX-0006W4-U2 for guix-patches@gnu.org; Fri, 01 Jan 2021 05:15:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kvHSX-00059w-Px for guix-patches@gnu.org; Fri, 01 Jan 2021 05:15:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45589] [PATCH] services: Add keepalived service. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 01 Jan 2021 10:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45589 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45589@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160949608119785 (code B ref -1); Fri, 01 Jan 2021 10:15:01 +0000 Received: (at submit) by debbugs.gnu.org; 1 Jan 2021 10:14:41 +0000 Received: from localhost ([127.0.0.1]:55361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvHSA-000590-Dw for submit@debbugs.gnu.org; Fri, 01 Jan 2021 05:14:41 -0500 Received: from lists.gnu.org ([209.51.188.17]:55544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvHS8-00058s-Dc for submit@debbugs.gnu.org; Fri, 01 Jan 2021 05:14:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvHS8-0000ND-8h for guix-patches@gnu.org; Fri, 01 Jan 2021 05:14:36 -0500 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]:36041) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kvHS6-0006Lq-Ax for guix-patches@gnu.org; Fri, 01 Jan 2021 05:14:35 -0500 Received: by mail-lf1-x135.google.com with SMTP id o13so48435930lfr.3 for ; Fri, 01 Jan 2021 02:14:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tWeT4MQhBDlTUeblpf3lU36d3kAVbL9MuqiJCGEp4gg=; b=T6fY/9cb01klmCQuGkAqMJwL1hnW+/19OQhDdKlqz5p656mcgxB+a4FS4UGUzej2uE NNkVTS8ozJ7Pv5GkTWER+YDsDR4mBTUI+bZ4/TQ8M/eE6l6I9PVIxGhx8YgMgjDjkaSi 6Wt5bl8Vr7/yrfqXSdIKK3zJREAHvYpQmLqjStipPWin3ut87UyXdXTsDcoJNXTNyCjU PinY02tJfC6ZV/dz8lbb8FWMyNJDJm07gb9moCXIioEb9QXlXRjRao2DKB3O1Z4O5ejt 26bK747iyuNxGO+4XzbQKBw7DV8aaGwiwdFF1UfhNIt3LnS8+xSb/bMeS8XVJs2z8tei B+HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tWeT4MQhBDlTUeblpf3lU36d3kAVbL9MuqiJCGEp4gg=; b=ZdW6F6rald8mAFyAHkPLdGl0INKc5YuWxhpA8k9spGcU1XNQj1264U8O2rO9rxjJBh 3dQZh9Pn+IPoM52/DH/EZPSbWmQRsvOQswo7ydA9qA2I/18JcS7Kh1lq6+09qhL/aOON HgY8gHaQFgo4soXughSr8rMDLL1vE66AgGJsHlYuEUeRSHqRLrPHNgbvkNZqrhJz22FD pZUGY0N0XJOczIzDvACjMNu37XxOa7KBLYqatXNCd/YDbTyg7aVLxUgA17hyo1V5guF4 tmdNT05nGrDcoEaMJzd2HesrxH/ifXY/lKMxOO3pVOrtX9Xd/D09RtFreG344musMcEj Zgrg== X-Gm-Message-State: AOAM530xSFT4lMVMy7p4d1jz6TblRvTkWqFC+/jK685FsvdfIhAXJ6ws +43F9zz07q2GOUB2tEywh7GIqTgOvh0= X-Google-Smtp-Source: ABdhPJzKiiUYvxaSRMi0BoNTdJdaRidoAwhbRPjeVIb+VvzFHPClCSkJxq0uKJhSfMkq3l7AX6kAxA== X-Received: by 2002:a2e:9f01:: with SMTP id u1mr28709954ljk.386.1609496071064; Fri, 01 Jan 2021 02:14:31 -0800 (PST) Received: from localhost.localdomain ([178.71.74.207]) by smtp.gmail.com with ESMTPSA id v10sm7834648lji.130.2021.01.01.02.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 02:14:30 -0800 (PST) From: Oleg Pykhalov Date: Fri, 1 Jan 2021 13:14:21 +0300 Message-Id: <20210101101421.9847-1-go.wigust@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=go.wigust@gmail.com; helo=mail-lf1-x135.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.23 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=gmail.com header.s=20161025 header.b=T6fY/9cb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 6623594050C X-Spam-Score: -1.23 X-Migadu-Scanner: scn1.migadu.com X-TUID: Bp+bnuhc3Hnf * gnu/services/networking.scm (): New record. (keepalived-shepherd-service): New procedure. (keepalived-service-type): New variable. * doc/guix.texi (Networking Services): Document this. --- doc/guix.texi | 54 ++++++++++++++++++++++++++++++++++++- gnu/services/networking.scm | 47 +++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1081ed26a3..b11554fb4d 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -55,7 +55,7 @@ Copyright @copyright{} 2017 Andy Wingo@* Copyright @copyright{} 2017, 2018, 2019, 2020 Arun Isaac@* Copyright @copyright{} 2017 nee@* Copyright @copyright{} 2018 Rutger Helling@* -Copyright @copyright{} 2018 Oleg Pykhalov@* +Copyright @copyright{} 2018, 2021 Oleg Pykhalov@* Copyright @copyright{} 2018 Mike Gerwitz@* Copyright @copyright{} 2018 Pierre-Antoine Rouby@* Copyright @copyright{} 2018, 2019 Gábor Boskovits@* @@ -17156,6 +17156,58 @@ address, delete everything except these options: @end table @end deftp +@cindex keepalived +@deffn {Scheme Variable} keepalived-service-type +This is the type for the @uref{https://www.keepalived.org/, Keepalived} +routing software, @command{keepalived}. Its value must be an +@code{keepalived-configuration} record as in this example for master +machine: + +@lisp +(service keepalived-service-type + (keepalived-configuration + (config-file (local-file "keepalived-master.conf")))) +@end lisp + +where @file{keepalived-master.conf}: + +@example +vrrp_instance my-group @{ + state MASTER + interface enp9s0 + virtual_router_id 100 + priority 100 + unicast_peer @{ 10.0.0.2 @} + virtual_ipaddress @{ + 10.0.0.4/24 + @} +@} +@end example + +and for backup machine: + +@lisp +(service keepalived-service-type + (keepalived-configuration + (config-file (local-file "keepalived-backup.conf")))) +@end lisp + +where @file{keepalived-backup.conf}: + +@example +vrrp_instance my-group @{ + state BACKUP + interface enp9s0 + virtual_router_id 100 + priority 99 + unicast_peer @{ 10.0.0.3 @} + virtual_ipaddress @{ + 10.0.0.4/24 + @} +@} +@end example +@end deffn + @node Unattended Upgrades @subsection Unattended Upgrades diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 9ec0f6a9ca..44754781c1 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -14,6 +14,7 @@ ;;; Copyright © 2019 Sou Bunnbu ;;; Copyright © 2019 Alex Griffin ;;; Copyright © 2020 Brice Waegeneire +;;; Copyright © 2021 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. ;;; @@ -42,6 +43,7 @@ #:use-module (gnu packages admin) #:use-module (gnu packages base) #:use-module (gnu packages bash) + #:use-module (gnu packages cluster) #:use-module (gnu packages connman) #:use-module (gnu packages freedesktop) #:use-module (gnu packages linux) @@ -192,7 +194,11 @@ yggdrasil-configuration-log-level yggdrasil-configuration-log-to yggdrasil-configuration-json-config - yggdrasil-configuration-package)) + yggdrasil-configuration-package + + keepalived-configuration + keepalived-configuration? + keepalived-service-type)) ;;; Commentary: ;;; @@ -1865,4 +1871,43 @@ See yggdrasil -genconf for config options.") (service-extension profile-service-type (compose list yggdrasil-configuration-package)))))) + +;;; +;;; Keepalived +;;; + +(define-record-type* + keepalived-configuration make-keepalived-configuration + keepalived-configuration? + (keepalived keepalived-configuration-keepalived ; + (default keepalived)) + (config-file keepalived-configuration-config-file ;file-like + (default #f))) + +(define keepalived-shepherd-service + (match-lambda + (($ keepalived config-file) + (list + (shepherd-service + (provision '(keepalived)) + (documentation "Run keepalived.") + (requirement '(loopback)) + (start #~(make-forkexec-constructor + (list (string-append #$keepalived "/sbin/keepalived") + "--dont-fork" "--log-console" "--log-detail" + "--pid=/var/run/keepalived.pid" + (string-append "--use-file=" #$config-file)) + #:pid-file "/var/run/keepalived.pid" + #:log-file "/var/log/keepalived.log")) + (respawn? #f) + (stop #~(make-kill-destructor))))))) + +(define keepalived-service-type + (service-type (name 'keepalived) + (extensions (list (service-extension shepherd-root-service-type + keepalived-shepherd-service))) + (description + "Run @uref{https://www.keepalived.org/, Keepalived} +routing software."))) + ;;; networking.scm ends here -- 2.29.2