From 41973e187dcbd76082d2c64e464718ac5da65318 Mon Sep 17 00:00:00 2001 From: L3D Date: Sun, 29 Oct 2023 14:43:07 +0100 Subject: [PATCH] improve linting and cleanup --- .github/workflows/ansible-linting-check.yml | 2 +- .github/workflows/galaxy.yml | 2 +- .github/workflows/j2lint-check.yml | 2 +- .github/workflows/yamllint-check.yml | 2 +- README.md | 9 +++++++ requirements.yml | 4 +++ tasks/backup.yml | 6 ++--- tasks/configure.yml | 4 +-- tasks/download.yml | 2 +- tasks/filepermissions.yml | 4 +-- tasks/main.yml | 30 ++++++++++++++------- tasks/migrate.yml | 10 +++---- tasks/set_version.yml | 2 +- tasks/versioncheck.yml | 7 +++-- 14 files changed, 54 insertions(+), 32 deletions(-) create mode 100644 requirements.yml diff --git a/.github/workflows/ansible-linting-check.yml b/.github/workflows/ansible-linting-check.yml index 3062a22..1a76d38 100644 --- a/.github/workflows/ansible-linting-check.yml +++ b/.github/workflows/ansible-linting-check.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - name: 'checkout git repo' + - name: Checkout git repo uses: actions/checkout@v4 with: submodules: true diff --git a/.github/workflows/galaxy.yml b/.github/workflows/galaxy.yml index 904bfd9..b44f94e 100644 --- a/.github/workflows/galaxy.yml +++ b/.github/workflows/galaxy.yml @@ -8,7 +8,7 @@ on: jobs: build: - name: Jinja2 Linting + name: Galaxy Role Importer runs-on: ubuntu-latest steps: diff --git a/.github/workflows/j2lint-check.yml b/.github/workflows/j2lint-check.yml index 5037de5..00c7861 100644 --- a/.github/workflows/j2lint-check.yml +++ b/.github/workflows/j2lint-check.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - name: 'checkout git repo' + - name: Checkout git repo uses: actions/checkout@v4 with: submodules: true diff --git a/.github/workflows/yamllint-check.yml b/.github/workflows/yamllint-check.yml index 751e992..5e62f57 100644 --- a/.github/workflows/yamllint-check.yml +++ b/.github/workflows/yamllint-check.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - name: 'checkout git repo' + - name: Checkout git repo uses: actions/checkout@v4 with: submodules: true diff --git a/README.md b/README.md index b6626d8..8837aa1 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,15 @@ By the way, this role requires that the Ansible user be allowed to execute comma submodules_versioncheck: true ``` + +## Requirements +The ``community.general`` collection is required for some parts of this ansible role. +You can install it with this command: +```bash +ansible-galaxy collection install -r requirements.yml --upgrade +``` + + Contributing -------------- Don't hesitate to open a issue or *(even better)* create a pull request. diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..a5a1e10 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: 'community.general' + version: ">=7.5.0,<=8.0.0" diff --git a/tasks/backup.yml b/tasks/backup.yml index b36ce9e..1ff5026 100644 --- a/tasks/backup.yml +++ b/tasks/backup.yml @@ -32,7 +32,7 @@ recurse: true group: "{{ etebase__group }}" owner: "{{ etebase__user }}" - with_items: + loop: - "{{ etebase__backup_destionation }}" - "{{ etebase__current_backup_destination }}" @@ -59,7 +59,7 @@ recurse: true group: "{{ etebase__group }}" owner: "{{ etebase__user }}" - with_items: + loop: - "{{ etebase__current_backup_destination }}" - name: Backup static root dir @@ -84,7 +84,7 @@ dest: "{{ etebase__current_backup_destination }}" remote_src: true - - name: Create bz2 archive of backup + - name: Create bz2 archive of backup # noqa: H1901 become: true community.general.archive: mode: 0640 diff --git a/tasks/configure.yml b/tasks/configure.yml index 30ac964..e256209 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -18,7 +18,7 @@ owner: "{{ etebase__user }}" recurse: true mode: 'u=rwX,g=rX,o=rX' - with_items: + loop: - "{{ etebase__global_static_root }}" - name: "Create media data directorys" @@ -30,7 +30,7 @@ owner: "{{ etebase__user }}" recurse: true mode: 'u=rwX,g=rX,o=' - with_items: + loop: - "{{ etebase__global_media_root }}" - "{{ etebase__secrets_dir }}" diff --git a/tasks/download.yml b/tasks/download.yml index 0d8d0e1..8cb93a3 100644 --- a/tasks/download.yml +++ b/tasks/download.yml @@ -1,5 +1,5 @@ --- -- name: Set git configuration for safe.directory +- name: Set git configuration for safe.directory # noqa: H1901 community.general.git_config: scope: global name: safe.directory diff --git a/tasks/filepermissions.yml b/tasks/filepermissions.yml index ba0b9eb..49e166f 100644 --- a/tasks/filepermissions.yml +++ b/tasks/filepermissions.yml @@ -8,7 +8,7 @@ owner: "{{ etebase__user }}" recurse: true mode: 'u=rwX,g=rX,o=rX' - with_items: + loop: - "{{ etebase__global_static_root }}" notify: - "Systemctl restart etebase.service" @@ -23,7 +23,7 @@ owner: "{{ etebase__user }}" recurse: true mode: 'u=rwX,g=rX,o=' - with_items: + loop: - "{{ etebase__global_media_root }}" - "{{ etebase__secrets_dir }}" - "{{ etebase__venv }}" diff --git a/tasks/main.yml b/tasks/main.yml index d21e151..b07cabc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,33 +1,43 @@ --- - name: Run optional versionscheck - ansible.builtin.include_tasks: versioncheck.yml + ansible.builtin.include_tasks: + file: 'versioncheck.yml' when: submodules_versioncheck | bool - name: Create Etebase User/Group - ansible.builtin.include_tasks: create_user.yml + ansible.builtin.include_tasks: + file: 'create_user.yml' - name: Define Etebase Version - ansible.builtin.include_tasks: set_version.yml + ansible.builtin.include_tasks: + file: 'set_version.yml' - name: Run optional etebase backup - ansible.builtin.include_tasks: backup.yml + ansible.builtin.include_tasks: + file: 'backup.yml' when: etebase__create_backup | bool - name: Download Etebase Repo - ansible.builtin.include_tasks: download.yml + ansible.builtin.include_tasks: + file: 'download.yml' - name: Setup Virtualenv and install Requirements - ansible.builtin.include_tasks: python_venv.yml + ansible.builtin.include_tasks: + file: 'python_venv.yml' - name: Create Etebase Config - ansible.builtin.include_tasks: configure.yml + ansible.builtin.include_tasks: + file: 'configure.yml' - name: Run ./manage.py migrate - ansible.builtin.include_tasks: migrate.yml + ansible.builtin.include_tasks: + file: 'migrate.yml' - name: Setup Systemd Service - ansible.builtin.include_tasks: systemd.yml + ansible.builtin.include_tasks: + file: 'systemd.yml' when: etebase__systemd_setup | bool - name: Cleanup file permissions - ansible.builtin.include_tasks: filepermissions.yml + ansible.builtin.include_tasks: + file: 'filepermissions.yml' diff --git a/tasks/migrate.yml b/tasks/migrate.yml index 975f40c..afca038 100644 --- a/tasks/migrate.yml +++ b/tasks/migrate.yml @@ -7,7 +7,7 @@ changed_when: _etebase_download.changed or _etebase_config.changed register: _etebase_migrate -- name: Print output of python3 manage.py migrate +- name: Print output of python3 manage.py migrate # noqa: H500 ansible.builtin.debug: verbosity: 1 msg: "{{ _etebase_migrate.stdout }}" @@ -23,7 +23,7 @@ - "Systemctl restart etebase.service" - "Systemctl restart webserver" -- name: Print output of python3 manage.py collectstatic +- name: Print output of python3 manage.py collectstatic # noqa: H500 ansible.builtin.debug: verbosity: 1 msg: "{{ _etebase_collectstatic.stdout }}" @@ -37,7 +37,7 @@ owner: "{{ etebase__user }}" recurse: true mode: 'u=rwX,g=rX,o=' - with_items: + loop: - "{{ etebase__secrets_dir }}" - name: "Fix File Permissions for static data directory" @@ -49,10 +49,10 @@ owner: "{{ etebase__user }}" recurse: true mode: 'u=rwX,g=rX,o=rX' - with_items: + loop: - "{{ etebase__global_static_root }}" -- name: Print hint how to create admin User +- name: Print hint how to create admin User # noqa: H500 ansible.builtin.debug: # yamllint disable-line rule:line-length msg: "To create a admin user, run 'cd {{ etebase__user_home }}/etebase_{{ etebase_version_target }}; source {{ etebase__venv }}/bin/activate; python3 ./manage.py createsuperuser' as priviledged user." diff --git a/tasks/set_version.yml b/tasks/set_version.yml index 469ed9a..ead7fd1 100644 --- a/tasks/set_version.yml +++ b/tasks/set_version.yml @@ -39,7 +39,7 @@ etebase_version_target: "{{ etebase__version }}" when: etebase__version != "latest" -- name: Print Etebase Version +- name: Print Etebase Version # noqa: H500 ansible.builtin.debug: verbosity: 1 msg: "etebase version is set to {{ etebase_version_target }}" diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index accace1..7dd80c5 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -7,7 +7,7 @@ ansible.builtin.file: path: '/etc/.ansible-version' state: directory - mode: "0755" + mode: '0755' when: submodules_versioncheck | bool - name: Check playbook version @@ -16,15 +16,14 @@ src: "/etc/.ansible-version/{{ playbook_version_path }}" register: playbook_version when: submodules_versioncheck | bool - ignore_errors: true failed_when: false -- name: Print remote role version +- name: Print remote role version # noqa: H500 ansible.builtin.debug: msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" when: submodules_versioncheck | bool -- name: Print locale role version +- name: Print locale role version # noqa: H500 ansible.builtin.debug: msg: "Local role version: '{{ playbook_version_number | string }}'." when: submodules_versioncheck | bool