diff --git a/defaults/main.yml b/defaults/main.yml index 1775ccf..1aab15c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -56,12 +56,12 @@ gitea_organizations: [] # - org1 # - org2 -# Purge -gitea_container_purge_timer_name: 'gitea-purge-artifact' -gitea_container_purge_timer_user: '{{ gitea_app_host_uid }}' -gitea_container_purge_timer_frequency: 'daily' -gitea_container_purge_timer_timeout: 120 -gitea_purge_max_retention: 15 +# Cleanup +gitea_container_cleanup_timer_name: 'gitea-cleanup-artifact' +gitea_container_cleanup_timer_user: '{{ gitea_app_host_uid }}' +gitea_container_cleanup_timer_frequency: 'daily' +gitea_container_cleanup_timer_timeout: 120 +gitea_cleanup_max_retention: 15 # General container management compose_recreate: 'smart' diff --git a/templates/purge-registry.py.j2 b/files/cleanup-registry.py similarity index 100% rename from templates/purge-registry.py.j2 rename to files/cleanup-registry.py diff --git a/tasks/cleanup.yml b/tasks/cleanup.yml new file mode 100644 index 0000000..133c9f3 --- /dev/null +++ b/tasks/cleanup.yml @@ -0,0 +1,27 @@ +--- +- name: Copy registry cleanup script + copy: + src: 'cleanup-registry.py' + dest: '{{ gitea_service_path }}/cleanup-registry.py' + owner: '{{ gitea_app_host_uid }}' + group: docker + mode: 0755 + +- name: 'Create timer for launch the clean up of workspace ' + include_role: name=systemd-timer + vars: + systemd_timer_name: '{{ gitea_container_cleanup_timer_name }}' + systemd_timer_description: 'Timer to perform clean ' + systemd_timer_dynamic_user: true + systemd_timer_frequency: '{{ gitea_container_cleanup_timer_frequency }}' + systemd_timer_timeout_sec: '{{ gitea_container_cleanup_timer_timeout }}' + systemd_timer_work_dir: '{{ gitea_service_path }}' + systemd_timer_requires_extra: 'docker.service' + systemd_timer_start_on_creation: false + systemd_timer_script_path: '{{ gitea_service_path}}/cleanup-registry.py' + systemd_timer_script_args: >- + --url http://localhost:{{ gitea_app_cont_web_port }} + --retention {{ gitea_cleanup_max_retention }} + systemd_timer_environment: + GITEA_USERNAME: '{{ gitea_app_admin_user | mandatory }}' + GITEA_PASSWORD: '{{ gitea_app_admin_pass | mandatory }}' diff --git a/tasks/main.yml b/tasks/main.yml index 463d97c..f5f6edb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,5 +13,5 @@ tags: ['role::gitea', 'role::gitea:consul'] - import_tasks: init-registry.yml tags: ['role::gitea', 'role::gitea:init-registry'] -- import_tasks: purge-registry.yml - tags: ['role::gitea', 'role::gitea:purge-registry'] +- import_tasks: cleanup.yml + tags: ['role::gitea', 'role::gitea:cleanup'] diff --git a/tasks/purge-registry.yml b/tasks/purge-registry.yml deleted file mode 100644 index 39f481b..0000000 --- a/tasks/purge-registry.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- name: Copy init script - template: - src: 'purge-registry.py.j2' - dest: '{{ gitea_service_path }}/purge-registry.py' - owner: '{{ gitea_app_host_uid }}' - group: docker - mode: 0755 - -- name: 'Create timer for launch the clean up of workspace ' - include_role: name=systemd-timer - vars: - systemd_timer_name: '{{ gitea_container_purge_timer_name }}' - systemd_timer_description: 'Timer to perform clean ' - systemd_timer_dynamic_user: true - systemd_timer_frequency: '{{ gitea_container_purge_timer_frequency }}' - systemd_timer_timeout_sec: '{{ gitea_container_purge_timer_timeout }}' - systemd_timer_work_dir: '{{ gitea_service_path }}' - systemd_timer_requires_extra: 'docker.service' - systemd_timer_start_on_creation: false - systemd_timer_script_path: '{{ gitea_service_path}}/purge-registry.py' - systemd_timer_script_args: >- - --url http://localhost:{{ gitea_app_cont_web_port }} - --retention {{ gitea_purge_max_retention }} - systemd_timer_environment: - GITEA_USERNAME: '{{ gitea_app_admin_user | mandatory }}' - GITEA_PASSWORD: '{{ gitea_app_admin_pass | mandatory }}'