Compare commits
No commits in common. "main" and "ansible-lint" have entirely different histories.
main
...
ansible-li
@ -1,6 +0,0 @@
|
|||||||
offline: false
|
|
||||||
|
|
||||||
warn_list:
|
|
||||||
- yaml[line-length]
|
|
||||||
- yaml[empty-lines]
|
|
||||||
- yaml[new-line-at-end-of-file]
|
|
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
# 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/main.yaml name[template] # Es braucht zwei Templates, um den FQDN zusammenzusetzen.
|
@ -1,5 +1,5 @@
|
|||||||
name: ansible-lint
|
name: ansible-lint
|
||||||
on: [push, pull_request] # yamllint disable-line rule:truthy
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -14,7 +14,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Run ansible-lint
|
- name: Run ansible-lint
|
||||||
# replace `main` with any valid ref, or tags like `v6`
|
# replace `main` with any valid ref, or tags like `v6`
|
||||||
uses: https://github.com/ansible/ansible-lint-action@v6
|
uses: https://github.com/ansible/ansible-lint-action@main
|
||||||
# optional:
|
# optional:
|
||||||
# with:
|
# with:
|
||||||
# path: "playbooks/" # <-- only one value is allowed
|
# path: "playbooks/" # <-- only one value is allowed
|
@ -1,29 +0,0 @@
|
|||||||
- 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_v2:
|
|
||||||
project_src: /opt/gitea
|
|
||||||
state: stopped
|
|
||||||
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: "{{ gitea_vars.base_path }}/"
|
|
||||||
dest: "/var/backups/gitea-{{ gitea.hostname }}.{{ gitea.domain }}@{{ lookup('pipe', 'date -u +%Y-%m-%dT%H:%M:%SZ') }}.tar.gz"
|
|
||||||
force_archive: true
|
|
||||||
format: gz
|
|
||||||
owner: root
|
|
||||||
mode: "400"
|
|
||||||
listen:
|
|
||||||
- Backup Gitea
|
|
||||||
register: backup
|
|
@ -1,37 +0,0 @@
|
|||||||
- name: Import backup handler
|
|
||||||
ansible.builtin.import_tasks:
|
|
||||||
file: backup.yaml
|
|
||||||
|
|
||||||
- name: Ensure Docker images are up to date
|
|
||||||
community.docker.docker_compose_v2_pull:
|
|
||||||
project_src: /opt/gitea
|
|
||||||
|
|
||||||
- name: Ensure Gitea is restarted
|
|
||||||
community.docker.docker_compose_v2:
|
|
||||||
project_src: /opt/gitea
|
|
||||||
state: restarted
|
|
||||||
recreate: always
|
|
||||||
register: docker_compose
|
|
||||||
|
|
||||||
- name: Ensure Gitea is running
|
|
||||||
community.docker.docker_compose_v2:
|
|
||||||
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
|
|
@ -1,8 +0,0 @@
|
|||||||
# actions/run-ansible-lint forces me to name this file .yml instead of .yaml :(
|
|
||||||
|
|
||||||
collections:
|
|
||||||
- name: community.docker
|
|
||||||
source: https://galaxy.ansible.com
|
|
||||||
|
|
||||||
- name: community.general
|
|
||||||
source: https://galaxy.ansible.com
|
|
144
tasks/main.yaml
144
tasks/main.yaml
@ -5,86 +5,114 @@
|
|||||||
# - docker.io
|
# - docker.io
|
||||||
# - python3-docker
|
# - python3-docker
|
||||||
|
|
||||||
- name: Ensure git user exists
|
- name: Create git USER
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: git
|
name: git
|
||||||
register: git_user
|
register: git_user
|
||||||
|
|
||||||
- name: Ensure Gitea directories exist
|
- name: Create Gitea
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: "/opt/gitea"
|
||||||
state: directory
|
state: directory
|
||||||
owner: root
|
owner: root
|
||||||
mode: "755"
|
mode: "755"
|
||||||
with_items: ["/opt/gitea", "{{ gitea_vars.base_path }}"]
|
|
||||||
|
|
||||||
- name: Ensure data and config directories exist
|
- name: Create Data Directory
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ gitea_vars.base_path }}/{{ item }}"
|
path: "/opt/gitea/data"
|
||||||
state: directory
|
state: directory
|
||||||
owner: "{{ git_user.uid }}"
|
owner: "{{ git_user.uid }}"
|
||||||
group: "{{ git_user.group }}"
|
group: "{{ git_user.group }}"
|
||||||
mode: "700"
|
mode: "700"
|
||||||
with_items: ["data", "config"]
|
|
||||||
|
|
||||||
- name: Ensure docker daemon is started
|
- name: Create Config Directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/opt/gitea/config"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ git_user.uid }}"
|
||||||
|
group: "{{ git_user.group }}"
|
||||||
|
mode: "700"
|
||||||
|
|
||||||
|
- name: Start Docker Daemon
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: docker
|
name: docker
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
- name: Ensure old backups will get deleted
|
- name: Backup Files
|
||||||
ansible.builtin.cron:
|
block:
|
||||||
name: gitea backup cleanup
|
- name: Stop Gitea for Backup
|
||||||
minute: "0"
|
community.docker.docker_compose:
|
||||||
hour: "8"
|
project_src: /opt/gitea
|
||||||
user: root
|
state: present
|
||||||
job: find /var/backups -path '/var/backups/gitea-*' -mtime +7 -type f -exec rm {} +
|
stopped: true
|
||||||
cron_file: gitea-backup-cleanup
|
|
||||||
|
|
||||||
- name: Check if environment.env will get changed
|
- name: Backup Gitea Directory
|
||||||
ansible.builtin.template:
|
ansible.builtin.copy:
|
||||||
src: environment.env.j2
|
src: /opt/gitea
|
||||||
dest: "/opt/gitea/environment.env"
|
dest: "/opt/gitea.backup@{{ ansible_date_time.iso8601 }}"
|
||||||
owner: root
|
mode: "700"
|
||||||
mode: "600"
|
remote_src: true
|
||||||
register: env_diff
|
directory_mode: true
|
||||||
check_mode: true
|
register: backup
|
||||||
notify:
|
|
||||||
- Backup Gitea
|
|
||||||
|
|
||||||
- name: Check if docker-compose.yaml will get changed
|
- name: Apply Changes
|
||||||
ansible.builtin.template:
|
block:
|
||||||
src: docker-compose.yaml.j2
|
- name: Upload Environment File
|
||||||
dest: /opt/gitea/docker-compose.yaml
|
ansible.builtin.template:
|
||||||
owner: root
|
src: environment.env.j2
|
||||||
mode: "600"
|
dest: "/opt/gitea/environment.env"
|
||||||
register: docker_compose_diff
|
owner: root
|
||||||
check_mode: true
|
mode: "600"
|
||||||
notify:
|
register: gitea_env
|
||||||
- Backup Gitea
|
|
||||||
|
|
||||||
- name: Execute handlers before changing configfiles
|
- name: Upload docker-compose.yaml
|
||||||
ansible.builtin.meta: flush_handlers
|
ansible.builtin.template:
|
||||||
|
src: docker-compose.yaml.j2
|
||||||
|
dest: /opt/gitea/docker-compose.yaml
|
||||||
|
owner: root
|
||||||
|
mode: "600"
|
||||||
|
register: gitea_container
|
||||||
|
|
||||||
- name: Upload environment.env
|
- name: Create / Recreate Gitea
|
||||||
ansible.builtin.template:
|
community.docker.docker_compose:
|
||||||
src: environment.env.j2
|
project_src: /opt/gitea
|
||||||
dest: "/opt/gitea/environment.env"
|
state: present
|
||||||
owner: root
|
restarted: true
|
||||||
mode: "600"
|
when: gitea_env.changed or gitea_container.changed
|
||||||
notify:
|
|
||||||
- Ensure Gitea is restarted
|
|
||||||
- Wait until Gitea is up
|
|
||||||
|
|
||||||
- name: Upload docker-compose.yaml
|
- name: Check if {{ gitea.hostname }}.{{ gitea.domain }} is available and returning status 200
|
||||||
ansible.builtin.template:
|
ansible.builtin.uri:
|
||||||
src: docker-compose.yaml.j2
|
url: "https://{{ gitea.hostname }}.{{ gitea.domain }}"
|
||||||
dest: /opt/gitea/docker-compose.yaml
|
register: _result
|
||||||
owner: root
|
until: _result.status == 200
|
||||||
mode: "600"
|
retries: 30
|
||||||
notify:
|
delay: 2
|
||||||
- Ensure Docker images are up to date
|
|
||||||
- Output docker compose state
|
rescue:
|
||||||
- Ensure Gitea is restarted
|
- name: Stop Gitea for Backup
|
||||||
- Wait until Gitea is up
|
community.docker.docker_compose:
|
||||||
|
project_src: /opt/gitea
|
||||||
|
state: present
|
||||||
|
stopped: true
|
||||||
|
|
||||||
|
- name: Restore Gitea Directory from Backup
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ backup.dest }}"
|
||||||
|
dest: "{{ backup.src }}"
|
||||||
|
remote_src: true
|
||||||
|
mode: "700"
|
||||||
|
|
||||||
|
- name: Create / Recreate Gitea
|
||||||
|
community.docker.docker_compose:
|
||||||
|
project_src: /opt/gitea
|
||||||
|
state: present
|
||||||
|
restarted: true
|
||||||
|
always:
|
||||||
|
- 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
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# -- Diese Datei wird via Ansible verwaltet und automatisch überschrieben!
|
# -- Diese Datei wird via Ansible verwaltet und automatisch überschrieben!
|
||||||
# https://azubi-gitea.int.sernet.de/mmeyer/ansible-role-gitea/src/branch/main/templates/docker-compose.yaml.j2
|
# https://azubi-gitea.int.sernet.de/mmeyer/ansible-role-gitea/src/branch/main/templates/docker-compose.yaml.j2
|
||||||
|
|
||||||
|
version: "3.8"
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
gitea:
|
gitea:
|
||||||
external: false
|
external: false
|
||||||
@ -11,10 +13,10 @@ networks:
|
|||||||
services:
|
services:
|
||||||
gitea:
|
gitea:
|
||||||
image: gitea/gitea:{{ gitea_vars['version'] }}-rootless
|
image: gitea/gitea:{{ gitea_vars['version'] }}-rootless
|
||||||
restart: unless-stopped
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- {{ gitea_vars.base_path }}/data:/var/lib/gitea
|
- ./data:/var/lib/gitea
|
||||||
- {{ gitea_vars.base_path }}/config:/etc/gitea
|
- ./config:/etc/gitea
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
ports:
|
ports:
|
||||||
@ -29,7 +31,7 @@ services:
|
|||||||
|
|
||||||
db:
|
db:
|
||||||
image: "{{ gitea_vars['database']['db_type'] }}:{{ gitea_vars['database']['docker_image_tag'] }}"
|
image: "{{ gitea_vars['database']['db_type'] }}:{{ gitea_vars['database']['docker_image_tag'] }}"
|
||||||
restart: unless-stopped
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- "MYSQL_DATABASE={{ gitea_vars.database.name }}"
|
- "MYSQL_DATABASE={{ gitea_vars.database.name }}"
|
||||||
- "MYSQL_USER={{ gitea_vars.database.user }}"
|
- "MYSQL_USER={{ gitea_vars.database.user }}"
|
||||||
@ -38,6 +40,5 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- gitea
|
- gitea
|
||||||
volumes:
|
volumes:
|
||||||
- {{ gitea_vars.base_path }}/mysql:/var/lib/mysql
|
- ./mysql:/var/lib/mysql
|
||||||
cap_add:
|
|
||||||
- SYS_NICE
|
|
||||||
|
@ -47,6 +47,9 @@ GITEA__database__SQLITE_JOURNAL_MODE={{ gitea_vars.database.sqlite_journal_mode
|
|||||||
{% if 'iterate_buffer_size' in gitea_vars['database'] %}
|
{% if 'iterate_buffer_size' in gitea_vars['database'] %}
|
||||||
GITEA__database__ITERATE_BUFFER_SIZE={{ gitea_vars.database.iterate_buffer_size }}
|
GITEA__database__ITERATE_BUFFER_SIZE={{ gitea_vars.database.iterate_buffer_size }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if 'charset' in gitea_vars['database'] %}
|
||||||
|
GITEA__database__CHARSET={{ gitea_vars.database.charset }}
|
||||||
|
{% endif %}
|
||||||
{% if 'path' in gitea_vars['database'] %}
|
{% if 'path' in gitea_vars['database'] %}
|
||||||
GITEA__database__PATH={{ gitea_vars.database.path }}
|
GITEA__database__PATH={{ gitea_vars.database.path }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -90,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 }}
|
||||||
@ -184,7 +187,7 @@ GITEA__attachment__MINIO_BASE_PATH={{ gitea_vars.attachment.minio_base_path }}
|
|||||||
GITEA__attachment__MINIO_USE_SSL={{ gitea_vars.attachment.minio_use_ssl }}
|
GITEA__attachment__MINIO_USE_SSL={{ gitea_vars.attachment.minio_use_ssl }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %} {# /attachment #}
|
{% endif %} {# /attachment #}
|
||||||
{# Disabled logging for now
|
|
||||||
{% if 'log' in gitea_vars %}
|
{% if 'log' in gitea_vars %}
|
||||||
{% if 'root_path' in gitea_vars['log'] %}
|
{% if 'root_path' in gitea_vars['log'] %}
|
||||||
GITEA__log__ROOT_PATH={{ gitea_vars.log.root_path }}
|
GITEA__log__ROOT_PATH={{ gitea_vars.log.root_path }}
|
||||||
@ -205,7 +208,7 @@ GITEA__log__ENABLE_log_LOG={{ gitea_vars.log.enable_log_log }}
|
|||||||
GITEA__log__ENABLE_XORM_LOG={{ gitea_vars.log.enable_xorm_log }}
|
GITEA__log__ENABLE_XORM_LOG={{ gitea_vars.log.enable_xorm_log }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %} {# /logging#}
|
{% endif %} {# /logging#}
|
||||||
#}
|
|
||||||
{% if 'ssh' in gitea_vars %}
|
{% if 'ssh' in gitea_vars %}
|
||||||
{% if 'minimum_key_sizes' in gitea_vars['ssh'] %}
|
{% if 'minimum_key_sizes' in gitea_vars['ssh'] %}
|
||||||
{% if 'ed25519' in gitea_vars['ssh']['minimum_key_sizes'] %}
|
{% if 'ed25519' in gitea_vars['ssh']['minimum_key_sizes'] %}
|
||||||
@ -302,18 +305,3 @@ GITEA__actions__ENABLED={{ gitea_vars.actions.enabled }}
|
|||||||
GITEA__actions__DEFAULT_ACTIONS_URL={{ gitea_vars.actions.default_actions_url }}
|
GITEA__actions__DEFAULT_ACTIONS_URL={{ gitea_vars.actions.default_actions_url }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %} {# /actions #}
|
{% endif %} {# /actions #}
|
||||||
|
|
||||||
{% if 'metrics' in gitea_vars %}
|
|
||||||
{% if 'enabled' in gitea_vars['metrics'] %}
|
|
||||||
GITEA__metrics__ENABLED={{ gitea_vars.metrics.enabled }}
|
|
||||||
{% endif %}
|
|
||||||
{% if 'enabled_issue_by_label' in gitea_vars['metrics'] %}
|
|
||||||
GITEA__metrics__ENABLED_ISSUE_BY_LABEL={{ gitea_vars.metrics.enabled_issue_by_label }}
|
|
||||||
{% endif %}
|
|
||||||
{% if 'enabled_issue_by_repository' in gitea_vars['metrics'] %}
|
|
||||||
GITEA__metrics__ENABLED_ISSUE_BY_REPOSITORY={{ gitea_vars.metrics.enabled_issue_by_repository }}
|
|
||||||
{% endif %}
|
|
||||||
{% if 'token' in gitea_vars['metrics'] %}
|
|
||||||
GITEA__metrics__TOKEN={{ gitea_vars.metrics.token }}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %} {# /actions #}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user