From f9757b897b3cafcae800597783c597484511bd04 Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Wed, 8 May 2024 02:22:00 +0200 Subject: [PATCH] Small tasks refactoring --- localhost.yml | 1 + roles/desktop/tasks/arch.yml | 25 ++----------------------- roles/desktop/tasks/audio.yml | 3 ++- roles/desktop/tasks/bluetooth.yml | 5 +++-- roles/desktop/tasks/flatpaks.yml | 14 ++++++++++++++ roles/desktop/tasks/main.yml | 7 +++++++ roles/desktop/tasks/timekpr.yml | 23 ++++++++++++----------- roles/desktop/tasks/ubuntu.yml | 14 ++++---------- roles/dev-java/tasks/arch.yml | 6 +++--- roles/lightdm/tasks/arch.yml | 6 ++++++ roles/lightdm/tasks/main.yml | 6 ++++++ roles/postinstall/tasks/main.yml | 6 ++++++ 12 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 roles/desktop/tasks/flatpaks.yml create mode 100644 roles/lightdm/tasks/arch.yml create mode 100644 roles/lightdm/tasks/main.yml create mode 100644 roles/postinstall/tasks/main.yml diff --git a/localhost.yml b/localhost.yml index 280b22f..bda7b9f 100644 --- a/localhost.yml +++ b/localhost.yml @@ -18,6 +18,7 @@ # - dev-flutter # - virtual # - terraform + - postinstall vars: desktop_src_dir: "{{ ansible_user_dir }}/src/desktop" arch_src_dir: "{{ ansible_user_dir }}/src/arch" diff --git a/roles/desktop/tasks/arch.yml b/roles/desktop/tasks/arch.yml index 689301a..586ce6e 100644 --- a/roles/desktop/tasks/arch.yml +++ b/roles/desktop/tasks/arch.yml @@ -10,17 +10,9 @@ - grub - xorg-xinit - polkit-gnome - - lightdm - - lightdm-gtk-greeter + - xdg-desktop-portal-gtk - helvum -- name: "Enable service" - become: yes - ansible.builtin.systemd: - name: lightdm - state: started - enabled: yes - - name: "Enable cron service" become: yes ansible.builtin.systemd: @@ -49,7 +41,7 @@ - traceroute - vim -- name: install terminal packages [AUR] +- name: "[Arch] install terminal packages" shell: cmd: yay -S --needed --noconfirm epson-inkjet-printer-escpr pm-utils @@ -103,16 +95,6 @@ name: - flatpak -- name: install the smile emoji picker - community.general.flatpak: - state: present - name: it.mijorus.smile - -- name: install bottles - community.general.flatpak: - state: present - name: com.usebottles.bottles - - name: copy scripts become: yes copy: @@ -121,6 +103,3 @@ mode: '0755' loop: - update-grub - -- import_tasks: audio.yml -- import_tasks: bluetooth.yml diff --git a/roles/desktop/tasks/audio.yml b/roles/desktop/tasks/audio.yml index b7ed8df..11fabcb 100644 --- a/roles/desktop/tasks/audio.yml +++ b/roles/desktop/tasks/audio.yml @@ -1,4 +1,5 @@ -- name: install audio [Arch] +- name: "[Arch] install audio" + when: ansible_distribution == "Archlinux" become: yes community.general.pacman: name: diff --git a/roles/desktop/tasks/bluetooth.yml b/roles/desktop/tasks/bluetooth.yml index 286fc89..c4de77a 100644 --- a/roles/desktop/tasks/bluetooth.yml +++ b/roles/desktop/tasks/bluetooth.yml @@ -1,10 +1,11 @@ -- name: install bluetooth +- name: "[Arch] install bluetooth" + when: ansible_distribution == "Archlinux" become: yes community.general.pacman: name: - blueman -- name: "Enable service" +- name: "[All] Enable service" become: yes ansible.builtin.systemd: name: bluetooth diff --git a/roles/desktop/tasks/flatpaks.yml b/roles/desktop/tasks/flatpaks.yml new file mode 100644 index 0000000..2738e21 --- /dev/null +++ b/roles/desktop/tasks/flatpaks.yml @@ -0,0 +1,14 @@ +- name: "[All] install the smile emoji picker" + community.general.flatpak: + state: present + name: it.mijorus.smile + +- name: "[All] install bottles" + community.general.flatpak: + state: present + name: com.usebottles.bottles + +- name: "[All] install Element" + community.general.flatpak: + state: present + name: im.riot.Riot diff --git a/roles/desktop/tasks/main.yml b/roles/desktop/tasks/main.yml index 9df85b3..9153720 100644 --- a/roles/desktop/tasks/main.yml +++ b/roles/desktop/tasks/main.yml @@ -5,7 +5,14 @@ - import_tasks: arch.yml when: ansible_distribution == "Archlinux" +- import_tasks: flatpaks.yml + +- import_tasks: audio.yml + +- import_tasks: bluetooth.yml + - import_tasks: dotfiles.yml + - import_tasks: signal.yml - import_tasks: timekpr.yml diff --git a/roles/desktop/tasks/timekpr.yml b/roles/desktop/tasks/timekpr.yml index e9cdd49..d048690 100644 --- a/roles/desktop/tasks/timekpr.yml +++ b/roles/desktop/tasks/timekpr.yml @@ -1,32 +1,33 @@ - become: yes + when: ansible_distribution == "Ubuntu" block: - - name: add ppa [Ubuntu] - when: ansible_distribution == "Ubuntu" + - name: "[Ubuntu] add ppa" apt_repository: repo: ppa:mjasnik/ppa - - name: install timekpr [Ubuntu] - when: ansible_distribution == "Ubuntu" + - name: "[Ubuntu] install timekpr" apt: update_cache: yes state: latest pkg: - timekpr-next - - name: install timekpr [Arch] - shell: - cmd: - yay -S --needed --noconfirm timekpr-next - when: ansible_distribution == "Archlinux" +- name: "[Arch] install timekpr" + shell: + cmd: + yay -S --needed --noconfirm timekpr-next + when: ansible_distribution == "Archlinux" - - name: configure +- become: yes + block: + - name: "[All] configure" template: src: var/lib/timekpr/config/timekpr.USER.conf.j2 dest: /var/lib/timekpr/config/timekpr.{{ansible_user_id}}.conf vars: user: "{{ ansible_user_id }}" - - name: "Enable service" + - name: "[All] Enable service" become: yes ansible.builtin.systemd: name: timekpr diff --git a/roles/desktop/tasks/ubuntu.yml b/roles/desktop/tasks/ubuntu.yml index 294b8cc..16b8ce6 100644 --- a/roles/desktop/tasks/ubuntu.yml +++ b/roles/desktop/tasks/ubuntu.yml @@ -1,5 +1,4 @@ ---- -- name: install package managers +- name: "[Ubuntu] install package managers" become: yes apt: update_cache: yes @@ -7,7 +6,7 @@ - aptitude - flatpak -- name: install terminal packages +- name: "[Ubuntu] install terminal packages" become: yes apt: pkg: @@ -26,13 +25,13 @@ - policykit-1-gnome - printer-driver-escpr -- name: install libfuse2 for appimages +- name: "[Ubuntu] install libfuse2 for appimages" become: yes apt: pkg: - libfuse2 -- name: install gui packages from apt +- name: "[Ubuntu] install gui packages from apt" become: yes apt: pkg: @@ -44,11 +43,6 @@ - flameshot - gsimplecal -- name: install the smile emoji picker - community.general.flatpak: - state: present - name: it.mijorus.smile - - name: install gui apps become: yes apt: diff --git a/roles/dev-java/tasks/arch.yml b/roles/dev-java/tasks/arch.yml index efc1103..3b87fd8 100644 --- a/roles/dev-java/tasks/arch.yml +++ b/roles/dev-java/tasks/arch.yml @@ -1,15 +1,15 @@ -- name: install java +- name: "[Arch] install java" become: yes community.general.pacman: name: - jdk17-openjdk -- name: install IntelliJ [AUR] +- name: "[Arch] install IntelliJ" shell: cmd: yay -S --needed --noconfirm intellij-idea-ultimate-edition -- name: Create symbolic link +- name: "[Arch] Create symbolic link" become: yes file: src: "/usr/bin/intellij-idea-ultimate-edition" diff --git a/roles/lightdm/tasks/arch.yml b/roles/lightdm/tasks/arch.yml new file mode 100644 index 0000000..511fe48 --- /dev/null +++ b/roles/lightdm/tasks/arch.yml @@ -0,0 +1,6 @@ +- name: "[Arch] install lightdm" + become: yes + community.general.pacman: + name: + - lightdm + - lightdm-gtk-greeter diff --git a/roles/lightdm/tasks/main.yml b/roles/lightdm/tasks/main.yml new file mode 100644 index 0000000..97284fc --- /dev/null +++ b/roles/lightdm/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- import_tasks: ubuntu.yml + when: ansible_distribution == "Ubuntu" + +- import_tasks: arch.yml + when: ansible_distribution == "Archlinux" diff --git a/roles/postinstall/tasks/main.yml b/roles/postinstall/tasks/main.yml new file mode 100644 index 0000000..81823cd --- /dev/null +++ b/roles/postinstall/tasks/main.yml @@ -0,0 +1,6 @@ +- name: "[All] Enable lightdm service" + become: yes + ansible.builtin.systemd: + name: lightdm + state: started + enabled: yes