From f671eda1a8c89910647b745de61cb07976dc1b4b Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Wed, 30 Sep 2026 17:12:13 +0100 Subject: scag update (now jamdog) --- inventory.yml | 2 +- playbook.yml | 2 +- roles/jamdog/tasks/main.yml | 123 ++++++++++++++++++++++++++++++++ roles/jamdog/templates/header.html | 10 +++ roles/jamdog/templates/jamdog.toml | 16 +++++ roles/jamdog/templates/nginx/feed.conf | 4 ++ roles/scag/tasks/main.yml | 125 --------------------------------- roles/scag/templates/header.html | 30 -------- roles/scag/templates/nginx/feed.conf | 4 -- roles/scag/templates/scag.toml | 16 ----- vars/feed.yml | 4 +- 11 files changed, 157 insertions(+), 179 deletions(-) create mode 100644 roles/jamdog/tasks/main.yml create mode 100644 roles/jamdog/templates/header.html create mode 100644 roles/jamdog/templates/jamdog.toml create mode 100644 roles/jamdog/templates/nginx/feed.conf delete mode 100644 roles/scag/tasks/main.yml delete mode 100644 roles/scag/templates/header.html delete mode 100644 roles/scag/templates/nginx/feed.conf delete mode 100644 roles/scag/templates/scag.toml diff --git a/inventory.yml b/inventory.yml index ec3157a..08ea31d 100644 --- a/inventory.yml +++ b/inventory.yml @@ -14,7 +14,7 @@ ungrouped: connection_name: nevis connection_device_name: eth0 rust_target: armv7-unknown-linux-musleabihf - scag_install_method: precompile + jamdog_install_method: precompile blade-canongate: ansible_host: 192.168.178.75 ansible_ssh_user: canongate diff --git a/playbook.yml b/playbook.yml index b052996..69298fa 100644 --- a/playbook.yml +++ b/playbook.yml @@ -18,7 +18,7 @@ roles: - nginx - http - - rss-aggregator + - jamdog vars_files: - common.yml - email.yml diff --git a/roles/jamdog/tasks/main.yml b/roles/jamdog/tasks/main.yml new file mode 100644 index 0000000..81626e0 --- /dev/null +++ b/roles/jamdog/tasks/main.yml @@ -0,0 +1,123 @@ +- name: Install jamdog by pre-compiling the binary + when: ( not ( jamdog_install_method is defined ) ) or jamdog_install_method == "precompile" + block: + - name: Fetch jamdog source code + delegate_to: 127.0.0.1 + become: false + ansible.builtin.git: + repo: https://git.joeac.net/jamdog.git + dest: /tmp/jamdog + depth: 1 + - name: Cross-compile jamdog + delegate_to: 127.0.0.1 + become: false + ansible.builtin.shell: + cmd: cross build --release --target {{ rust_target }} + chdir: /tmp/jamdog + changed_when: "'Compiling' in _task.result.stderr" + - name: Install jamdog binary + ansible.builtin.copy: + src: /tmp/jamdog/target/{{ rust_target }}/release/jamdog + dest: /usr/bin/jamdog + mode: +x + +- name: Install or update jamdog using rustup + when: jamdog_install_method == "rustup" + block: + - name: Install Rust toolchain using installation script + ansible.builtin.shell: + cmd: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + creates: /usr/bin/rustc + - name: Update Rust toolchain with rustup + ansible.builtin.shell: rustup update + changed_when: "'updated' in _task.result.stdout" + - name: Install or update jamdog using cargo + ansible.builtin.shell: + cmd: cargo install --git git://git.joeac.net/jamdog.git + changed_when: "'Installed' in _task.result.stdout or 'Replaced' in _task.result.stdout" + - name: Install daily crontab to update jamdog using cargo + ansible.builtin.cron: + special_time: daily + name: Update jamdog + job: cargo install --git git://git.joeac.net/jamdog.git + +- name: Install jamdog using cargo provided by APK + when: jamdog_install_method == "cargo" + block: + - name: Install cargo using APK + community.general.apk: + name: cargo + - name: Install or update jamdog using cargo + ansible.builtin.shell: + cmd: cargo install --git git://git.joeac.net/jamdog.git + changed_when: "'Installed' in _task.result.stdout or 'Replaced' in _task.result.stdout" + - name: Install daily crontab to update jamdog using cargo + ansible.builtin.cron: + special_time: daily + name: Update jamdog + job: cargo install --git git://git.joeac.net/jamdog.git + +- name: Create jamdog configuration directory + ansible.builtin.file: + path: /etc/jamdog + state: directory + +- name: Configure jamdog + ansible.builtin.template: + src: jamdog.toml + dest: /etc/jamdog/config.toml + +- name: Configure HTML feed head + ansible.builtin.shell: + cmd: | + curl --silent https://git.joeac.net/joeac.net.git/plain/http/share/components/head.upphtml \ + | grep -E ^\ {{ feed_html_head }} + creates: "{{ feed_html_head }}" + +- name: Configure HTML feed header + ansible.builtin.template: + src: header.html + dest: "{{ feed_html_header }}" + +- name: Fetch subscriptions + ansible.builtin.git: + repo: git://git.joeac.net/subscriptions.git + dest: "{{ src_dir }}/subscriptions" + depth: 1 + +- name: Symlink subscriptions into jamdog configuration directory + ansible.builtin.file: + src: "{{ src_dir }}/subscriptions/subscriptions.txt" + dest: /etc/jamdog/subscriptions.txt + state: link + +- name: Create directory for RSS file + ansible.builtin.file: + path: "{{ http_files_dir }}/feed/{{ feed_dir }}" + state: directory + owner: nginx + group: nginx + +- name: Use jamdog to generate RSS file + ansible.builtin.shell: + cmd: jamdog + creates: "{{ http_files_dir }}/feed/{{ feed_rss_path }}" + +- name: Install nginx location config + register: nginx_conf + ansible.builtin.template: + src: nginx/feed.conf + dest: /etc/nginx/http.d/joeac.net.locations.d/feed.conf + +- name: Restart nginx + when: nginx_conf is changed + ansible.builtin.service: + name: nginx + state: restarted + +- name: Install hourly crontab to update subscriptions and run jamdog + ansible.builtin.cron: + special_time: daily + name: Run jamdog + job: git -C "{{ src_dir }}/subscriptions" pull; jamdog diff --git a/roles/jamdog/templates/header.html b/roles/jamdog/templates/header.html new file mode 100644 index 0000000..1e6ee30 --- /dev/null +++ b/roles/jamdog/templates/header.html @@ -0,0 +1,10 @@ + diff --git a/roles/jamdog/templates/jamdog.toml b/roles/jamdog/templates/jamdog.toml new file mode 100644 index 0000000..9eafa6c --- /dev/null +++ b/roles/jamdog/templates/jamdog.toml @@ -0,0 +1,16 @@ +subscriptions_path = "subscriptions.txt" + +[feed] +title = "Stuff that Joe Carstairs wants to read" +description = "Stuff that Joe Carstairs wants to read" +url = "https://joeac.net/feed" + +[output] +outfile_rss = "{{ http_files_dir }}/feed/{{ feed_rss_path }}" +outfile_html = "{{ http_files_dir }}/feed/{{ feed_html_path }}" +produce_formats = ["html", "rss"] +max_age = 31 + +[output.html] +head = "{{ feed_html_head }}" +header = "{{ feed_html_header }}" diff --git a/roles/jamdog/templates/nginx/feed.conf b/roles/jamdog/templates/nginx/feed.conf new file mode 100644 index 0000000..6f650ba --- /dev/null +++ b/roles/jamdog/templates/nginx/feed.conf @@ -0,0 +1,4 @@ +location /feed { + root {{ http_files_dir }}/feed; + try_files $uri $uri.xml $uri.rss $uri.atom $uri.rss.xml $uri.html $uri/index.html $uri.php $uri/index.php =404; +} diff --git a/roles/scag/tasks/main.yml b/roles/scag/tasks/main.yml deleted file mode 100644 index ca26c3e..0000000 --- a/roles/scag/tasks/main.yml +++ /dev/null @@ -1,125 +0,0 @@ -- name: Install scag by pre-compiling the binary - when: ( not ( scag_install_method is defined ) ) or scag_install_method == "precompile" - block: - - name: Fetch scag source code - delegate_to: 127.0.0.1 - become: false - ansible.builtin.git: - repo: https://git.joeac.net/scag.git - dest: /tmp/scag - depth: 1 - - name: Cross-compile scag - delegate_to: 127.0.0.1 - become: false - ansible.builtin.shell: - cmd: cross build --release --target {{ rust_target }} - chdir: /tmp/scag - changed_when: "'Compiling' in _task.result.stderr" - - name: Install scag binary - ansible.builtin.copy: - src: /tmp/scag/target/{{ rust_target }}/release/scag - dest: /usr/bin/scag - mode: +x - -- name: Install or update scag using rustup - when: scag_install_method == "rustup" - block: - - name: Install Rust toolchain using installation script - ansible.builtin.shell: - cmd: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - creates: /usr/bin/rustc - - name: Update Rust toolchain with rustup - ansible.builtin.shell: rustup update - changed_when: "'updated' in _task.result.stdout" - - name: Install or update scag using cargo - ansible.builtin.shell: - cmd: cargo install --git git://git.joeac.net/scag.git - changed_when: "'Installed' in _task.result.stdout or 'Replaced' in _task.result.stdout" - - name: Install daily crontab to update scag using cargo - ansible.builtin.cron: - special_time: daily - name: Update scag - job: cargo install --git git://git.joeac.net/scag.git - -- name: Install scag using cargo provided by APK - when: scag_install_method == "cargo" - block: - - name: Install cargo using APK - community.general.apk: - name: cargo - - name: Install or update scag using cargo - ansible.builtin.shell: - cmd: cargo install --git git://git.joeac.net/scag.git - changed_when: "'Installed' in _task.result.stdout or 'Replaced' in _task.result.stdout" - - name: Install daily crontab to update scag using cargo - ansible.builtin.cron: - special_time: daily - name: Update scag - job: cargo install --git git://git.joeac.net/scag.git - -- name: Create scag configuration directory - ansible.builtin.file: - path: /etc/scag - state: directory - -- name: Configure scag - ansible.builtin.template: - src: scag.toml - dest: /etc/scag/config.toml - -- name: Configure HTML feed head - ansible.builtin.shell: - cmd: | - curl --silent https://git.joeac.net/joeac.net.git/plain/http/share/components/head.upphtml \ - | grep -E ^\ {{ feed_html_head }} - creates: "{{ feed_html_head }}" - -- name: Configure HTML feed header - ansible.builtin.template: - src: header.html - dest: "{{ feed_html_header }}" - -- name: Fetch subscriptions - ansible.builtin.git: - repo: git://git.joeac.net/subscriptions.git - dest: "{{ src_dir }}/subscriptions" - depth: 1 - -- name: Symlink subscriptions into scag configuration directory - ansible.builtin.file: - src: "{{ src_dir }}/subscriptions/subscriptions.txt" - dest: /etc/scag/subscriptions.txt - state: link - -- name: Create directory for RSS file - ansible.builtin.file: - path: "{{ http_files_dir }}/feed/{{ feed_dir }}" - state: directory - owner: nginx - group: nginx - -- name: Use scag to generate RSS file - ansible.builtin.shell: - cmd: scag - creates: "{{ http_files_dir }}/feed/{{ feed_rss_path }}" - -- name: Install nginx location config - register: nginx_conf - ansible.builtin.template: - src: nginx/feed.conf - dest: /etc/nginx/http.d/joeac.net.locations.d/feed.conf - -- name: Restart nginx - when: nginx_conf is changed - ansible.builtin.service: - name: nginx - state: restarted - -- name: Install hourly crontab to update subscriptions and run scag - ansible.builtin.cron: - special_time: daily - name: Run scag - job: >- - git -C "{{ src_dir }}/subscriptions" pull; - scag diff --git a/roles/scag/templates/header.html b/roles/scag/templates/header.html deleted file mode 100644 index 20ea0f1..0000000 --- a/roles/scag/templates/header.html +++ /dev/null @@ -1,30 +0,0 @@ - - - diff --git a/roles/scag/templates/nginx/feed.conf b/roles/scag/templates/nginx/feed.conf deleted file mode 100644 index 6f650ba..0000000 --- a/roles/scag/templates/nginx/feed.conf +++ /dev/null @@ -1,4 +0,0 @@ -location /feed { - root {{ http_files_dir }}/feed; - try_files $uri $uri.xml $uri.rss $uri.atom $uri.rss.xml $uri.html $uri/index.html $uri.php $uri/index.php =404; -} diff --git a/roles/scag/templates/scag.toml b/roles/scag/templates/scag.toml deleted file mode 100644 index 9eafa6c..0000000 --- a/roles/scag/templates/scag.toml +++ /dev/null @@ -1,16 +0,0 @@ -subscriptions_path = "subscriptions.txt" - -[feed] -title = "Stuff that Joe Carstairs wants to read" -description = "Stuff that Joe Carstairs wants to read" -url = "https://joeac.net/feed" - -[output] -outfile_rss = "{{ http_files_dir }}/feed/{{ feed_rss_path }}" -outfile_html = "{{ http_files_dir }}/feed/{{ feed_html_path }}" -produce_formats = ["html", "rss"] -max_age = 31 - -[output.html] -head = "{{ feed_html_head }}" -header = "{{ feed_html_header }}" diff --git a/vars/feed.yml b/vars/feed.yml index 14d27f2..5576d81 100644 --- a/vars/feed.yml +++ b/vars/feed.yml @@ -1,5 +1,5 @@ feed_dir: feed feed_html_path: "{{ feed_dir }}/index.html" feed_rss_path: "{{ feed_dir }}/rss.xml" -feed_html_head: /etc/scag/head.html -feed_html_header: /etc/scag/header.html +feed_html_head: /etc/jamdog/head.html +feed_html_header: /etc/jamdog/header.html -- cgit v1.2.3