aboutsummaryrefslogblamecommitdiffstats
path: root/roles/srht/tasks/main.yml
blob: 3815ebcd9ce6b13c9d50535ecd10a51c27259f48 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

















                                                                                                  
                                                




















                                                          

                             



                                           
                               














                                                                       
                             




                                       
                             


                                        
                            





                                            
                                


                    













                                                 

# 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 }}.sr.ht" 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: "{{ srht_services }}"


- name: generate srht example configuration
  template:
    src: config.ini.j2
    dest: /etc/sr.ht/config.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: "{{ srht_services }}"
  become: true
  become_user: postgres

- name: init database for srht services
  shell: "{{ item }}srht-initdb"
  loop: "{{ srht_services }}"

- name: enable and restart srht services
  service:
    name: "{{ item }}.sr.ht"
    state: restarted
    enabled: true
  loop: "{{ srht_services }}"

- name: enable and restart srht api services
  service:
    name: "{{ item }}.sr.ht-api"
    state: restarted
    enabled: true
  loop:
    - "meta"
    - "git"

- name: enable and restart srht webhooks services
  service:
    name: "{{ item }}.sr.ht-webhooks"
    state: restarted
    enabled: true
  loop:
    - "meta"
    - "git"

- name: restart nginx
  service: name=nginx state=restarted
remember that computers suck.