mirror of
https://github.com/roles-ansible/ansible_role_gitea.git
synced 2024-08-16 11:39:50 +02:00
use new ansible name scheme at more tasks
This commit is contained in:
parent
6096767d26
commit
d3c26ac0f8
7 changed files with 50 additions and 33 deletions
|
@ -1,17 +1,20 @@
|
||||||
---
|
---
|
||||||
- name: "Restart gitea"
|
- name: "Restart gitea"
|
||||||
|
become: true
|
||||||
service:
|
service:
|
||||||
name: gitea
|
name: gitea
|
||||||
state: restarted
|
state: restarted
|
||||||
when: ansible_service_mgr == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- name: "Reload systemd"
|
- name: "Reload systemd"
|
||||||
|
become: true
|
||||||
systemd:
|
systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
when: ansible_service_mgr == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- name: "Restart fail2ban"
|
- name: "systemctl restart fail2ban"
|
||||||
service:
|
become: true
|
||||||
|
ansible.builtin.systemd:
|
||||||
name: fail2ban
|
name: fail2ban
|
||||||
state: restarted
|
state: restarted
|
||||||
when: ansible_service_mgr == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
---
|
---
|
||||||
- name: Get service facts
|
- name: Get service facts
|
||||||
service_facts:
|
ansible.builtin.service_facts:
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Stopping gitea before upgrade
|
- name: Stopping gitea before upgrade
|
||||||
service:
|
become: true
|
||||||
|
ansible.builtin.systemd:
|
||||||
name: gitea
|
name: gitea
|
||||||
state: stopped
|
state: stopped
|
||||||
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- name: "Create backup directory"
|
- name: "Create backup directory"
|
||||||
file:
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: "{{ gitea_user }}"
|
owner: "{{ gitea_user }}"
|
||||||
|
@ -19,13 +22,11 @@
|
||||||
- "{{ gitea_backup_location }}"
|
- "{{ gitea_backup_location }}"
|
||||||
|
|
||||||
- name: Backing up gitea before upgrade
|
- name: Backing up gitea before upgrade
|
||||||
command:
|
ansible.builtin.command:
|
||||||
cmd: "gitea dump -c /etc/gitea/gitea.ini"
|
cmd: "gitea dump -c /etc/gitea/gitea.ini"
|
||||||
chdir: "{{ gitea_backup_location }}"
|
chdir: "{{ gitea_backup_location }}"
|
||||||
become: true
|
become: true
|
||||||
become_method: su
|
|
||||||
become_user: "{{ gitea_user }}"
|
become_user: "{{ gitea_user }}"
|
||||||
become_flags: "-s /bin/sh"
|
|
||||||
when:
|
when:
|
||||||
- ansible_facts.services["gitea.service"] is defined
|
- ansible_facts.services["gitea.service"] is defined
|
||||||
- ansible_facts.services["gitea.service"].state == "running"
|
- ansible_facts.services["gitea.service"].state == "running"
|
||||||
|
|
18
tasks/configure.yml
Normal file
18
tasks/configure.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
- name: "Configure gitea"
|
||||||
|
become: true
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: gitea.ini.j2
|
||||||
|
dest: /etc/gitea/gitea.ini
|
||||||
|
owner: "{{ gitea_user }}"
|
||||||
|
group: "{{ gitea_group }}"
|
||||||
|
mode: 0600
|
||||||
|
notify: "Restart gitea"
|
||||||
|
|
||||||
|
- name: "Service gitea"
|
||||||
|
become: true
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: gitea
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
when: ansible_service_mgr == "systemd"
|
|
@ -1,11 +1,13 @@
|
||||||
---
|
---
|
||||||
- name: "Create Gitea Group"
|
- name: "Create Gitea Group"
|
||||||
|
become: true
|
||||||
group:
|
group:
|
||||||
name: "{{ gitea_group }}"
|
name: "{{ gitea_group }}"
|
||||||
system: true
|
system: true
|
||||||
state: "present"
|
state: "present"
|
||||||
|
|
||||||
- name: "Create Gitea user"
|
- name: "Create Gitea user"
|
||||||
|
become: true
|
||||||
user:
|
user:
|
||||||
name: "{{ gitea_user }}"
|
name: "{{ gitea_user }}"
|
||||||
comment: "Gitea user"
|
comment: "Gitea user"
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
---
|
---
|
||||||
- name: Install fail2ban filter
|
- name: Install fail2ban filter
|
||||||
template:
|
become: true
|
||||||
|
ansible.builtin.template:
|
||||||
src: fail2ban/filter.conf.j2
|
src: fail2ban/filter.conf.j2
|
||||||
dest: /etc/fail2ban/filter.d/gitea.conf
|
dest: /etc/fail2ban/filter.d/gitea.conf
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0444
|
mode: 0444
|
||||||
notify: Restart fail2ban
|
notify: systemctl restart fail2ban
|
||||||
|
|
||||||
- name: Install fail2ban jail
|
- name: Install fail2ban jail
|
||||||
template:
|
become: true
|
||||||
|
ansible.builtin.template:
|
||||||
src: fail2ban/jail.conf.j2
|
src: fail2ban/jail.conf.j2
|
||||||
dest: /etc/fail2ban/jail.d/gitea.conf
|
dest: /etc/fail2ban/jail.d/gitea.conf
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0444
|
mode: 0444
|
||||||
notify: Restart fail2ban
|
notify: systemctl restart fail2ban
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: "Setup systemd service"
|
- name: "Setup systemd service"
|
||||||
|
become: true
|
||||||
template:
|
template:
|
||||||
src: gitea.service.j2
|
src: gitea.service.j2
|
||||||
dest: /lib/systemd/system/gitea.service
|
dest: /lib/systemd/system/gitea.service
|
||||||
|
@ -10,8 +11,7 @@
|
||||||
- "Reload systemd"
|
- "Reload systemd"
|
||||||
- "Restart gitea"
|
- "Restart gitea"
|
||||||
|
|
||||||
# systemd to be reloaded the first time because
|
|
||||||
# it is the only way Systemd is going to be aware of the new unit file.
|
|
||||||
- name: "Reload systemd"
|
- name: "Reload systemd"
|
||||||
|
become: true
|
||||||
systemd:
|
systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
|
@ -28,28 +28,19 @@
|
||||||
- name: Create directorys
|
- name: Create directorys
|
||||||
ansible.builtin.include_tasks: directory.yml
|
ansible.builtin.include_tasks: directory.yml
|
||||||
|
|
||||||
- include: install_systemd.yml
|
- name: setup gitea systemd service
|
||||||
|
ansible.builtin.include_tasks: install_systemd.yml
|
||||||
when: ansible_service_mgr == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
- include_tasks: jwt_secrets.yml
|
- name: generate JWT Secrets if undefined
|
||||||
|
ansible.builtin.include_tasks: jwt_secrets.yml
|
||||||
|
|
||||||
- include_tasks: gitea_secrets.yml
|
- name: generate gitea secrets if undefined
|
||||||
|
ansible.builtin.include_tasks: gitea_secrets.yml
|
||||||
|
|
||||||
- name: "Configure gitea"
|
- name: configure gitea
|
||||||
template:
|
ansible.builtin.include_tasks: configure.yml
|
||||||
src: gitea.ini.j2
|
|
||||||
dest: /etc/gitea/gitea.ini
|
|
||||||
owner: "{{ gitea_user }}"
|
|
||||||
group: "{{ gitea_group }}"
|
|
||||||
mode: 0600
|
|
||||||
notify: "Restart gitea"
|
|
||||||
|
|
||||||
- name: "Service gitea"
|
- name: deploy optional fail2ban rules
|
||||||
service:
|
ansible.builtin.include_tasks: fail2ban.yml
|
||||||
name: gitea
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
when: ansible_service_mgr == "systemd"
|
|
||||||
|
|
||||||
- include: fail2ban.yml
|
|
||||||
when: gitea_fail2ban_enabled|bool
|
when: gitea_fail2ban_enabled|bool
|
||||||
|
|
Loading…
Reference in a new issue