Skip to content

Commit

Permalink
Merge pull request #19 from roles-ansible/f
Browse files Browse the repository at this point in the history
improve linting and adding requirements
  • Loading branch information
DO1JLR committed Oct 28, 2023
2 parents 6a46e87 + cce2f3f commit 3c16e7d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 16 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
4 changes: 4 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
collections:
- name: 'community.general'
version: ">=7.5.0,<=8.0.0"
4 changes: 2 additions & 2 deletions tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -67,7 +67,7 @@
mode: 0750
owner: "{{ i3wm_usr.user }}"
group: "{{ i3wm_usr.user }}"
with_items:
loop:
- 'volume.sh'
- 'wlan.py'
- 'battery.py'
Expand Down
18 changes: 12 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions tasks/variables.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 5 additions & 6 deletions tasks/versioncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3c16e7d

Please sign in to comment.