diff --git a/meta/main.yml b/meta/main.yml index dbf92f8..c23216d 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,24 +1,24 @@ --- galaxy_info: role_name: i3wm - author: do1jlr + author: l3d description: Install and configure i3wm on common linux distibutions (https://i3wm.org/) license: "MIT" - min_ansible_version: 2.11 + min_ansible_version: '2.13' github_branch: main platforms: - - name: Archlinux - versions: all + - name: ArchLinux + versions: ['all'] - name: Debian - versions: all + versions: ['all'] - name: Ubuntu - versions: all + versions: ['all'] - name: Fedora - versions: all + versions: ['all'] galaxy_tags: - i3wm - desktop - linux - xorg - - wayland + - linux dependencies: [] diff --git a/tasks/config.yml b/tasks/config.yml index 78cdec0..c1ce8c4 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -8,7 +8,7 @@ owner: "{{ i3wm_user }}" group: "{{ i3wm_user }}" -- name: create i3 config folder +- name: Create i3 config folder become: true ansible.builtin.file: path: '/home/{{ i3wm_user }}/.config/i3/' @@ -17,7 +17,7 @@ owner: "{{ i3wm_user }}" group: "{{ i3wm_user }}" -- name: copy multiple images +- name: Copy multiple images ansible.builtin.copy: src: "{{ item.src }}" dest: "{{ item.dest }}" @@ -29,7 +29,7 @@ - { src: 'files/lockscreen.png', dest: '/home/{{ i3wm_user }}/.config/lockscreen.png' } when: i3wm_copy_wallpapers | bool -- name: copy and validate i3wm config file +- name: Copy and validate i3wm config file become: true ansible.builtin.template: src: templates/config.j2 @@ -41,7 +41,7 @@ group: "{{ i3wm_user }}" # todo: rewrite user stuff and support multiple users -- name: mkdir ~/.config/i3blocks/ +- name: Mkdir ~/.config/i3blocks/ become: true ansible.builtin.file: path: "/home/{{ i3wm_user }}/.config/i3blocks/" @@ -50,7 +50,7 @@ owner: "{{ i3wm_user }}" group: "{{ i3wm_user }}" -- name: copy i3blocks config +- name: Copy i3blocks config become: true ansible.builtin.copy: src: "files/i3blocks/config" @@ -59,7 +59,7 @@ owner: "{{ i3wm_user }}" group: "{{ i3wm_user }}" -- name: copy i3blocks config +- name: Copy i3blocks config become: true ansible.builtin.copy: src: "files/i3blocks/{{ item }}" diff --git a/tasks/main.yml b/tasks/main.yml index 5d4181d..585b686 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,22 +1,22 @@ --- -- name: run optional versionscheck +- name: Run optional versionscheck ansible.builtin.include_tasks: versioncheck.yml - when: submodules_versioncheck|bool + when: submodules_versionchecki | bool -- name: register variables +- name: Register variables ansible.builtin.import_tasks: variables.yml -- name: ensure i3 packages are installed [Debian] +- name: Ensure i3 packages are installed [Debian] ansible.builtin.include_tasks: setup-Debian.yml when: ansible_os_family == 'Debian' -- name: ensure i3 packages are installed [Archlinux} +- name: Ensure i3 packages are installed [Archlinux} ansible.builtin.include_tasks: setup-Archlinux.yml when: ansible_os_family == 'Archlinux' -- name: ensure i3 packages are installed [RHEL]. +- name: Ensure i3 packages are installed [RHEL]. ansible.builtin.include_tasks: setup-RedHat.yml when: ansible_os_family == 'Fedora' or ansible_os_family == 'RedHat' -- name: create i3 config file +- name: Create i3 config file ansible.builtin.include_tasks: config.yml diff --git a/tasks/setup-Archlinux.yml b/tasks/setup-Archlinux.yml index 6fa8068..2b65c7c 100644 --- a/tasks/setup-Archlinux.yml +++ b/tasks/setup-Archlinux.yml @@ -1,6 +1,6 @@ --- -- name: ensure i3 packages are installed. - ansible.builtin.pacman: +- name: Ensure i3 packages are installed. + community.general.pacman: name: "{{ i3_packages }}" state: present update_cache: true diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index cd5dec9..4170cbf 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -1,5 +1,13 @@ --- -- name: ensure i3 packages are installed. +- name: Update apt cache + become: true + ansible.builtin.apt: + cache_valid_time: 3600 + update_cache: true + when: + - ansible_pkg_mgr == "apt" + +- name: Ensure i3 packages are installed. ansible.builtin.apt: name: "{{ i3_packages }}" state: "present" diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index a629e80..f49b70f 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -1,5 +1,5 @@ --- -- name: ensure i3 packages are installed. +- name: Ensure i3 packages are installed. ansible.builtin.dnf: name: "{{ i3_packages }}" state: present diff --git a/tasks/variables.yml b/tasks/variables.yml index 7896d1c..856b0fe 100644 --- a/tasks/variables.yml +++ b/tasks/variables.yml @@ -1,45 +1,42 @@ --- -- name: register os-specific variables +- name: Register OS-specific Variables ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" when: ansible_distribution != "Fedora" -- name: register Fedora variables +- name: Register Fedora-specific variables ansible.builtin.include_vars: "{{ ansible_distribution }}.yml" when: ansible_distribution == "Fedora" -# i3 packages -- name: define i3_packages +- name: Define i3_packages ansible.builtin.set_fact: i3_packages: "{{ __i3_packages | list }}" when: i3_packages is not defined -- name: define i3_packages_extra +- name: Define i3_packages_extra ansible.builtin.set_fact: i3_packages: "{{ i3_packages | list + i3_packages_extra | list }}" when: i3_packages_extra is defined -# i3 workspaces -- name: define i3_packages +- name: Define i3_packages ansible.builtin.set_fact: i3_workspaces: "{{ __i3_workspaces | list }}" when: i3_workspaces is not defined -# i3 keybindings -- name: define i3_packages +- name: Define i3_keybindings ansible.builtin.set_fact: i3_keybindings: "{{ __i3_keybindings | list }}" when: - i3_keybindings is not defined - __i3_keybindings is defined -- name: define extra i3 keybindings +- name: Define additional i3 keybindings ansible.builtin.set_fact: i3_keybindings: "{{ i3_keybindings_extra | list + i3_keybindings | list }}" when: - i3_keybindings_extra is defined - i3_keybindings is defined -- name: define extra i3 keybindings +- name: Finalize i3 keybindings definition ansible.builtin.set_fact: i3_keybindings: "{{ i3_keybindings_extra | list }}" when: diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index 5128cc8..62687e5 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -8,37 +8,38 @@ path: '/etc/.ansible-version' state: directory mode: 0755 - when: submodules_versioncheck|bool + when: submodules_versioncheck | bool -- name: check playbook version +- name: Check playbook version become: true ansible.builtin.slurp: src: "/etc/.ansible-version/{{ playbook_version_path }}" - register: playbook_version - when: submodules_versioncheck|bool + register: i3wm_playbook_version + when: submodules_versioncheck | bool ignore_errors: true failed_when: false - name: Print remote role version ansible.builtin.debug: - msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" - when: submodules_versioncheck|bool + msg: "Remote role version: {{ i3wm_playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" + when: submodules_versioncheck | bool - name: Print locale role version ansible.builtin.debug: - msg: "Local role version: '{{ playbook_version_number|string }}'." - when: submodules_versioncheck|bool + msg: "Local role version: '{{ playbook_version_number | string }}'." + when: submodules_versioncheck | bool - name: Check if your version is outdated ansible.builtin.fail: msg: "Your ansible module has the version '{{ playbook_version_number }}' and is outdated. You need to update it!" when: - - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck|bool + - i3wm_playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck | bool -- name: write new version to remote disk +- name: Write new version to remote disk become: true ansible.builtin.copy: content: "{{ playbook_version_number }}" dest: "/etc/.ansible-version/{{ playbook_version_path }}" mode: '0644' - when: submodules_versioncheck|bool + when: submodules_versioncheck | bool + tags: skip_ansible_lint_template-instead-of-copy diff --git a/vars/main.yml b/vars/main.yml index f28d59c..02ba4b0 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -33,5 +33,5 @@ __i3_workspaces: user: "{{ i3wm_user }}" -playbook_version_number: 9024 # should be int +playbook_version_number: 9025 # should be int playbook_version_path: 'role-i3wm_chaos-bodensee_github.com.version'