diff options
Diffstat (limited to 'roles/jamdog/tasks/main.yml')
| -rw-r--r-- | roles/jamdog/tasks/main.yml | 123 |
1 files changed, 123 insertions, 0 deletions
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 ^\<link\ rel=\"stylesheet\" \ + > {{ 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 |
