blob: 076557fdaf9a5e6e5d2b2c32929b30e6c984649d (
plain) (
tree)
|
|
# srht ~~ roles/srht/tasks/main.yml
# Srht git server
---
- name: ensure srht repository is enabled
lineinfile:
path: /etc/apk/repositories
regexp: "^https://mirror.sr.ht"
line: "https://mirror.sr.ht/alpine/v3.12/sr.ht"
- name: ensure signing key for sourcehut repository is installed
shell: |
wget -q -O /etc/apk/keys/alpine@sr.ht.rsa.pub https://mirror.sr.ht/alpine/alpine@sr.ht.rsa.pub
apk update
- name: ensure sourcehut is installed
package: name="{{ item }}" state=present
loop: "{{ srht_services }}"
- name: generate srht service key
shell: srht-keygen service | rev | cut -d " " -f 1 | rev
register: srht_key_service
- name: generate srht network key
shell: srht-keygen network | rev | cut -d " " -f 1 | rev
register: srht_key_network
- name: generate srht webhook key
shell: srht-keygen webhook | rev | cut -d " " -f 1 | rev
register: srht_key_webhook
- name: generate srht nginx configuration
template:
src: "{{ item }}.srht.conf.j2"
dest: "/etc/nginx/conf.d/{{ item }}.srht.conf"
owner: "{{ user_root }}"
group: "{{ group_root }}"
mode: 0644
loop:
- "meta"
- "hub"
- name: generate srht example configuration
template:
src: config.ini.j2
dest: /etc/sr.ht/config.example.ini
owner: "{{ user_root }}"
group: "{{ group_root }}"
mode: 0644
- name: debug hint for example configuration
debug:
msg:
- srht configuration example at /etc/sr.ht/config.example.ini
- copy and modify it to /etc/sr.ht/config.ini
- name: create database for srht services
shell: psql -c 'create database "{{ item }}.sr.ht"'
register: result
failed_when: result.rc != 0 and "already exists" not in result.stderr
ignore_errors: true
loop:
- "meta"
- "git"
- "hub"
become: true
become_user: postgres
- name: init database for srht services
shell: "{{ item }}srht-initdb"
loop:
- "meta"
- "git"
- "hub"
- name: enable and restart srht services
service:
name: "{{ item }}"
state: restarted
enabled: true
loop: "{{ srht_services }}"
- name: enable and restart srht api services
service:
name: "{{ item }}"
state: restarted
enabled: true
loop:
- "meta.sr.ht-api"
- "git.sr.ht-api"
|