From 6096767d26c10d277a54caafc8dde0b833d1d613 Mon Sep 17 00:00:00 2001 From: L3D Date: Mon, 22 Mar 2021 21:08:40 +0100 Subject: [PATCH] simplify directory handling and start using new ansible name scheme --- tasks/directory.yml | 18 +++++++++++++++++ tasks/main.yml | 48 +++++++++------------------------------------ vars/main.yml | 10 ++++++++++ 3 files changed, 37 insertions(+), 39 deletions(-) create mode 100644 tasks/directory.yml diff --git a/tasks/directory.yml b/tasks/directory.yml new file mode 100644 index 0000000..a684bb2 --- /dev/null +++ b/tasks/directory.yml @@ -0,0 +1,18 @@ +--- +- name: "Create config and data directory" + ansible.builtin.file: + path: "{{ item }}" + state: directory + owner: "{{ gitea_user }}" + group: "{{ gitea_group }}" + mode: 'u=rwX,g=rX,o=' + with_items: + - "/etc/gitea" + - "{{ gitea_home }}" + - "{{ gitea_home }}/data" + - "{{ gitea_home }}/custom" + - "{{ gitea_home }}/custom/https" + - "{{ gitea_home }}/custom/mailer" + - "{{ gitea_home }}/indexers" + - "{{ gitea_home }}/log" + - "{{ gitea_repository_root }}" diff --git a/tasks/main.yml b/tasks/main.yml index e62be44..0dfaba0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,16 +4,10 @@ when: submodules_versioncheck|bool - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}.yml" + ansible.builtin.include_vars: "{{ lookup('first_found', gitea_variables) }}" - name: "Check gitea version" - shell: "set -eo pipefail; /usr/local/bin/gitea -v | cut -d' ' -f 3" + ansible.builtin.shell: "set -eo pipefail; /usr/local/bin/gitea -v | cut -d' ' -f 3" args: executable: /bin/bash register: gitea_active_version @@ -22,41 +16,17 @@ when: gitea_version_check|bool - name: backup gitea before update - include_tasks: backup.yml + ansible.builtin.include_tasks: backup.yml when: gitea_backup_on_upgrade|bool +- name: create gitea user and role + ansible.builtin.include_tasks: create_user.yml + - name: install or update gitea - include_tasks: install.yml + ansible.builtin.include_tasks: install.yml -- include: create_user.yml - -- name: "Create config directory" - file: - path: "{{ item }}" - state: directory - owner: "{{ gitea_user }}" - group: "{{ gitea_group }}" - mode: '0755' - with_items: - - "/etc/gitea" - -- name: "Create data directory" - file: - path: "{{ item }}" - state: directory - owner: "{{ gitea_user }}" - group: "{{ gitea_group }}" - mode: 'u=rwX,g=rX,o=' - recurse: true - with_items: - - "{{ gitea_home }}" - - "{{ gitea_home }}/data" - - "{{ gitea_home }}/custom" - - "{{ gitea_home }}/custom/https" - - "{{ gitea_home }}/custom/mailer" - - "{{ gitea_home }}/indexers" - - "{{ gitea_home }}/log" - - "{{ gitea_repository_root }}" +- name: Create directorys + ansible.builtin.include_tasks: directory.yml - include: install_systemd.yml when: ansible_service_mgr == "systemd" diff --git a/vars/main.yml b/vars/main.yml index 217afb2..775aca8 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -9,5 +9,15 @@ gitea_go_arch_map: gitea_arch: "{{ gitea_go_arch_map[ansible_architecture] | default(ansible_architecture) }}" +gitea_variables: + files: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + paths: + - 'vars' + playbook_version_number: 6 # should be int playbook_version_path: 'do1jlr.gitea.version'