diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-07 21:06:35 -0700 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-11 18:36:50 -0700 |
| commit | f60e2a723c744628823cad6344a8d3d0dd4c32e4 (patch) | |
| tree | 02201b37edbe05070aac9c5f2c2335dbe25c22bc | |
| parent | Retab file (diff) | |
| download | site-configs-f60e2a723c744628823cad6344a8d3d0dd4c32e4.zip | |
Update configs
| -rw-r--r-- | .nvim.lua | 7 | ||||
| -rw-r--r-- | roles/acme_client/handlers/main.yml | 6 | ||||
| -rw-r--r-- | roles/acme_client/tasks/main.yml | 13 | ||||
| -rw-r--r-- | roles/acme_client/templates/httpd.d/acme.conf (renamed from roles/acme_client/files/httpd.d/acme.conf) | 0 | ||||
| -rw-r--r-- | roles/obsd_cgit/defaults/main.yml | 4 | ||||
| -rw-r--r-- | roles/obsd_cgit/tasks/main.yml | 6 | ||||
| -rw-r--r-- | roles/obsd_cgit/tasks/markdown.yml (renamed from roles/obsd_cgit/tasks/lowdown.yml) | 13 | ||||
| -rw-r--r-- | roles/obsd_cgit/templates/cgitrc.j2 | 5 | ||||
| -rw-r--r-- | roles/obsd_git/defaults/main.yml | 2 | ||||
| -rw-r--r-- | roles/obsd_git/files/git-shell-commands/create | 27 | ||||
| -rw-r--r-- | roles/obsd_git/handlers/main.yml | 2 | ||||
| -rw-r--r-- | roles/obsd_git/tasks/main.yml | 3 | ||||
| -rw-r--r-- | roles/obsd_git/templates/git-shell-commands/create | 71 | ||||
| -rw-r--r-- | roles/obsd_git/templates/git-shell-commands/no-interactive-login | 10 | ||||
| -rw-r--r-- | roles/obsd_httpd/handlers/main.yml | 2 | ||||
| -rw-r--r-- | roles/obsd_httpd/tasks/main.yml | 27 |
16 files changed, 116 insertions, 82 deletions
diff --git a/.nvim.lua b/.nvim.lua new file mode 100644 index 0000000..0fec175 --- /dev/null +++ b/.nvim.lua @@ -0,0 +1,7 @@ +local root = vim.pesc(vim.fn.getcwd()) + +vim.filetype.add({ + pattern = { + [root .. "/.*%.ya?ml"] = "yaml.ansible", + }, +}) diff --git a/roles/acme_client/handlers/main.yml b/roles/acme_client/handlers/main.yml deleted file mode 100644 index ca566a6..0000000 --- a/roles/acme_client/handlers/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -- name: run acme-client - ansible.builtin.command: acme-client {{ acme_domain }} - changed_when: true - -- name: restart httpd - ansible.builtin.command: rcctl restart httpd diff --git a/roles/acme_client/tasks/main.yml b/roles/acme_client/tasks/main.yml index 54cd70c..35974e0 100644 --- a/roles/acme_client/tasks/main.yml +++ b/roles/acme_client/tasks/main.yml @@ -1,11 +1,11 @@ - name: Deploy acme challenge vhost fragment - ansible.builtin.copy: + ansible.builtin.template: src: httpd.d/acme.conf dest: "{{ httpd_conf_d | default('/etc/httpd.d') }}/acme.conf" owner: root group: wheel mode: "0644" - notify: restart httpd + register: acme_vhost_config - name: Deploy acme-client.conf ansible.builtin.template: @@ -15,10 +15,13 @@ group: wheel mode: "0600" -- name: Flush handlers so httpd restarts before issuing cert - ansible.builtin.meta: flush_handlers +- name: Restart httpd + ansible.builtin.service: + name: httpd + state: restarted + when: acme_vhost_config is changed -- name: Ensure certificates exist +- name: Generate certificate ansible.builtin.command: acme-client {{ acme_domain }} args: creates: "/etc/ssl/{{ acme_domain }}.fullchain.pem" diff --git a/roles/acme_client/files/httpd.d/acme.conf b/roles/acme_client/templates/httpd.d/acme.conf index 558a8bd..558a8bd 100644 --- a/roles/acme_client/files/httpd.d/acme.conf +++ b/roles/acme_client/templates/httpd.d/acme.conf diff --git a/roles/obsd_cgit/defaults/main.yml b/roles/obsd_cgit/defaults/main.yml index 655724a..eb983fa 100644 --- a/roles/obsd_cgit/defaults/main.yml +++ b/roles/obsd_cgit/defaults/main.yml @@ -1,4 +1,4 @@ cgit_domain: "{{ cgit_domain }}" -cgit_cache_dir: /var/www/cgit/cache # Absolute path from /var/www chroot that httpd runs in -cgit_repos_dir: /pub/git +cgit_cache_dir: /cgit/cache +cgit_repos_dir: /git/public diff --git a/roles/obsd_cgit/tasks/main.yml b/roles/obsd_cgit/tasks/main.yml index 3971803..6530b18 100644 --- a/roles/obsd_cgit/tasks/main.yml +++ b/roles/obsd_cgit/tasks/main.yml @@ -14,14 +14,14 @@ - name: Create cgit cache directory ansible.builtin.file: - path: "{{ cgit_cache_dir }}" + path: "/var/www{{ cgit_cache_dir }}" state: directory owner: www group: daemon mode: "0755" -- name: Set up lowdown markdown renderer in chroot - ansible.builtin.include_tasks: lowdown.yml +- name: Compile markdown renderer into chroot + ansible.builtin.include_tasks: markdown.yml - name: Copy extra html head file into chroot ansible.builtin.copy: diff --git a/roles/obsd_cgit/tasks/lowdown.yml b/roles/obsd_cgit/tasks/markdown.yml index 9d6b466..c4cc6b9 100644 --- a/roles/obsd_cgit/tasks/lowdown.yml +++ b/roles/obsd_cgit/tasks/markdown.yml @@ -3,7 +3,7 @@ name: lowdown state: present -- name: Copy lowdown binary into chroot +- name: Copy convert-markdown.c into /tmp ansible.builtin.copy: src: convert-markdown.c dest: /tmp/ @@ -11,7 +11,7 @@ group: wheel mode: "0755" -- name: Ensure chroot bin directory exists +- name: Ensure /var/www/bin directory exists ansible.builtin.file: path: "/var/www/bin" state: directory @@ -28,14 +28,13 @@ -llowdown \ -lm \ -static \ - -pie + -pie \ + -s args: chdir: /tmp + creates: /var/www/bin/convert-markdown -- name: Strip /var/www/bin/convert-markdown - ansible.builtin.command: strip /var/www/bin/convert-markdown - -- name: Update ownership +- name: Ensure root:daemon owns convert-markdown binary ansible.builtin.file: path: /var/www/bin/convert-markdown owner: root diff --git a/roles/obsd_cgit/templates/cgitrc.j2 b/roles/obsd_cgit/templates/cgitrc.j2 index c8eb111..9fd96de 100644 --- a/roles/obsd_cgit/templates/cgitrc.j2 +++ b/roles/obsd_cgit/templates/cgitrc.j2 @@ -25,6 +25,7 @@ readme=:README.md css=/cgit.css logo=/cgit.png virtual-root=/ -scan-path=/pub/git -cache-root=/var/www/cgit/cache +scan-path={{ cgit_repos_dir }} +section-from-path=1 +cache-root={{ cgit_cache_dir }} cache-size=1000 diff --git a/roles/obsd_git/defaults/main.yml b/roles/obsd_git/defaults/main.yml index 19018f2..d0ca79a 100644 --- a/roles/obsd_git/defaults/main.yml +++ b/roles/obsd_git/defaults/main.yml @@ -1,4 +1,4 @@ git_user: git -git_home: /var/www/pub/git +git_home: /var/www/git git_packages: - git diff --git a/roles/obsd_git/files/git-shell-commands/create b/roles/obsd_git/files/git-shell-commands/create deleted file mode 100644 index db38900..0000000 --- a/roles/obsd_git/files/git-shell-commands/create +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -set -e - -main() { - repo="$1" - desc="$2" - if [ -z "$repo" ]; then - echo "Usage: provide a repository name" >&2 - exit 1 - fi - - repo_name=$(basename "$repo" .git) - repo_path="/var/www/pub/git/$repo_name.git" - - if [ ! -d "$repo_path" ]; then - echo "Creating bare repository: $repo_name.git" - git init --bare --initial-branch=main "$repo_path" - chown -R git:git "$repo_path" - - if [ -n "$desc" ]; then - # cgit will lookup the git repository description via the git config. - git -C "$repo_path" config gitweb.description "$desc" - fi - fi -} - -main "$@" diff --git a/roles/obsd_git/handlers/main.yml b/roles/obsd_git/handlers/main.yml deleted file mode 100644 index 3af955f..0000000 --- a/roles/obsd_git/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -- name: restart httpd - ansible.builtin.command: rcctl restart httpd diff --git a/roles/obsd_git/tasks/main.yml b/roles/obsd_git/tasks/main.yml index a5d9e69..aeb3bb7 100644 --- a/roles/obsd_git/tasks/main.yml +++ b/roles/obsd_git/tasks/main.yml @@ -7,6 +7,7 @@ ansible.builtin.user: name: "{{ git_user }}" home: "{{ git_home }}" + create_home: false shell: /usr/local/bin/git-shell system: true @@ -51,7 +52,7 @@ mode: "0755" - name: Deploy git-shell create-repo helper script - ansible.builtin.copy: + ansible.builtin.template: src: git-shell-commands/create dest: "{{ git_home }}/git-shell-commands/create" owner: "{{ git_user }}" diff --git a/roles/obsd_git/templates/git-shell-commands/create b/roles/obsd_git/templates/git-shell-commands/create new file mode 100644 index 0000000..9ac25a5 --- /dev/null +++ b/roles/obsd_git/templates/git-shell-commands/create @@ -0,0 +1,71 @@ +#!/bin/sh +set -e + +REPO="" +DESC="" +PROJ="" +VISIBILITY="public" + +main() { + parse_args "$@" + + repo_name=$(basename "$REPO" .git) + if [ -n "$PROJ" ]; then + proj_dir="{{ git_home }}/$VISIBILITY/$PROJ" + if [ ! -d "$proj_dir" ]; then + mkdir "$proj_dir" + fi + repo_path="$proj_dir/$repo_name.git" + else + repo_path="{{ git_home }}/$VISIBILITY/$repo_name.git" + fi + + if [ ! -d "$repo_path" ]; then + echo "Creating bare repository: $repo_name.git" + git init --bare --initial-branch=main "$repo_path" + chown -R git:git "$repo_path" + if [ -n "$DESC" ]; then + echo "$DESC" >>"$repo_path/description" + fi + fi +} + +parse_args() { + while [ $# -gt 0 ]; do + case "$1" in + --visibility) + VISIBILITY="$2" + case "$VISIBILITY" in public | private) ;; *) usage ;; esac + shift 2 + ;; + --description) + DESC="$2" + shift 2 + ;; + --project) + PROJ="$2" + shift 2 + ;; + -*) + echo "Unknown option: $1" >&2 + exit 1 + ;; + *) + if [ -n "$REPO" ]; then + echo "Unexpected argument: $1" >&2 + usage + fi + REPO="$1" + shift + ;; + esac + done + [ -n "$REPO" ] || usage +} + +usage() { + echo "Usage: $0 [--visibility public|private] [--description DESC] [--project PROJ] <repo>" >&2 + exit 1 +} + +main "$@" diff --git a/roles/obsd_git/templates/git-shell-commands/no-interactive-login b/roles/obsd_git/templates/git-shell-commands/no-interactive-login new file mode 100644 index 0000000..7c774ca --- /dev/null +++ b/roles/obsd_git/templates/git-shell-commands/no-interactive-login @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +main() { + printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not" + printf '%s\n' "provide interactive shell access." + exit 128 +} + +main "$@" diff --git a/roles/obsd_httpd/handlers/main.yml b/roles/obsd_httpd/handlers/main.yml deleted file mode 100644 index 3af955f..0000000 --- a/roles/obsd_httpd/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -- name: restart httpd - ansible.builtin.command: rcctl restart httpd diff --git a/roles/obsd_httpd/tasks/main.yml b/roles/obsd_httpd/tasks/main.yml index 36ff9fb..6e21ab8 100644 --- a/roles/obsd_httpd/tasks/main.yml +++ b/roles/obsd_httpd/tasks/main.yml @@ -16,8 +16,6 @@ notify: restart httpd - name: Ensure all registered httpd fragment files exist - # If they don't exist, httpd validate will fail. So we want to create them, - # even if empty for now. ansible.builtin.copy: content: "" dest: "{{ httpd_conf_d }}/{{ item }}" @@ -27,29 +25,10 @@ mode: "0644" loop: "{{ httpd_fragments }}" -- name: Validate httpd config - ansible.builtin.command: httpd -n - changed_when: false - - name: Enable httpd and slowcgi - ansible.builtin.command: "rcctl enable {{ item }}" - args: - creates: "/etc/rc.conf.d/{{ item }}" - loop: - - httpd - - slowcgi - changed_when: true - -- name: Check service status - ansible.builtin.command: rcctl check {{ item }} - register: httpd_check - changed_when: false - failed_when: false # rc 1 exit code means "not running" + ansible.builtin.service: + name: "{{ item }}" + enabled: true loop: - httpd - slowcgi - -- name: Start services that are not running - ansible.builtin.command: rcctl start {{ item.item }} - loop: "{{ httpd_check.results }}" - when: item.rc != 0 |