configs/roles/config/tasks/main.yml
2024-10-16 08:21:55 +02:00

302 lines
6.3 KiB
YAML

---
- name: Gather the package facts
ansible.builtin.package_facts:
tags: always
- name: Create backup structure
ansible.builtin.file:
path: "~/old_dat"
state: "directory"
tags: config
- name: Copy files to backup
ansible.builtin.copy:
src: "~/{{ item }}"
dest: "~/old_dat/"
remote_src: true
loop:
- ".config"
- ".local/share/applications"
- ".mozilla"
- ".ssh"
- "scripts"
ignore_errors: true
tags: config
- name: Remove old/unnecessary files and directories
ansible.builtin.file:
path: "{{ item }}"
state: "absent"
loop:
- "~/.emacs.d"
- "~/scripts"
tags: config
- name: Copy new files and directories
ansible.posix.synchronize:
src: "{{ item }}"
dest: "~/"
owner: false
group: false
loop:
- ".config"
- ".face"
- ".fonts"
- ".gitconfig"
- ".gtkrc-2.0"
- ".local"
- ".themes"
- "scripts"
tags: config
- name: Copy new templated files
ansible.builtin.template:
src: "{{ item }}"
dest: "~/"
loop:
- ".ssh/config.j2"
tags: config
- name: Copy new files and directories (root)
ansible.posix.synchronize:
src: "{{ item }}"
dest: "/"
owner: false
group: false
loop:
- "etc"
- "usr"
become: true
tags: config
- name: Copy config for SDDM (root)
ansible.builtin.copy:
src: "{{ ansible_env['HOME'] }}/{{ item }}"
dest: "/var/lib/sddm/.config/"
owner: sddm
group: sddm
remote_src: true
loop:
- ".config/kwinoutputconfig.json"
- ".config/kcminputrc"
become: true
tags: config
- name: x86_64 | Copy files (root)
ansible.builtin.copy:
src: "{{ item }}"
dest: "/etc/pacman.conf"
loop:
- "etc/pacman-x86_64.conf"
when: ansible_architecture == "x86_64"
become: true
tags: config
- name: Symlink xdg environment variables
ansible.builtin.file:
src: "~/.config/user-dirs.dirs"
dest: "~/.config/environment.d/user-dirs.dirs.conf"
state: "link"
tags: config
- name: Bash cat | Download
ansible.builtin.git:
repo: https://github.com/exu-g/bash-cat-with-cat.git
dest: "/tmp/bash-cat-with-cat"
tags: config
- name: Bash cat | Copy to scripts
ansible.builtin.copy:
src: "/tmp/bash-cat-with-cat/cat.sh"
dest: "~/scripts/pieces/cat.sh"
mode: "0755"
tags: config
- name: Reload system systemd services
ansible.builtin.systemd_service:
daemon_reload: true
become: true
tags: services
- name: Reload user systemd services
ansible.builtin.systemd_service:
daemon_reload: true
scope: user
tags: services
- name: Enable system services
ansible.builtin.systemd_service:
name: "{{ item }}"
state: "started"
enabled: true
loop:
- "fstrim.timer"
- "bluetooth.service"
- "sddm.service"
become: true
tags: services
- name: Enable user services
ansible.builtin.systemd_service:
name: "{{ item }}"
state: "restarted"
enabled: true
scope: user
loop:
- "ssh-agent.service"
tags: services
- name: Start system services
ansible.builtin.systemd_service:
name: "{{ item }}"
state: "started"
enabled: true
loop:
- "fstrim.timer"
- "bluetooth.service"
become: true
tags: services
- name: Enable zram generator
ansible.builtin.systemd_service:
name: "systemd-zram-setup@zram0.service"
state: "started"
enabled: true
when:
- ('zram-generator' in ansible_facts.packages)
- ('zswap.enabled=0' in lookup('ansible.builtin.file', '/proc/cmdline'))
become: true
tags: services
- name: Enable btrfsmaintenance timers
ansible.builtin.systemd_service:
name: "{{ item }}"
enabled: true
loop:
- "btrfs-balance.timer"
- "btrfs-scrub.timer"
when: ('btrfsmaintenance' in ansible_facts.packages)
become: true
tags: services
- name: Enable btrfsmaintenance services
ansible.builtin.systemd_service:
name: "{{ item }}"
state: "restarted"
loop:
- "btrfsmaintenance-refresh.service"
when: ('btrfsmaintenance' in ansible_facts.packages)
become: true
tags: services
- name: Enable reflector
ansible.builtin.systemd_service:
name: "{{ item }}"
enabled: true
loop:
- "reflector.timer"
when: ('reflector' in ansible_facts.packages)
become: true
tags: services
- name: Enable NTP
ansible.builtin.command: timedatectl set-ntp true
become: true
tags: services
- name: Add group for libvirt
ansible.builtin.user:
name: "{{ ansible_user_id }}"
groups:
- libvirt
append: true
when: ('libvirt' in ansible_facts.packages)
become: true
tags: config
- name: Enable libvirt socket
ansible.builtin.systemd_service:
name: "libvirtd.socket"
state: "started"
enabled: true
when: ('libvirt' in ansible_facts.packages)
become: true
tags: services
- name: Create groups
ansible.builtin.group:
name: "{{ item }}"
state: present
loop:
- video # backlight
- render # GPU passing
- wireguard # wireguard
become: true
tags: config
- name: Set fish for user
ansible.builtin.user:
name: "{{ ansible_user_id }}"
shell: "/usr/bin/fish"
become: true
tags: config
- name: Set fish for root
ansible.builtin.user:
name: "root"
shell: "/usr/bin/fish"
become: true
tags: config
- name: Add user to groups
ansible.builtin.user:
name: "{{ ansible_user_id }}"
groups:
- video # backlight
- render # GPU passing
- wireguard # wireguard
append: true
become: true
tags: config
- name: Set sudoers.d permissions
ansible.builtin.file:
path: /etc/sudoers.d
mode: "600"
owner: root
group: root
recurse: true
become: true
tags: config
- name: Make scripts executable
ansible.builtin.file:
path: "{{ item }}"
mode: u+x,g+x,o+x
recurse: true
loop:
- "~/scripts"
- "~/.local/share/applications/*.desktop"
tags: config
- name: Reload applications
ansible.builtin.shell:
cmd: "update-desktop-database ~/.local/share/applications/"
tags: config
- name: Doom Emacs | Check if installed
ansible.builtin.stat:
path: "~/.config/emacs/bin/doom"
register: doom_emacs
tags: config
- name: Doom Emacs | Update if present
ansible.builtin.shell:
cmd: "~/.config/emacs/bin/doom sync"
when: doom_emacs.stat.exists
tags: config
- name: Include Tasks from plasma.yml
ansible.builtin.import_tasks:
file: plasma.yml