From 7c1f7039170a25f192d87235476179f7cfe01a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sat, 10 Dec 2022 21:17:16 +0100 Subject: chore: explode workstation role in subroles --- roles/workstation/tasks/cronie.yml | 10 ----- roles/workstation/tasks/doas.yml | 34 --------------- roles/workstation/tasks/dockerd.yml | 28 ------------- roles/workstation/tasks/hosts.yml | 7 ---- roles/workstation/tasks/libvirt.yml | 21 ---------- roles/workstation/tasks/main.yml | 29 ------------- roles/workstation/tasks/os_archlinux.yml | 35 ---------------- roles/workstation/tasks/os_openbsd.yml | 72 -------------------------------- roles/workstation/tasks/pipewire.yml | 22 ---------- roles/workstation/tasks/pkgs.yml | 7 ---- roles/workstation/tasks/shell.yml | 8 ---- roles/workstation/tasks/smartcard.yml | 5 --- roles/workstation/tasks/ssh.yml | 18 -------- roles/workstation/tasks/tlp.yml | 10 ----- roles/workstation/tasks/yay.yml | 20 --------- 15 files changed, 326 deletions(-) delete mode 100644 roles/workstation/tasks/cronie.yml delete mode 100644 roles/workstation/tasks/doas.yml delete mode 100644 roles/workstation/tasks/dockerd.yml delete mode 100644 roles/workstation/tasks/hosts.yml delete mode 100644 roles/workstation/tasks/libvirt.yml delete mode 100644 roles/workstation/tasks/main.yml delete mode 100644 roles/workstation/tasks/os_archlinux.yml delete mode 100644 roles/workstation/tasks/os_openbsd.yml delete mode 100644 roles/workstation/tasks/pipewire.yml delete mode 100644 roles/workstation/tasks/pkgs.yml delete mode 100644 roles/workstation/tasks/shell.yml delete mode 100644 roles/workstation/tasks/smartcard.yml delete mode 100644 roles/workstation/tasks/ssh.yml delete mode 100644 roles/workstation/tasks/tlp.yml delete mode 100644 roles/workstation/tasks/yay.yml (limited to 'roles/workstation/tasks') diff --git a/roles/workstation/tasks/cronie.yml b/roles/workstation/tasks/cronie.yml deleted file mode 100644 index faa1095..0000000 --- a/roles/workstation/tasks/cronie.yml +++ /dev/null @@ -1,10 +0,0 @@ -- name: install cronie - ansible.builtin.package: - name: cronie - state: present - -- name: enable and restart cronie - ansible.builtin.service: - name: cronie - state: restarted - enabled: true diff --git a/roles/workstation/tasks/doas.yml b/roles/workstation/tasks/doas.yml deleted file mode 100644 index e47fa35..0000000 --- a/roles/workstation/tasks/doas.yml +++ /dev/null @@ -1,34 +0,0 @@ -- name: generate doas configuration - ansible.builtin.lineinfile: - path: /etc/doas.conf - regexp: "^permit persist keepenv {{ workstation_user }} as root" - line: "permit persist keepenv {{ workstation_user }} as root" - create: true - mode: 0644 - owner: 0 - group: 0 - -- name: allow reboot/shutdown/hibernate with doas - ansible.builtin.lineinfile: - path: /etc/doas.conf - regexp: "^permit nopass {{ workstation_user }} as root cmd {{ item }}" - line: "permit nopass {{ workstation_user }} as root cmd {{ item }}" - loop: - - ZZZ - - mount - - reboot - - shutdown - - zzz - -- name: check sudo binary path # noqa no-changed-when - ansible.builtin.command: command -v sudo - register: result - failed_when: false - -- name: uninstall sudo binary - ansible.builtin.package: - name: sudo - state: absent - when: result.rc == 0 - register: sudo - ignore_errors: true diff --git a/roles/workstation/tasks/dockerd.yml b/roles/workstation/tasks/dockerd.yml deleted file mode 100644 index c0dfd33..0000000 --- a/roles/workstation/tasks/dockerd.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: install docker - ansible.builtin.package: - name: - - docker - - docker-compose - state: present - -- name: append current user to docker group - ansible.builtin.user: - name: "{{ workstation_user }}" - groups: "{{ workstation_docker_group }}" - append: true - -- name: create docker directory - ansible.builtin.file: - path: /etc/docker - state: directory - owner: 0 - group: 0 - mode: 0755 - -- name: configure default network for docker containers - ansible.builtin.template: - src: docker-daemon.json.j2 - dest: /etc/docker/daemon.json - owner: 0 - group: 0 - mode: 0600 diff --git a/roles/workstation/tasks/hosts.yml b/roles/workstation/tasks/hosts.yml deleted file mode 100644 index 7cc261a..0000000 --- a/roles/workstation/tasks/hosts.yml +++ /dev/null @@ -1,7 +0,0 @@ -- name: retrieve hosts file - ansible.builtin.get_url: - url: "{{ workstation_hosts_url }}" - dest: "{{ workstation_hosts_file }}" - mode: '0644' - owner: 0 - group: 0 diff --git a/roles/workstation/tasks/libvirt.yml b/roles/workstation/tasks/libvirt.yml deleted file mode 100644 index 554f800..0000000 --- a/roles/workstation/tasks/libvirt.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: install iptables-nft - ansible.builtin.shell: yes | pacman --noprogressbar --needed --sync iptables-nft - when: ansible_distribution == "Archlinux" - -- name: install libvirt - ansible.builtin.package: - name: - - cdrtools - - dnsmasq - - ebtables - - libvirt - state: present - -- name: append current user to virt groups - ansible.builtin.user: - name: "{{ workstation_user }}" - groups: "{{ item }}" - append: true - loop: - - kvm - - libvirt diff --git a/roles/workstation/tasks/main.yml b/roles/workstation/tasks/main.yml deleted file mode 100644 index 1c4c463..0000000 --- a/roles/workstation/tasks/main.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: include specific distribution variables - ansible.builtin.include_vars: "os_{{ ansible_distribution | lower }}.yml" - -- name: include packages - ansible.builtin.include_tasks: pkgs.yml - -- name: include operating system setup - ansible.builtin.include_tasks: "os_{{ ansible_distribution | lower }}.yml" - -- name: include shell setup - ansible.builtin.include_tasks: shell.yml - -- name: include doas setup - ansible.builtin.include_tasks: doas.yml - -- name: include smartcard setup - ansible.builtin.include_tasks: smartcard.yml - -- name: include ssh setup - ansible.builtin.include_tasks: - file: ssh.yml - args: - apply: - become: true - become_user: "{{ workstation_user }}" - -- name: include hosts setup - ansible.builtin.include_tasks: - file: hosts.yml diff --git a/roles/workstation/tasks/os_archlinux.yml b/roles/workstation/tasks/os_archlinux.yml deleted file mode 100644 index f45433a..0000000 --- a/roles/workstation/tasks/os_archlinux.yml +++ /dev/null @@ -1,35 +0,0 @@ -- name: include battery optimization - ansible.builtin.include_tasks: tlp.yml - when: ansible_form_factor in ["Laptop", "Notebook"] - -- name: include cronie setup - ansible.builtin.include_tasks: cronie.yml - -- name: include virtualization setup - ansible.builtin.include_tasks: libvirt.yml - -- name: include dockerd setup - ansible.builtin.include_tasks: dockerd.yml - -- name: include pipewire - ansible.builtin.include_tasks: pipewire.yml - -- name: retrieve installed packages - ansible.builtin.package_facts: - register: package_facts - -- name: include yay - ansible.builtin.include_tasks: yay.yml - when: - - "'yay' not in package_facts.ansible_facts.packages" - - "'yay-bin' not in package_facts.ansible_facts.packages" - -- name: append current user to system groups - ansible.builtin.user: - name: "{{ workstation_user }}" - groups: "{{ item }}" - append: true - loop: - - wheel - - video - - audio diff --git a/roles/workstation/tasks/os_openbsd.yml b/roles/workstation/tasks/os_openbsd.yml deleted file mode 100644 index 21f3bb1..0000000 --- a/roles/workstation/tasks/os_openbsd.yml +++ /dev/null @@ -1,72 +0,0 @@ -- name: ensure wsconsctl config file exists - ansible.builtin.file: - path: /etc/wsconsctl.conf - state: touch - owner: 0 - group: 0 - mode: 0644 - -- name: append configuration to wsconsctl - ansible.builtin.lineinfile: - path: /etc/wsconsctl.conf - regexp: "^{{ item[0] }}" - line: "{{ item[0] }}={{ item[1] }}" - create: true - owner: 0 - group: 0 - mode: 0644 - loop: - - [screen.brightness, 80] - - [keyboard.repeat.del1, 180] - - [keyboard.repeat.deln, 50] - - [keyboard.bell.volume, 0] - - [mouse.tp.tapping, 1] - -- name: ensure Xorg subdirectory for configuration exists - ansible.builtin.file: - path: /etc/X11/xorg.conf.d - owner: 0 - group: 0 - mode: 0644 - state: directory - -- name: generate system wide configurations - ansible.builtin.template: - src: "{{ item[0] }}" - dest: "{{ item[1] }}" - mode: preserve - loop: - - [xorg-intel.conf, /etc/X11/xorg.conf.d] - - [apm-hibernate, /etc/apm/hibernate] - - [apm-suspend, /etc/apm/suspend] - - [apm-resume, /etc/apm/resume] - -- name: ensure sysctl configuration file exists - ansible.builtin.file: - path: /etc/sysctl.conf - owner: root - mode: 0644 - -- name: ensure sysctl memory optimizations - ansible.builtin.blockinfile: - path: /etc/sysctl.conf - block: | - kern.shminfo.shmall=3145728 - kern.shminfo.shmmax=1073741823 - kern.shminfo.shmmni=1024 - kern.shminfo.shmseg=1024 - kern.seminfo.semmns=4096 - kern.seminfo.semmni=1024 - marker: "# memory {mark} - managed by Ansible" - -- name: ensure sysctl process optimizations - ansible.builtin.blockinfile: - path: /etc/sysctl.conf - block: | - kern.maxfiles=102400 - kern.maxproc=32768 - kern.maxfiles=65535 - kern.bufcachepercent=90 - kern.maxvnodes=262144 - kern.somaxconn=2048 - marker: "# process - {mark} managed by Ansible" diff --git a/roles/workstation/tasks/pipewire.yml b/roles/workstation/tasks/pipewire.yml deleted file mode 100644 index 1fc83a9..0000000 --- a/roles/workstation/tasks/pipewire.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: install pipewire - ansible.builtin.package: - name: - - pipewire - - pipewire-alsa - - pipewire-pulse - - mda.lv2 - state: present - -- name: enable and start pipewire - ansible.builtin.systemd: - name: "{{ item }}" - scope: user - enabled: true - state: started - become: true - become_method: su - become_user: "{{ workstation_user }}" - loop: - - pipewire - - pipewire-pulse - when: ansible_service_mgr == "systemd" diff --git a/roles/workstation/tasks/pkgs.yml b/roles/workstation/tasks/pkgs.yml deleted file mode 100644 index 674ccc4..0000000 --- a/roles/workstation/tasks/pkgs.yml +++ /dev/null @@ -1,7 +0,0 @@ -- name: install distribution packages - ansible.builtin.package: - name: "{{ item }}" - state: present - loop: - - "{{ workstation_pkgs_common }}" - - "{{ workstation_pkgs }}" diff --git a/roles/workstation/tasks/shell.yml b/roles/workstation/tasks/shell.yml deleted file mode 100644 index dc11ca4..0000000 --- a/roles/workstation/tasks/shell.yml +++ /dev/null @@ -1,8 +0,0 @@ -- name: retrieve zsh path # noqa no-changed-when command-instead-of-shell - ansible.builtin.shell: command -v zsh - register: zsh_path - -- name: ensure zsh is used for workstation user - ansible.builtin.user: - name: "{{ workstation_user }}" - shell: "{{ zsh_path.stdout_lines[0] }}" diff --git a/roles/workstation/tasks/smartcard.yml b/roles/workstation/tasks/smartcard.yml deleted file mode 100644 index 926770a..0000000 --- a/roles/workstation/tasks/smartcard.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: start and enable pcscd service - ansible.builtin.service: - name: pcscd - state: started - enabled: true diff --git a/roles/workstation/tasks/ssh.yml b/roles/workstation/tasks/ssh.yml deleted file mode 100644 index d09c7f8..0000000 --- a/roles/workstation/tasks/ssh.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: create ssh directory - ansible.builtin.file: - path: "/home/{{ workstation_user }}/{{ item }}" - owner: "{{ workstation_user }}" - group: "{{ workstation_user }}" - state: directory - mode: 0700 - loop: - - .ssh - - .ssh/config.d - -- name: generate ssh configuration - ansible.builtin.template: - src: ssh.config.j2 - dest: "/home/{{ workstation_user }}/.ssh/config.d/dns.config" - owner: "{{ workstation_user }}" - group: "{{ workstation_user }}" - mode: 0600 diff --git a/roles/workstation/tasks/tlp.yml b/roles/workstation/tasks/tlp.yml deleted file mode 100644 index 4782741..0000000 --- a/roles/workstation/tasks/tlp.yml +++ /dev/null @@ -1,10 +0,0 @@ -- name: install tlp - ansible.builtin.package: - name: tlp - state: present - -- name: enable and start tlp - ansible.builtin.service: - name: tlp - state: started - enabled: true diff --git a/roles/workstation/tasks/yay.yml b/roles/workstation/tasks/yay.yml deleted file mode 100644 index 8581bfd..0000000 --- a/roles/workstation/tasks/yay.yml +++ /dev/null @@ -1,20 +0,0 @@ -- name: clone yay repository - ansible.builtin.git: - repo: "{{ workstation_yay_repo }}" - dest: "{{ workstation_yay_dir }}" - version: origin/master - become: true - become_user: "{{ workstation_user }}" - -- name: make yay package # noqa: no-changed-when - # possible ambiguous replacement: command : ansible.builtin.command | community.ciscosmb.command | community.routeros.command - ansible.builtin.command: - cmd: makepkg -fs - chdir: "{{ workstation_yay_dir }}" - become: true - become_user: "{{ workstation_user }}" - -- name: install yay package # noqa: no-changed-when - ansible.builtin.shell: - cmd: pacman --noconfirm -U *.zst - chdir: "{{ workstation_yay_dir }}" -- cgit v1.2.3