Compare commits
28 Commits
experiment
...
main
Author | SHA1 | Date | |
---|---|---|---|
ab52152834 | |||
115ab7e840 | |||
|
14da8cd5a1 | ||
|
50e6c10349 | ||
|
c28214c517 | ||
306d2eebbe | |||
|
b0da3ff4a7 | ||
|
529749ed14 | ||
|
d03e1142f2 | ||
|
fbc2a17011 | ||
|
c39d29c03f | ||
d7fe8eb263 | |||
|
d2e25188cc | ||
|
16c3c592c0 | ||
|
fa915065f5 | ||
|
bbc480fec2 | ||
|
3da637c178 | ||
|
2bca413df1 | ||
|
1e33c1d339 | ||
|
d37cc02ecf | ||
|
d4b9261f24 | ||
|
e8545cd4e7 | ||
|
18c18c112b | ||
|
9451bdb478 | ||
|
b1789e15d6 | ||
|
a20c7b188d | ||
cf59550120 | |||
32ac3f842a |
6
.ansible-lint
Normal file
6
.ansible-lint
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
offline: false
|
||||||
|
|
||||||
|
warn_list:
|
||||||
|
- yaml[line-length]
|
||||||
|
- yaml[empty-lines]
|
||||||
|
- yaml[new-line-at-end-of-file]
|
@ -1,5 +1,5 @@
|
|||||||
name: ansible-lint
|
name: ansible-lint
|
||||||
on: [push, pull_request]
|
on: [push, pull_request] # yamllint disable-line rule:truthy
|
||||||
|
|
||||||
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@main
|
uses: https://github.com/ansible/ansible-lint-action@v6
|
||||||
# optional:
|
# optional:
|
||||||
# with:
|
# with:
|
||||||
# path: "playbooks/" # <-- only one value is allowed
|
# path: "playbooks/" # <-- only one value is allowed
|
@ -5,11 +5,10 @@
|
|||||||
listen:
|
listen:
|
||||||
- Backup Gitea
|
- Backup Gitea
|
||||||
|
|
||||||
- name: Stop Gitea for Backup
|
- name: Stop Gitea for backup
|
||||||
community.docker.docker_compose:
|
community.docker.docker_compose_v2:
|
||||||
project_src: /opt/gitea
|
project_src: /opt/gitea
|
||||||
state: present
|
state: stopped
|
||||||
stopped: true
|
|
||||||
register: docker_compose
|
register: docker_compose
|
||||||
listen:
|
listen:
|
||||||
- Backup Gitea
|
- Backup Gitea
|
||||||
@ -17,10 +16,10 @@
|
|||||||
- Ensure Gitea is running
|
- Ensure Gitea is running
|
||||||
when: docker_compose_stat.stat.exists is defined and docker_compose_stat.stat.exists
|
when: docker_compose_stat.stat.exists is defined and docker_compose_stat.stat.exists
|
||||||
|
|
||||||
- name: Backup Gitea Directory
|
- name: Backup Gitea directory
|
||||||
community.general.archive:
|
community.general.archive:
|
||||||
path: /opt/gitea/
|
path: "{{ gitea_vars.base_path }}/"
|
||||||
dest: "/var/backups/gitea-{{ gitea.hostname }}.{{ gitea.domain }}@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}.tar.gz"
|
dest: "/var/backups/gitea-{{ gitea.hostname }}.{{ gitea.domain }}@{{ lookup('pipe', 'date -u +%Y-%m-%dT%H:%M:%SZ') }}.tar.gz"
|
||||||
force_archive: true
|
force_archive: true
|
||||||
format: gz
|
format: gz
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
- name: Import Backup Handler
|
- name: Import backup handler
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: backup.yaml
|
file: backup.yaml
|
||||||
|
|
||||||
- name: Ensure Gitea is restarted
|
- name: Ensure Docker images are up to date
|
||||||
community.docker.docker_compose:
|
community.docker.docker_compose_v2_pull:
|
||||||
project_src: /opt/gitea
|
project_src: /opt/gitea
|
||||||
restarted: true
|
|
||||||
|
- name: Ensure Gitea is restarted
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: /opt/gitea
|
||||||
|
state: restarted
|
||||||
|
recreate: always
|
||||||
register: docker_compose
|
register: docker_compose
|
||||||
|
|
||||||
- name: Ensure Gitea is running
|
- name: Ensure Gitea is running
|
||||||
community.docker.docker_compose:
|
community.docker.docker_compose_v2:
|
||||||
project_src: /opt/gitea
|
project_src: /opt/gitea
|
||||||
register: docker_compose
|
register: docker_compose
|
||||||
|
|
||||||
- name: Get Gitea HTTP Response
|
- name: Get Gitea HTTP response
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: "https://{{ gitea.hostname }}.{{ gitea.domain }}"
|
url: "https://{{ gitea.hostname }}.{{ gitea.domain }}"
|
||||||
register: gitea_http_response
|
register: gitea_http_response
|
||||||
@ -27,6 +32,6 @@
|
|||||||
retries: 30
|
retries: 30
|
||||||
delay: 2
|
delay: 2
|
||||||
|
|
||||||
- name: Output Docker Compose State
|
- name: Output docker compose state
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: docker_compose
|
var: docker_compose
|
||||||
|
8
requirements.yml
Normal file
8
requirements.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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
|
@ -5,40 +5,43 @@
|
|||||||
# - docker.io
|
# - docker.io
|
||||||
# - python3-docker
|
# - python3-docker
|
||||||
|
|
||||||
- name: Create git USER
|
- name: Ensure git user exists
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: git
|
name: git
|
||||||
register: git_user
|
register: git_user
|
||||||
|
|
||||||
- name: Create Gitea
|
- name: Ensure Gitea directories exist
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "/opt/gitea"
|
path: "{{ item }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: root
|
owner: root
|
||||||
mode: "755"
|
mode: "755"
|
||||||
|
with_items: ["/opt/gitea", "{{ gitea_vars.base_path }}"]
|
||||||
|
|
||||||
- name: Create Data Directory
|
- name: Ensure data and config directories exist
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "/opt/gitea/data"
|
path: "{{ gitea_vars.base_path }}/{{ item }}"
|
||||||
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: Create Config Directory
|
- name: Ensure docker daemon is started
|
||||||
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
|
||||||
|
ansible.builtin.cron:
|
||||||
|
name: gitea backup cleanup
|
||||||
|
minute: "0"
|
||||||
|
hour: "8"
|
||||||
|
user: root
|
||||||
|
job: find /var/backups -path '/var/backups/gitea-*' -mtime +7 -type f -exec rm {} +
|
||||||
|
cron_file: gitea-backup-cleanup
|
||||||
|
|
||||||
- name: Check if environment.env will get changed
|
- name: Check if environment.env will get changed
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: environment.env.j2
|
src: environment.env.j2
|
||||||
@ -61,10 +64,10 @@
|
|||||||
notify:
|
notify:
|
||||||
- Backup Gitea
|
- Backup Gitea
|
||||||
|
|
||||||
- name: Execute Handlers before changing configfiles
|
- name: Execute handlers before changing configfiles
|
||||||
ansible.builtin.meta: flush_handlers
|
ansible.builtin.meta: flush_handlers
|
||||||
|
|
||||||
- name: Upload Environment File
|
- name: Upload environment.env
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: environment.env.j2
|
src: environment.env.j2
|
||||||
dest: "/opt/gitea/environment.env"
|
dest: "/opt/gitea/environment.env"
|
||||||
@ -81,6 +84,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
mode: "600"
|
mode: "600"
|
||||||
notify:
|
notify:
|
||||||
- Output Docker Compose State
|
- Ensure Docker images are up to date
|
||||||
|
- Output docker compose state
|
||||||
- Ensure Gitea is restarted
|
- Ensure Gitea is restarted
|
||||||
- Wait until Gitea is up
|
- Wait until Gitea is up
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
# -- 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
|
||||||
@ -13,10 +11,10 @@ networks:
|
|||||||
services:
|
services:
|
||||||
gitea:
|
gitea:
|
||||||
image: gitea/gitea:{{ gitea_vars['version'] }}-rootless
|
image: gitea/gitea:{{ gitea_vars['version'] }}-rootless
|
||||||
restart: always
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/var/lib/gitea
|
- {{ gitea_vars.base_path }}/data:/var/lib/gitea
|
||||||
- ./config:/etc/gitea
|
- {{ gitea_vars.base_path }}/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:
|
||||||
@ -31,7 +29,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: always
|
restart: unless-stopped
|
||||||
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 }}"
|
||||||
@ -40,5 +38,6 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- gitea
|
- gitea
|
||||||
volumes:
|
volumes:
|
||||||
- ./mysql:/var/lib/mysql
|
- {{ gitea_vars.base_path }}/mysql:/var/lib/mysql
|
||||||
|
cap_add:
|
||||||
|
- SYS_NICE
|
||||||
|
@ -47,9 +47,6 @@ 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 %}
|
||||||
@ -187,7 +184,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 }}
|
||||||
@ -208,7 +205,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'] %}
|
||||||
@ -305,3 +302,18 @@ 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