Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imprve code for a präsentation #173

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
- name: "Restart gitea"
become: true
ansible.builtin.service:
listen: "systemctl restart gitea"
ansible.builtin.systemd_service:
name: gitea
state: restarted
when: ansible_service_mgr == "systemd"

- name: "Reload systemd"
become: true
ansible.builtin.systemd:
ansible.builtin.systemd_service:
daemon_reload: true
when: ansible_service_mgr == "systemd"

- name: "Systemctl restart fail2ban"
become: true
ansible.builtin.systemd:
ansible.builtin.systemd_service:
name: fail2ban
state: restarted
when: ansible_service_mgr == "systemd"
4 changes: 2 additions & 2 deletions tasks/backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
block:
- name: Stopping gitea before upgrade
become: true
ansible.builtin.systemd:
ansible.builtin.systemd_service:
name: 'gitea.service'
state: 'stopped'
when: ansible_service_mgr == "systemd"
Expand All @@ -33,7 +33,7 @@
rescue:
- name: Starting gitea because backup failed
become: true
ansible.builtin.systemd:
ansible.builtin.systemd_service:
name: 'gitea.service'
state: 'started'
when: ansible_service_mgr == "systemd"
Expand Down
6 changes: 3 additions & 3 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
- name: "Configure gitea"
become: true
ansible.builtin.template:
src: gitea.ini.j2
src: 'templates/gitea.ini.j2'
dest: "{{ gitea_configuration_path }}/gitea.ini"
owner: "{{ gitea_user }}"
group: "{{ gitea_group }}"
mode: '0640'
notify: "Restart gitea"
notify: "systemctl restart gitea"

- name: "Service gitea"
become: true
ansible.builtin.systemd:
ansible.builtin.systemd_service:
name: gitea
state: started
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion tasks/customize_footer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
mode: '0640'
failed_when: false
tags: skip_ansible_lint
notify: "Restart gitea"
notify: "systemctl restart gitea"
4 changes: 2 additions & 2 deletions tasks/customize_public_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
mode: "u=rwX,g=rX,o="
failed_when: false
tags: skip_ansible_lint
notify: "Restart gitea"
notify: "systemctl restart gitea"

- name: Create css directory for custom themes
when: gitea_custom_themes is defined
Expand All @@ -41,4 +41,4 @@
group: "{{ gitea_group }}"
mode: "u=rwX,g=rX,o="
loop: "{{ gitea_custom_themes }}"
notify: "Restart gitea"
notify: "systemctl restart gitea"
2 changes: 1 addition & 1 deletion tasks/install_forgejo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@
mode: 0755
owner: root
group: root
notify: "Restart gitea"
notify: "systemctl restart gitea"
2 changes: 1 addition & 1 deletion tasks/install_gitea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
mode: 0755
owner: root
group: root
notify: "Restart gitea"
notify: "systemctl restart gitea"
6 changes: 3 additions & 3 deletions tasks/install_systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
- name: "Setup systemd service"
become: true
ansible.builtin.template:
src: gitea.service.j2
src: 'templates/gitea.service.j2'
dest: "{{ gitea_systemd_path }}/gitea.service"
owner: root
group: root
mode: 0644
notify:
- "Reload systemd"
- "Restart gitea"
- "systemctl restart gitea"

- name: "Reload systemd"
become: true
ansible.builtin.systemd:
ansible.builtin.systemd_service:
daemon_reload: true
14 changes: 8 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
- name: Perform optional versionscheck
ansible.builtin.include_tasks:
file: "versioncheck.yml"
when: submodules_versioncheck|bool
when: submodules_versioncheck | bool

- name: Gather installed packages for checks later on
ansible.builtin.package_facts:
manager: "auto"

- name: Prepare gitea/forgejo variable import
block:
- name: Gather variables for gitea or forgejo
- name: Gather vars for gitea or forgejo
ansible.builtin.include_vars:
file: "{{ lookup('ansible.builtin.first_found', gitea_fork_variables) }}"
file: "{{ lookup('ansible.builtin.first_found',
gitea_fork_variables) }}"
rescue:
- name: Gitea/Forejo import info
- name: Gitea/Forgejo import info
ansible.builtin.fail:
msg: "Currently only {{ gitea_supported_forks }} are supported."
msg: "Only {{ gitea_supported_forks }} are supported."

- name: Gather Gitea/Forgejo UI Theme variables
ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', params) }}"
ansible.builtin.include_vars:
file: "{{ lookup('ansible.builtin.first_found', params) }}"
vars:
params:
files:
Expand Down
4 changes: 3 additions & 1 deletion tasks/set_forgejo_version.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- name: "Check forgejo installed version"
ansible.builtin.shell: "set -eo pipefail; {{ gitea_full_executable_path }} -v | cut -d' ' -f 3"
ansible.builtin.shell: |
set -eo pipefail
{{ gitea_full_executable_path }} -v | cut -d' ' -f 3
args:
executable: '/bin/bash'
register: gitea_active_version
Expand Down
4 changes: 3 additions & 1 deletion tasks/set_gitea_version.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- name: "Check gitea installed version"
ansible.builtin.shell: "set -eo pipefail; {{ gitea_full_executable_path }} -v | cut -d' ' -f 3"
ansible.builtin.shell: |
set -eo pipefail
{{ gitea_full_executable_path }} -v | cut -d' ' -f 3
args:
executable: /bin/bash
register: gitea_active_version
Expand Down
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ transfer_custom_footer:
- 'files/gitea_footer/extra_links_footer.tmpl'
- 'files/extra_links_footer.tmpl'

playbook_version_number: 61
playbook_version_number: 62
playbook_version_path: 'do1jlr.gitea.version'