--- - name: Prepare base folder file: path: "{{ gitea_base_dir }}" state: directory owner: "{{ gitea_user }}" group: "{{ gitea_user }}" mode: 0750 become: True become_user: root - block: - name: Prepare folder structure file: path: "{{ item }}" state: directory with_items: - "{{ gitea_bin_dir }}" - "{{ gitea_config_dir }}" - "{{ gitea_data_dir }}" - "{{ gitea_global_log_dir }}" - name: Download Gitea binary get_url: url: "https://dl.gitea.io/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-amd64" dest: "{{ gitea_bin_dir }}/gitea-{{ gitea_version }}" mode: 0750 - name: Link Version {{ gitea_version }} to latest file: src: "{{ gitea_bin_dir }}/gitea-{{ gitea_version }}" dest: "{{ gitea_base_dir }}/gitea-latest" state: link # - name: Register current INTERNAL_TOKEN # shell: "awk -F '=' '/INTERNAL_TOKEN/ {print $2}' {{ gitea_config_dir }}/app.ini | tr -d ' '" # register: internal_token # changed_when: False # - name: Remove INTERNAL_TOKEN # ini_file: # path: "{{ gitea_config_dir }}/app.ini" # section: security # option: INTERNAL_TOKEN # state: absent # changed_when: False - name: Copy config file template: src: "custom/conf/app.ini.j2" dest: "{{ gitea_config_dir }}/app.ini" mode: 0600 notify: __gitea_restart register: add_config # - name: Re-add INTERNAL_TOKEN if configuration not changed # ini_file: # path: "{{ gitea_config_dir }}/app.ini" # section: security # option: INTERNAL_TOKEN # value: "{{ internal_token.stdout }}" # changed_when: False # when: not add_config.changed # - name: Copy env file # template: # src: "custom/conf/gitea.env.j2" # dest: "{{ gitea_config_dir }}/gitea.env" # notify: # - gitea_restart become: True become_user: "{{ gitea_user }}" when: gitea_installed.stat.exists == False or gitea_current.stdout is version_compare(gitea_version, operator='<=', strict=True) - name: Copy systemd unit file template: src: "etc/systemd/system/gitea.service.j2" dest: "/etc/systemd/system/gitea.service" notify: __gitea_restart become: True become_user: root