From cce2f3f419441e4c4adc4602930c266a036b65e6 Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 28 Oct 2023 16:25:06 +0200 Subject: [PATCH] improve linting and adding requirements --- README.md | 7 +++++++ requirements.yml | 4 ++++ tasks/config.yml | 4 ++-- tasks/main.yml | 18 ++++++++++++------ tasks/variables.yml | 6 ++++-- tasks/versioncheck.yml | 11 +++++------ 6 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 requirements.yml diff --git a/README.md b/README.md index ddf1867..e6170da 100644 --- a/README.md +++ b/README.md @@ -100,3 +100,10 @@ For a good overview about possible variables, please have a look into ``defaults # choose rofi theme i3_rofi_config_file: 'files/rofi/dracula_dark.rasi' ``` + +## 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 +``` 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/config.yml b/tasks/config.yml index 1ae8374..9ceb922 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -25,7 +25,7 @@ mode: 0644 owner: "{{ i3wm_usr.user }}" group: "{{ i3wm_usr.user }}" - with_items: + loop: - { src: 'files/background.png', dest: "{{ i3wm_usr.home }}/.config/background.png" } - { src: 'files/lockscreen.png', dest: '{{ i3wm_usr.home }}/.config/lockscreen.png' } when: i3wm_copy_wallpapers | bool @@ -67,7 +67,7 @@ mode: 0750 owner: "{{ i3wm_usr.user }}" group: "{{ i3wm_usr.user }}" - with_items: + loop: - 'volume.sh' - 'wlan.py' - 'battery.py' diff --git a/tasks/main.yml b/tasks/main.yml index 2598246..c78316c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,25 +1,31 @@ --- - name: Run optional versionscheck - ansible.builtin.include_tasks: versioncheck.yml + ansible.builtin.include_tasks: + file: versioncheck.yml when: submodules_versioncheck | bool - name: Register variables - ansible.builtin.import_tasks: variables.yml + ansible.builtin.import_tasks: + file: variables.yml - name: Ensure i3 packages are installed [Debian] - ansible.builtin.include_tasks: setup-Debian.yml + ansible.builtin.include_tasks: + file: setup-Debian.yml when: ansible_os_family == 'Debian' - name: Ensure i3 packages are installed [Archlinux} - ansible.builtin.include_tasks: setup-Archlinux.yml + ansible.builtin.include_tasks: + file: setup-Archlinux.yml when: ansible_os_family == 'Archlinux' - name: Ensure i3 packages are installed [RHEL]. - ansible.builtin.include_tasks: setup-RedHat.yml + ansible.builtin.include_tasks: + file: setup-RedHat.yml when: ansible_os_family == 'Fedora' or ansible_os_family == 'RedHat' - name: Create i3 config file - ansible.builtin.include_tasks: config.yml + ansible.builtin.include_tasks: + file: config.yml loop: "{{ i3wm_user_list | flatten(1) }}" loop_control: loop_var: i3wm_usr diff --git a/tasks/variables.yml b/tasks/variables.yml index 856b0fe..2cf67dd 100644 --- a/tasks/variables.yml +++ b/tasks/variables.yml @@ -1,10 +1,12 @@ --- - name: Register OS-specific Variables - ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" + ansible.builtin.include_vars: + file: "{{ ansible_os_family }}.yml" when: ansible_distribution != "Fedora" - name: Register Fedora-specific variables - ansible.builtin.include_vars: "{{ ansible_distribution }}.yml" + ansible.builtin.include_vars: + file: "{{ ansible_distribution }}.yml" when: ansible_distribution == "Fedora" - name: Define i3_packages diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index 62687e5..e660e3e 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -14,17 +14,16 @@ become: true ansible.builtin.slurp: src: "/etc/.ansible-version/{{ playbook_version_path }}" - register: i3wm_playbook_version + 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: {{ i3wm_playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" + 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 @@ -33,7 +32,7 @@ ansible.builtin.fail: msg: "Your ansible module has the version '{{ playbook_version_number }}' and is outdated. You need to update it!" when: - - i3wm_playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck | bool + - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck | bool - name: Write new version to remote disk become: true