Merge pull request 'Merge experimental nach main' (#3) from experimental into main
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 13s
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 13s
Reviewed-on: #3
This commit is contained in:
commit
32ac3f842a
@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
# In den hier aufgelisteten Dateien sollen die dahinter stehenden
|
|
||||||
# Warnungen und Fehler von ansible-lint ignoriert werden.
|
|
||||||
|
|
||||||
tasks/main.yaml no-handler # Der Restart / Recreate Gitea Task ist gut dort, wo er ist
|
|
||||||
tasks/start.yaml name[template] # Es braucht zwei Templates, um den FQDN zusammenzusetzen.
|
|
30
handlers/backup.yaml
Normal file
30
handlers/backup.yaml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
- name: Get stats of docker-compose.yaml
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /opt/gitea/docker-compose.yaml
|
||||||
|
register: docker_compose_stat
|
||||||
|
listen:
|
||||||
|
- Backup Gitea
|
||||||
|
|
||||||
|
- name: Stop Gitea for Backup
|
||||||
|
community.docker.docker_compose:
|
||||||
|
project_src: /opt/gitea
|
||||||
|
state: present
|
||||||
|
stopped: true
|
||||||
|
register: docker_compose
|
||||||
|
listen:
|
||||||
|
- Backup Gitea
|
||||||
|
notify:
|
||||||
|
- Ensure Gitea is running
|
||||||
|
when: docker_compose_stat.stat.exists is defined and docker_compose_stat.stat.exists
|
||||||
|
|
||||||
|
- name: Backup Gitea Directory
|
||||||
|
community.general.archive:
|
||||||
|
path: /opt/gitea/
|
||||||
|
dest: "/var/backups/gitea-{{ gitea.hostname }}.{{ gitea.domain }}@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}.tar.gz"
|
||||||
|
force_archive: true
|
||||||
|
format: gz
|
||||||
|
owner: root
|
||||||
|
mode: "400"
|
||||||
|
listen:
|
||||||
|
- Backup Gitea
|
||||||
|
register: backup
|
32
handlers/main.yaml
Normal file
32
handlers/main.yaml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
- name: Import Backup Handler
|
||||||
|
ansible.builtin.import_tasks:
|
||||||
|
file: backup.yaml
|
||||||
|
|
||||||
|
- name: Ensure Gitea is restarted
|
||||||
|
community.docker.docker_compose:
|
||||||
|
project_src: /opt/gitea
|
||||||
|
restarted: true
|
||||||
|
register: docker_compose
|
||||||
|
|
||||||
|
- name: Ensure Gitea is running
|
||||||
|
community.docker.docker_compose:
|
||||||
|
project_src: /opt/gitea
|
||||||
|
register: docker_compose
|
||||||
|
|
||||||
|
- name: Get Gitea HTTP Response
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "https://{{ gitea.hostname }}.{{ gitea.domain }}"
|
||||||
|
register: gitea_http_response
|
||||||
|
failed_when: 400 <= gitea_http_response.status < 500
|
||||||
|
|
||||||
|
- name: Wait until Gitea is up
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "https://{{ gitea.hostname }}.{{ gitea.domain }}"
|
||||||
|
register: gitea_http_response
|
||||||
|
until: gitea_http_response.status == 200
|
||||||
|
retries: 30
|
||||||
|
delay: 2
|
||||||
|
|
||||||
|
- name: Output Docker Compose State
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: docker_compose
|
@ -39,64 +39,48 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
- name: Backup Files
|
- name: Check if environment.env will get changed
|
||||||
block:
|
|
||||||
- name: Stop Gitea for Backup
|
|
||||||
community.docker.docker_compose:
|
|
||||||
project_src: /opt/gitea
|
|
||||||
state: present
|
|
||||||
stopped: true
|
|
||||||
|
|
||||||
- name: Backup Gitea Directory
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: /opt/gitea/
|
|
||||||
dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}"
|
|
||||||
mode: "700"
|
|
||||||
remote_src: true
|
|
||||||
directory_mode: true
|
|
||||||
register: backup
|
|
||||||
|
|
||||||
- name: Apply Changes
|
|
||||||
block:
|
|
||||||
- name: Upload Environment File
|
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: environment.env.j2
|
src: environment.env.j2
|
||||||
dest: "/opt/gitea/environment.env"
|
dest: "/opt/gitea/environment.env"
|
||||||
owner: root
|
owner: root
|
||||||
mode: "600"
|
mode: "600"
|
||||||
register: gitea_env
|
register: env_diff
|
||||||
|
check_mode: true
|
||||||
|
notify:
|
||||||
|
- Backup Gitea
|
||||||
|
|
||||||
- name: Upload docker-compose.yaml
|
- name: Check if docker-compose.yaml will get changed
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: docker-compose.yaml.j2
|
src: docker-compose.yaml.j2
|
||||||
dest: /opt/gitea/docker-compose.yaml
|
dest: /opt/gitea/docker-compose.yaml
|
||||||
owner: root
|
owner: root
|
||||||
mode: "600"
|
mode: "600"
|
||||||
validate: /usr/bin/docker compose -f %s config -q
|
register: docker_compose_diff
|
||||||
|
check_mode: true
|
||||||
|
notify:
|
||||||
|
- Backup Gitea
|
||||||
|
|
||||||
- name: Start Gitea and try reaching it
|
- name: Execute Handlers before changing configfiles
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.meta: flush_handlers
|
||||||
file: start.yaml
|
|
||||||
|
|
||||||
rescue:
|
- name: Upload Environment File
|
||||||
- name: Stop Gitea for Backup
|
ansible.builtin.template:
|
||||||
community.docker.docker_compose:
|
src: environment.env.j2
|
||||||
project_src: /opt/gitea
|
dest: "/opt/gitea/environment.env"
|
||||||
state: present
|
owner: root
|
||||||
stopped: true
|
mode: "600"
|
||||||
|
notify:
|
||||||
|
- Ensure Gitea is restarted
|
||||||
|
- Wait until Gitea is up
|
||||||
|
|
||||||
- name: Restore Gitea Directory from Backup
|
- name: Upload docker-compose.yaml
|
||||||
ansible.builtin.copy:
|
ansible.builtin.template:
|
||||||
src: "{{ backup.dest }}"
|
src: docker-compose.yaml.j2
|
||||||
dest: "{{ backup.src }}"
|
dest: /opt/gitea/docker-compose.yaml
|
||||||
remote_src: true
|
owner: root
|
||||||
mode: "700"
|
mode: "600"
|
||||||
|
notify:
|
||||||
- name: Start Gitea and try reaching it
|
- Output Docker Compose State
|
||||||
ansible.builtin.include_tasks:
|
- Ensure Gitea is restarted
|
||||||
file: start.yaml
|
- Wait until Gitea is up
|
||||||
|
|
||||||
always:
|
|
||||||
- name: Output Docker Compose State
|
|
||||||
ansible.builtin.debug:
|
|
||||||
var: docker_compose
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
- name: Start Gitea
|
|
||||||
community.docker.docker_compose:
|
|
||||||
project_src: /opt/gitea
|
|
||||||
register: docker_compose
|
|
||||||
|
|
||||||
- name: Check if {{ gitea.hostname }}.{{ gitea.domain }} is available and returning status 200
|
|
||||||
ansible.builtin.uri:
|
|
||||||
url: "https://{{ gitea.hostname }}.{{ gitea.domain }}"
|
|
||||||
register: _result
|
|
||||||
until: _result.status == 200
|
|
||||||
retries: 30
|
|
||||||
delay: 2
|
|
@ -93,7 +93,7 @@ GITEA__service__ENABLE_NOTIFY_MAIL={{ gitea_vars.service.enable_notify_mail }}
|
|||||||
GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE={{ gitea_vars.service.default_keep_email_private }}
|
GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE={{ gitea_vars.service.default_keep_email_private }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if 'default_allow_create_organization' in gitea_vars['service'] %}
|
{% if 'default_allow_create_organization' in gitea_vars['service'] %}
|
||||||
GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION ={{ gitea_vars.service.default_allow_create_organization }}
|
GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION={{ gitea_vars.service.default_allow_create_organization }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if 'default_enable_timetracking' in gitea_vars['service'] %}
|
{% if 'default_enable_timetracking' in gitea_vars['service'] %}
|
||||||
GITEA__service__DEFAULT_ENABLE_TIMETRACKING={{ gitea_vars.service.default_enable_timetracking }}
|
GITEA__service__DEFAULT_ENABLE_TIMETRACKING={{ gitea_vars.service.default_enable_timetracking }}
|
||||||
|
Loading…
Reference in New Issue
Block a user