]> git.ekhem.eu.org Git - metadata.git/commitdiff
[metrics] Configure automatic deployment, describe the repository and make it public.
authorJakub Czajka <jakub@ekhem.eu.org>
Tue, 2 Jan 2024 12:02:30 +0000 (13:02 +0100)
committerJakub Czajka <jakub@ekhem.eu.org>
Tue, 2 Jan 2024 12:02:30 +0000 (13:02 +0100)
COPYING
metrics.git/deploy.yaml [new file with mode: 0644]
metrics.git/description [new file with mode: 0644]
metrics.git/git-daemon-export-ok [new file with mode: 0644]
metrics.git/hooks/post-receive [new file with mode: 0755]

diff --git a/COPYING b/COPYING
index 123b02962ae1d8d5ea502c771ba206daa0671a0d..2092834fbf50382fd643ce2bda807db84397815a 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
 state the exclusion of warranty; and each file should have at least
 the "copyright" line and a pointer to where the full notice is found.
 
-    Copyright (C) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+    Copyright (C) 2023-2024 Jakub Czajka <jakub@ekhem.eu.org>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -651,7 +651,7 @@ Also add information on how to contact you by electronic and paper mail.
   If the program does terminal interaction, make it output a short
 notice like this when it starts in an interactive mode:
 
-    metadata Copyright (C) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+    metadata Copyright (C) 2023-2024 Jakub Czajka <jakub@ekhem.eu.org>
     This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
     This is free software, and you are welcome to redistribute it
     under certain conditions; type `show c' for details.
diff --git a/metrics.git/deploy.yaml b/metrics.git/deploy.yaml
new file mode 100644 (file)
index 0000000..082ffbb
--- /dev/null
@@ -0,0 +1,59 @@
+# Copyright (c) 2024 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+- hosts: servers
+  vars:
+    dest: "{{ ansible_local.env.vars.prod_dir }}/metrics"
+    repo: "{{ ansible_local.env.vars.git_home_dir }}/metrics.git"
+    site: metrics.conf
+  tasks:
+    - name: Create destination directory
+      file:
+        path: "{{ dest }}"
+        state: directory
+        mode: 0775
+        owner: git
+        group: www-data
+      become: true
+    - name: Checkout scripts to the destination directory
+      command: git --work-tree={{ dest }} --git-dir={{ repo }} checkout main \
+        --force *.sh
+      become: true
+    - find:
+        paths: "{{ dest }}"
+        file_type: file
+        patterns: "*.sh"
+      register: scripts
+    - name: Make metrics scripts executable
+      file:
+        path: "{{ item.path }}"
+        mode: 0744
+        owner: www-data
+        group: www-data
+      become: true
+      with_items: "{{ scripts.files }}"
+
+    - name: Install fcgiwrap and nginx
+      package:
+        name:
+          - fcgiwrap
+          - nginx
+        state: latest
+      become: true
+    - name: Checkout site to /etc/nginx/sites-available
+      command: git --work-tree=/etc/nginx/sites-available --git-dir={{ repo }} \
+        checkout main --force {{ site }}
+      become: true
+    - name: Enable site in nginx
+      shell: envsubst < /etc/nginx/sites-available/{{ site }} \
+        > /etc/nginx/sites-enabled/{{ site }}
+      environment: "{{ ansible_local.env.vars }}"
+      become: true
+    - name: Restart fcgiwrap and nginx
+      service:
+        name: "{{ item }}"
+        state: restarted
+      become: true
+      with_items:
+        - fcgiwrap
+        - nginx
diff --git a/metrics.git/description b/metrics.git/description
new file mode 100644 (file)
index 0000000..271b945
--- /dev/null
@@ -0,0 +1 @@
+HTTP interface for a database tracking different life metrics.
diff --git a/metrics.git/git-daemon-export-ok b/metrics.git/git-daemon-export-ok
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/metrics.git/hooks/post-receive b/metrics.git/hooks/post-receive
new file mode 100755 (executable)
index 0000000..4b8ca5e
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+# Copyright (c) 2024 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+while read old_revision new_revision branch
+do
+    if [ "${branch}" != "refs/heads/main" ]
+    then
+        echo "${branch} is not the main branch so not deploying."
+        exit 0
+    fi
+    sudo ansible-playbook --connection=local deploy.yaml
+done