diff --git a/roles/gitea/defaults/main.yaml b/roles/gitea/defaults/main.yaml index d01767a..02cee39 100644 --- a/roles/gitea/defaults/main.yaml +++ b/roles/gitea/defaults/main.yaml @@ -13,7 +13,6 @@ gitea_service_name: gitea.service gitea_service_state: started gitea_service_enabled: yes -gitea_version: 1.12.2 gitea_url: "https://github.com/go-gitea/gitea/releases/download/v{{ gitea_version }}/gitea-{{ gitea_version }}-{{ ansible_system | lower }}-{{ gitea_go_arch }}" gitea_bin_path: /usr/local/bin gitea_var_path: /var/lib/gitea diff --git a/roles/gitea/tasks/configure.yaml b/roles/gitea/tasks/configure.yaml index 69b44f3..62496bf 100644 --- a/roles/gitea/tasks/configure.yaml +++ b/roles/gitea/tasks/configure.yaml @@ -1,4 +1,44 @@ --- +- name: create group + user: + name: "{{ gitea_group }}" + system: yes + +- name: create user and group + user: + name: "{{ gitea_user }}" + group: "{{ gitea_group }}" + shell: "{{ gitea_shell }}" + comment: "{{ gitea_gecos }}" + system: yes + password: "{{ gitea_password }}" + home: "{{ gitea_home_path }}" + +- name: "create {{ gitea_etc_path }}" + file: + path: "{{ gitea_etc_path }}" + owner: root + group: "{{ gitea_group }}" + mode: 0750 + state: directory + +- name: "create {{ gitea_var_path }} tree" + file: + path: "{{ item }}" + owner: "{{ gitea_user }}" + group: "{{ gitea_group }}" + mode: 0750 + state: directory + with_items: "{{ gitea_var_tree }}" + +- name: "create {{ gitea_log_path }} path" + file: + path: "{{ gitea_log_path }}" + owner: "{{ gitea_user }}" + group: "{{ gitea_group }}" + mode: 0755 + state: directory + - name: configure template: src: app.ini.j2 @@ -9,3 +49,21 @@ notify: - restart gitea +- name: configure systemd unit + template: + src: gitea.service.j2 + dest: "{{ gitea_systemd_unit_path }}" + owner: root + group: root + mode: 0644 + notify: + - gitea daemon-reload + - restart gitea + when: ansible_service_mgr == 'systemd' + +- name: manage service + service: + name: "{{ gitea_service_name }}" + state: "{{ gitea_service_state }}" + enabled: "{{ gitea_service_enabled }}" + diff --git a/roles/gitea/tasks/install.yaml b/roles/gitea/tasks/install.yaml index ed2f957..7591750 100644 --- a/roles/gitea/tasks/install.yaml +++ b/roles/gitea/tasks/install.yaml @@ -10,62 +10,3 @@ notify: - restart gitea retries: 3 - -- name: create group - user: - name: "{{ gitea_group }}" - system: yes - -- name: create user and group - user: - name: "{{ gitea_user }}" - group: "{{ gitea_group }}" - shell: "{{ gitea_shell }}" - comment: "{{ gitea_gecos }}" - system: yes - password: "{{ gitea_password }}" - home: "{{ gitea_home_path }}" - -- name: "create {{ gitea_etc_path }}" - file: - path: "{{ gitea_etc_path }}" - owner: root - group: "{{ gitea_group }}" - mode: 0750 - state: directory - -- name: "create {{ gitea_var_path }} tree" - file: - path: "{{ item }}" - owner: "{{ gitea_user }}" - group: "{{ gitea_group }}" - mode: 0750 - state: directory - with_items: "{{ gitea_var_tree }}" - -- name: "create {{ gitea_log_path }} path" - file: - path: "{{ gitea_log_path }}" - owner: "{{ gitea_user }}" - group: "{{ gitea_group }}" - mode: 0755 - state: directory - -- name: configure systemd unit - template: - src: gitea.service.j2 - dest: "{{ gitea_systemd_unit_path }}" - owner: root - group: root - mode: 0644 - notify: - - gitea daemon-reload - - restart gitea - when: ansible_service_mgr == 'systemd' - -- name: manage service - service: - name: "{{ gitea_service_name }}" - state: "{{ gitea_service_state }}" - enabled: "{{ gitea_service_enabled }}" - diff --git a/roles/gitea/tasks/pre.yaml b/roles/gitea/tasks/pre.yaml index 8af6450..b160c4c 100644 --- a/roles/gitea/tasks/pre.yaml +++ b/roles/gitea/tasks/pre.yaml @@ -18,13 +18,9 @@ until: _latest_version.status == 200 retries: 3 - - name: get checksums + - name: set gitea_version set_fact: - checksum_string: "{{ lookup('url', gitea_url + '.sha256') }}" - - - name: set gitea_checksum - set_fact: - gitea_checksum: "sha256:{{ checksum_string.split(' ') | first }}" + gitea_version: "{{ _latest_version.json['tag_name'] | regex_replace('^v', '') }}" - block: - name: determine installed version @@ -35,14 +31,18 @@ - name: set gitea_local_version set_fact: gitea_local_version: "{{ _installed_version_string.stdout | regex_search('^Gitea version ([\\d.]+)', '\\1') | first }}" - - - name: set gitea_local_version - set_fact: - gitea_version: "{{ _latest_version.json['tag_name'] | regex_replace('^v', '') }}" when: gitea_installed | bool -- block: - - name: set gitea_local_version to 0 - set_fact: - gitea_local_version: "0" +- name: set gitea_local_version to 0 + set_fact: + gitea_local_version: "0" when: not gitea_installed | bool + +- block: + - name: get checksums + set_fact: + checksum_string: "{{ lookup('url', gitea_url + '.sha256') }}" + + - name: set gitea_checksum + set_fact: + gitea_checksum: "sha256:{{ checksum_string.split(' ') | first }}"