Move Gitea configuration steps

This commit is contained in:
Ryan Cavicchioni 2020-10-12 16:41:26 -05:00
parent 5ee4391bc3
commit cc4a5748fa
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
4 changed files with 72 additions and 74 deletions

View File

@ -13,7 +13,6 @@ gitea_service_name: gitea.service
gitea_service_state: started gitea_service_state: started
gitea_service_enabled: yes 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_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_bin_path: /usr/local/bin
gitea_var_path: /var/lib/gitea gitea_var_path: /var/lib/gitea

View File

@ -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 - name: configure
template: template:
src: app.ini.j2 src: app.ini.j2
@ -9,3 +49,21 @@
notify: notify:
- restart gitea - 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 }}"

View File

@ -10,62 +10,3 @@
notify: notify:
- restart gitea - restart gitea
retries: 3 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 }}"

View File

@ -18,13 +18,9 @@
until: _latest_version.status == 200 until: _latest_version.status == 200
retries: 3 retries: 3
- name: get checksums - name: set gitea_version
set_fact: set_fact:
checksum_string: "{{ lookup('url', gitea_url + '.sha256') }}" gitea_version: "{{ _latest_version.json['tag_name'] | regex_replace('^v', '') }}"
- name: set gitea_checksum
set_fact:
gitea_checksum: "sha256:{{ checksum_string.split(' ') | first }}"
- block: - block:
- name: determine installed version - name: determine installed version
@ -35,14 +31,18 @@
- name: set gitea_local_version - name: set gitea_local_version
set_fact: set_fact:
gitea_local_version: "{{ _installed_version_string.stdout | regex_search('^Gitea version ([\\d.]+)', '\\1') | first }}" 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 when: gitea_installed | bool
- block: - name: set gitea_local_version to 0
- name: set gitea_local_version to 0
set_fact: set_fact:
gitea_local_version: "0" gitea_local_version: "0"
when: not gitea_installed | bool 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 }}"