Authentication-Results: mail-b.sr.ht; dkim=pass header.d=secluded.site header.i=@secluded.site Received: from mx.nixnet.email (mx.nixnet.email [94.16.121.167]) by mail-b.sr.ht (Postfix) with ESMTPS id 73ED211F013 for <~whereswaldon/arbor-dev@lists.sr.ht>; Thu, 21 Jul 2022 03:10:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by mx.nixnet.email (Postfix) with ESMTPSA id 511FD20286C; Wed, 20 Jul 2022 23:10:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secluded.site; s=202002021149; t=1658373035; h=from:from:reply-to:subject:subject:to:to:cc:cc; bh=vc9tjYtJWR1Xnr59i7SGoN2Q7/Pmc1zHKcZ+K53bdug=; b=JrrFqtpi8CBLCus+cqU1ucRP6dXXj0/Q4TxaOGbW1nfYnrp2qJjEsiS5scefxZbnl6LqEU 5+IDWHwYoExDtOG9RSrCqOvhDR3uqbhWQwLvxBrMPX8tUTNyDjJplEKrYtWWpuo+P7taP7 aI9eWtmTD3rxgozGMhwLFuBvO6uuAq0= From: Amolith To: ~whereswaldon/arbor-dev@lists.sr.ht Cc: Amolith Subject: [PATCH 06/12] Add Prometheus and Caddy targets Date: Wed, 20 Jul 2022 23:09:55 -0400 Message-Id: <20220721031001.97027-7-amolith@secluded.site> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220721031001.97027-1-amolith@secluded.site> References: <20220721031001.97027-1-amolith@secluded.site> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Signed-off-by: Amolith --- setup.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/setup.go b/setup.go index 1c1c602..e9f4cbc 100644 --- a/setup.go +++ b/setup.go @@ -23,8 +23,8 @@ var files embed.FS // Handles initial configuration of the instance func Deploy() error { - mg.Deps(Users, Sudoers, Apt, Firewall) - + // Run the various mage targets + mg.Deps(Users, Sudoers, Apt, Firewall, Prometheus, Caddy) // Finally override the ssh config to disallow root login. // This is the point of no return and will create a zombie @@ -156,6 +156,25 @@ func Firewall() error { return sh.Run("ufw", "enable") } +func Prometheus() error { + log.Println("Running target Prometheus") + err := config("files/prometheus.yml", "/etc/prometheus/prometheus.yml") + if err != nil { + return err + } + return sh.Run("systemctl", "restart", "prometheus") +} + +// Copy Caddyfile to system and restart daemon +func Caddy() error { + log.Println("Running target Caddy") + err := config("files/Caddyfile", "/etc/caddy/Caddyfile") + if err != nil { + return err + } + return sh.Run("systemctl", "restart", "caddy") +} + // config() takes source template and destination file arguments and executes // the template replacing `hostname` with the system's hostname. func config(rfile string, wfile string) error { -- 2.37.1