Adding older roles for geomyidae, git and stagit for archiving. - ansible-roles - A collection of ansible roles I have created over the years.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit b0b4e9c35e75f3695813e157d90e0f536929b04b
(DIR) parent ef67642333897c1cd2cabd724a90f2d6ae7e7a94
(HTM) Author: Jay Scott <me@jay.scot>
Date: Thu, 24 Aug 2023 11:40:53 +0100
Adding older roles for geomyidae, git and stagit for archiving.
Diffstat:
A geomyidae/handlers/main.yml | 12 ++++++++++++
A geomyidae/tasks/main.yml | 58 ++++++++++++++++++++++++++++++
A geomyidae/templates/geomyidae.serv… | 16 ++++++++++++++++
A geomyidae/vars/Debian.yml | 4 ++++
A geomyidae/vars/main.yml | 5 +++++
A git/handlers/main.yml | 6 ++++++
A git/tasks/main.yml | 31 +++++++++++++++++++++++++++++++
A git/templates/git-daemon.service.j2 | 18 ++++++++++++++++++
A git/vars/Debian.yml | 2 ++
A stagit/handlers/main.yml | 5 +++++
A stagit/tasks/main.yml | 46 +++++++++++++++++++++++++++++++
A stagit/templates/stagit_create.sh.… | 38 +++++++++++++++++++++++++++++++
A stagit/vars/Debian.yml | 4 ++++
A stagit/vars/main.yml | 5 +++++
14 files changed, 250 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/geomyidae/handlers/main.yml b/geomyidae/handlers/main.yml
@@ -0,0 +1,12 @@
+---
+- name: Restart geomyidae
+ ansible.builtin.systemd:
+ name: geomyidae
+ state: started
+ enabled: true
+ daemon_reload: true
+
+- name: Install geomyidae
+ community.general.system.make:
+ chdir: "{{ build_path }}"
+ target: install
(DIR) diff --git a/geomyidae/tasks/main.yml b/geomyidae/tasks/main.yml
@@ -0,0 +1,58 @@
+---
+- name: Include OS-specific variables.
+ ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
+
+- name: Install required packages
+ ansible.builtin.package:
+ name: "{{ common_packages }}"
+ state: present
+
+- name: Git checkout
+ ansible.builtin.git:
+ repo: "{{ source_repo }}"
+ dest: "{{ build_path }}"
+ force: false
+ version: "{{ geomyidae.git_branch }}"
+ register: repo_clone
+ failed_when:
+ - repo_clone.failed
+ - not 'Local modifications exist in the destination' in repo_clone.msg
+
+- name: Disable TLS options
+ ansible.builtin.replace:
+ path: "{{ build_path }}/Makefile"
+ regexp: '^TLS_CFLAGS = -DENABLE_TLS'
+ replace: '#TLS_CFLAGS = -DENABLE_TLS'
+ when: disable_tls
+
+- name: Disable TLS flags
+ ansible.builtin.replace:
+ path: "{{ build_path }}/Makefile"
+ regexp: '^TLS_LDFLAGS = -ltls'
+ replace: '#TLS_LDFLAGS = -ltls'
+ when: disable_tls
+
+- name: Build geomyidae
+ community.general.system.make:
+ chdir: "{{ build_path }}"
+ notify: Install geomyidae
+
+- name: Flush handlers
+ ansible.builtin.meta: flush_handlers
+
+- name: Create root directory
+ ansible.builtin.file:
+ path: "{{ geomyidae.root_path }}"
+ owner: "{{ geomyidae.user }}"
+ group: "{{ geomyidae.group }}"
+ mode: 0755
+ state: directory
+
+- name: Create systemd service file
+ ansible.builtin.template:
+ src: templates/geomyidae.service.j2
+ dest: /lib/systemd/system/geomyidae.service
+ owner: root
+ group: root
+ mode: '0644'
+ notify: Restart geomyidae
(DIR) diff --git a/geomyidae/templates/geomyidae.service.j2 b/geomyidae/templates/geomyidae.service.j2
@@ -0,0 +1,16 @@
+[Unit]
+Description=Geomyidae Gopher Server
+After=network.target
+Wants=network.target
+StartLimitBurst=5
+StartLimitIntervalSec=1
+
+[Service]
+Type=forking
+Restart=on-abnormal
+RestartSec=1
+User=root
+ExecStart=/usr/local/bin/geomyidae -v 0 -b {{ geomyidae.root_path }} -p 70 -n -u {{ geomyidae.user }} -g {{ geomyidae.group }}
+
+[Install]
+WantedBy=multi-user.target
(DIR) diff --git a/geomyidae/vars/Debian.yml b/geomyidae/vars/Debian.yml
@@ -0,0 +1,4 @@
+common_packages:
+ - git
+ - build-essential
+ - libssl-dev
(DIR) diff --git a/geomyidae/vars/main.yml b/geomyidae/vars/main.yml
@@ -0,0 +1,5 @@
+---
+
+build_path: /tmp/src/geomyidae
+source_repo: git://r-36.net/geomyidae
+disable_tls: true
(DIR) diff --git a/git/handlers/main.yml b/git/handlers/main.yml
@@ -0,0 +1,6 @@
+---
+- name: Restart git-daemon
+ ansible.builtin.systemd:
+ name: git-daemon
+ state: started
+ daemon_reload: true
(DIR) diff --git a/git/tasks/main.yml b/git/tasks/main.yml
@@ -0,0 +1,31 @@
+---
+- name: Include OS-specific variables
+ ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
+
+- name: Install required packages
+ ansible.builtin.package:
+ name: "{{ common_packages }}"
+ state: present
+
+- name: Added git service account
+ ansible.builtin.user:
+ name: "{{ git.user }}"
+ comment: "Git Service Account"
+ home: "{{ git.base_path }}"
+ shell: /usr/bin/git-shell
+ group: "{{ git.group }}"
+
+- name: Set initial authorized key
+ ansible.posix.authorized_key:
+ user: git
+ state: present
+ key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
+
+- name: Create systemd service file
+ ansible.builtin.template:
+ src: templates/git-daemon.service.j2
+ dest: /lib/systemd/system/git-daemon.service
+ owner: root
+ group: root
+ mode: "0644"
+ notify: Restart git-daemon
(DIR) diff --git a/git/templates/git-daemon.service.j2 b/git/templates/git-daemon.service.j2
@@ -0,0 +1,18 @@
+[Unit]
+Description=Start Git Daemon
+
+[Service]
+ExecStart=/usr/bin/git daemon --reuseaddr --base-path={{ git.base_path }} {{ git.base_path }}
+
+Restart=always
+RestartSec=500ms
+
+StandardOutput=syslog
+StandardError=syslog
+SyslogIdentifier=git-daemon
+
+User={{ git.user }}
+Group={{ git.group }}
+
+[Install]
+WantedBy=multi-user.target
(DIR) diff --git a/git/vars/Debian.yml b/git/vars/Debian.yml
@@ -0,0 +1,2 @@
+common_packages:
+ - git
(DIR) diff --git a/stagit/handlers/main.yml b/stagit/handlers/main.yml
@@ -0,0 +1,5 @@
+---
+- name: Install stagit
+ community.general.system.make:
+ chdir: "{{ build_path }}"
+ target: install
(DIR) diff --git a/stagit/tasks/main.yml b/stagit/tasks/main.yml
@@ -0,0 +1,46 @@
+---
+- name: Include OS-specific variables.
+ ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
+
+- name: Install required packages
+ ansible.builtin.package:
+ name: "{{ common_packages }}"
+ state: present
+
+- name: Git checkout
+ ansible.builtin.git:
+ repo: "{{ source_repo }}"
+ dest: "{{ build_path }}"
+ force: false
+ version: "{{ stagit_gopher.git_branch }}"
+ register: repo_clone
+ failed_when:
+ - repo_clone.failed
+ - not 'Local modifications exist in the destination' in repo_clone.msg
+
+- name: Enable old libgit2 workaround
+ ansible.builtin.replace:
+ path: "{{ build_path }}/Makefile"
+ regexp: '^#STAGIT_CFLAGS'
+ replace: 'STAGIT_CFLAGS'
+ when: enable_old_libgit2
+
+- name: Build from source
+ community.general.system.make:
+ chdir: "{{ build_path }}"
+ notify: Install stagit
+
+- name: Create stagit run script
+ ansible.builtin.template:
+ src: templates/stagit_create.sh.j2
+ dest: "/home/{{ stagit_gopher.cron_user }}/stagit_create.sh"
+ owner: "{{ stagit_gopher.cron_user }}"
+ group: "{{ stagit_gopher.cron_group }}"
+ mode: "755"
+
+- name: Adding script to cron
+ ansible.builtin.cron:
+ name: "run stagit script"
+ user: "{{ stagit_gopher.cron_user }}"
+ minute: "0"
+ job: "/home/{{ stagit_gopher.cron_user }}/stagit_create.sh"
(DIR) diff --git a/stagit/templates/stagit_create.sh.j2 b/stagit/templates/stagit_create.sh.j2
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+reposdir="{{ stagit_gopher.repo_path }}"
+gopherdir="{{ stagit_gopher.output_path }}"
+stagitdir="/git"
+destdir="${gopherdir}/${stagitdir}"
+
+# remove /'s at the end.
+stagitdir=$(printf "%s" "${stagitdir}" | sed 's@[/]*$@@g')
+
+rm -rf "{{ stagit_gopher.output_path }}/git/*"
+
+/usr/local/bin/stagit-gopher-index -b "${stagitdir}" "${reposdir}/"*.git/ >"${destdir}/index.gph"
+
+# make files per repo.
+for dir in "${reposdir}/"*/; do
+ # strip .git suffix.
+ r=$(basename "${dir}")
+ d=$(basename "${dir}" ".git")
+ printf "%s... " "${d}"
+
+ mkdir -p "${destdir}/${d}"
+ cd "${destdir}/${d}" || continue
+
+ if [ "$d" != "pass" ]; then
+ /usr/local/bin/stagit-gopher -b "${stagitdir}/${d}" \
+ -u "gopher://jay.scot/1/git/$d/" "${reposdir}/${r}"
+
+ # symlinks
+ ln -sf log.gph index.gph
+
+ echo "done"
+ else
+ echo "skipping"
+ fi
+done
+
+
(DIR) diff --git a/stagit/vars/Debian.yml b/stagit/vars/Debian.yml
@@ -0,0 +1,4 @@
+common_packages:
+ - git
+ - build-essential
+ - libgit2-dev
(DIR) diff --git a/stagit/vars/main.yml b/stagit/vars/main.yml
@@ -0,0 +1,5 @@
+---
+
+build_path: /tmp/src/stagit-gopher
+source_repo: git://git.codemadness.org/stagit-gopher
+enable_old_libgit2: true