ALT Linux Distributions development
 help / color / mirror / Atom feed
* [devel-distro] feature/gitlab-runner
@ 2021-12-04 21:12 Konstantin Lepikhov
  2021-12-06  6:50 ` Антон Мидюков
  0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Lepikhov @ 2021-12-04 21:12 UTC (permalink / raw)
  To: devel-distro

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

Привет!

Сделал feature для добавления gitlab-runner. Пакет было собирать влом,
поэтому обошелся доп. функционалом в mkimage и hasher.

Как конфигурировать потом этот gitlab-runner зависит от задачи, поэтому
оставляю простор для творчества.

-- 
WBR et al.

[-- Attachment #2: 0091-features-add-gitlab-runner.patch --]
[-- Type: text/x-patch, Size: 3729 bytes --]

>From 930995ae8a82d4e8ffd95cebea23f4a6c533f82b Mon Sep 17 00:00:00 2001
From: "Konstantin A. Lepikhov" <lakostis@altlinux.ru>
Date: Sat, 4 Dec 2021 14:51:18 +0100
Subject: [PATCH 91/94] features: add gitlab-runner

- Add gitlab-runner feature.
---
 features.in/gitlab-runner/README              | 11 ++++
 features.in/gitlab-runner/config.mk           | 13 ++++
 .../rootfs/image-scripts.d/60-gitlab-install  | 61 +++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 features.in/gitlab-runner/README
 create mode 100644 features.in/gitlab-runner/config.mk
 create mode 100755 features.in/gitlab-runner/rootfs/image-scripts.d/60-gitlab-install

diff --git a/features.in/gitlab-runner/README b/features.in/gitlab-runner/README
new file mode 100644
index 00000000..2e09e84b
--- /dev/null
+++ b/features.in/gitlab-runner/README
@@ -0,0 +1,11 @@
+This feature installs gitlab-runner according official guide [1]
+
+The following envs can be altered:
+
+GL_USER - define default gitlab-runner username ('gitlab-runner' by default)
+GL_SSH_KEY - ssh pubkey added to authorized_keys of GL_USER
+
+NOTE: this feature depends on network enablement in hasher (see [2] for details)
+
+1. https://docs.gitlab.com/runner/install/linux-manually.html
+2. https://bugzilla.altlinux.org/34596
diff --git a/features.in/gitlab-runner/config.mk b/features.in/gitlab-runner/config.mk
new file mode 100644
index 00000000..3bb3e719
--- /dev/null
+++ b/features.in/gitlab-runner/config.mk
@@ -0,0 +1,13 @@
+# WARNING: the variable values are stored in build config/log!
+use/gitlab-runner:
+	@$(call add_feature)
+	@$(call add,THE_PACKAGES,shadow-utils passwd curl)
+	@$(call xport,GL_USER)
+	@$(call xport,GL_SSH_KEY)
+
+# some presets
+# USERS variable chunk format is "login:passwd:admin:sudo"
+# GROUPS are just stashed there to include USERS logins created
+# GL_SSH_KEY should be changed accordingly
+use/gitlab-runner/defuser: use/gitlab-runner
+	@$(call add,GL_USER,gitlab-runner)
diff --git a/features.in/gitlab-runner/rootfs/image-scripts.d/60-gitlab-install b/features.in/gitlab-runner/rootfs/image-scripts.d/60-gitlab-install
new file mode 100755
index 00000000..259c6d97
--- /dev/null
+++ b/features.in/gitlab-runner/rootfs/image-scripts.d/60-gitlab-install
@@ -0,0 +1,61 @@
+#!/bin/sh -efu
+
+gl_url="https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-"
+
+add_user() {
+	useradd -c 'Gitlab Runner' -m "$1"
+	[ -z "$GLOBAL_GL_SSH_KEY" ] || echo "$GLOBAL_GL_SSH_KEY" >> /home/"$1"/.ssh/authorized_keys
+	usermod -L "$1" ||
+	echo "*** failed to add user '$1'"
+}
+
+
+case "$GLOBAL_ARCH" in
+	x86_64)
+		gl_url="${gl_url}amd64"
+	;;
+	i586)
+		gl_url="${gl_url}386"
+	;;
+	armh)
+		gl_url="${gl_url}arm"
+	;;
+	aarch64)
+		gl_url="${gl_url}arm64"
+	;;
+	ppc64le)
+		gl_url="${gl_url}ppc64le"
+	;;
+	*)
+		echo "arch $GLOBAL_ARCH not supported!"
+		exit 1
+	;;
+esac
+
+if [ -n "$GLOBAL_GL_USER" ]; then
+	add_user "$GLOBAL_GL_USER"
+	echo 'nameserver 8.8.8.8' >> /etc/resolv.conf
+	curl -L --output /usr/local/bin/gitlab-runner "$gl_url"
+	chmod +x /usr/local/bin/gitlab-runner
+	cat > /lib/systemd/system/gitlab-runner.service << EOF
+[Unit]
+Description=GitLab Runner
+ConditionFileIsExecutable=/usr/local/bin/gitlab-runner
+
+After=syslog.target network.target
+
+[Service]
+StartLimitInterval=5
+StartLimitBurst=10
+ExecStart=/usr/bin/gitlab-runner "run" "--working-directory" "/home/$GLOBAL_GL_USER" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--user" "$GLOBAL_GL_USER"
+
+Restart=always
+
+RestartSec=120
+EnvironmentFile=-/etc/sysconfig/gitlab-runner
+
+[Install]
+WantedBy=multi-user.target
+EOF
+    systemctl enable gitlab-runner
+fi
-- 
2.33.0


[-- Attachment #3: 0094-use-gitlab-runner-update-README.patch --]
[-- Type: text/x-patch, Size: 1064 bytes --]

>From 0932e5b015e76185dcde52dd31ee788ee4e24f13 Mon Sep 17 00:00:00 2001
From: "Konstantin A. Lepikhov" <lakostis@altlinux.ru>
Date: Sat, 4 Dec 2021 22:01:28 +0100
Subject: [PATCH 94/94] use/gitlab-runner: update README

- added notes about mkimage network options.
---
 features.in/gitlab-runner/README | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/features.in/gitlab-runner/README b/features.in/gitlab-runner/README
index 2e09e84b..0555b043 100644
--- a/features.in/gitlab-runner/README
+++ b/features.in/gitlab-runner/README
@@ -6,6 +6,8 @@ GL_USER - define default gitlab-runner username ('gitlab-runner' by default)
 GL_SSH_KEY - ssh pubkey added to authorized_keys of GL_USER
 
 NOTE: this feature depends on network enablement in hasher (see [2] for details)
+      and mkimage [3]
 
 1. https://docs.gitlab.com/runner/install/linux-manually.html
 2. https://bugzilla.altlinux.org/34596
+3. https://git.altlinux.org/people/legion/packages/mkimage.git?p=mkimage.git;a=commitdiff;h=6e90f032f15f89de1c2c523a725e369ab6cad1a0
-- 
2.33.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [devel-distro] feature/gitlab-runner
  2021-12-04 21:12 [devel-distro] feature/gitlab-runner Konstantin Lepikhov
@ 2021-12-06  6:50 ` Антон Мидюков
  0 siblings, 0 replies; 2+ messages in thread
From: Антон Мидюков @ 2021-12-06  6:50 UTC (permalink / raw)
  To: devel-distro

05.12.2021 04:12, Konstantin Lepikhov пишет:
> Привет!
> 
> Сделал feature для добавления gitlab-runner. Пакет было собирать влом,
> поэтому обошелся доп. функционалом в mkimage и hasher.
> 
> Как конфигурировать потом этот gitlab-runner зависит от задачи, поэтому
> оставляю простор для творчества.
> 

Патчи принял. Может кому-то пригодятся.

-- 
С уважением, Антон Мидюков <antohami@altlinux.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-06  6:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-04 21:12 [devel-distro] feature/gitlab-runner Konstantin Lepikhov
2021-12-06  6:50 ` Антон Мидюков

ALT Linux Distributions development

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel-distro/0 devel-distro/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel-distro devel-distro/ http://lore.altlinux.org/devel-distro \
		devel-distro@lists.altlinux.org devel-distro@lists.altlinux.ru devel-distro@lists.altlinux.com
	public-inbox-index devel-distro

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel-distro


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git