From 4f96ddf3791714cf52e53cb71962cb95a1b12293 Mon Sep 17 00:00:00 2001 From: Salt Date: Tue, 3 Nov 2020 05:30:19 -0600 Subject: [PATCH] Add udev, grub roles for desktops Lovin how light they are tho --- inventory/hosts.yml | 4 ++++ roles/grub/defaults/main.yml | 14 ++++++++++++++ roles/grub/handlers/main.yml | 5 +++++ roles/grub/tasks/main.yml | 8 ++++++++ roles/grub/templates/grub.conf | 12 ++++++++++++ roles/udev/handlers/main.yml | 5 +++++ roles/udev/tasks/main.yml | 9 +++++++++ site.yml | 13 +++++++++++++ 8 files changed, 70 insertions(+) create mode 100644 roles/grub/defaults/main.yml create mode 100644 roles/grub/handlers/main.yml create mode 100644 roles/grub/tasks/main.yml create mode 100644 roles/grub/templates/grub.conf create mode 100644 roles/udev/handlers/main.yml create mode 100644 roles/udev/tasks/main.yml diff --git a/inventory/hosts.yml b/inventory/hosts.yml index 3864882..f6332bf 100644 --- a/inventory/hosts.yml +++ b/inventory/hosts.yml @@ -3,6 +3,10 @@ all: vars: ansible_user: ansible children: + desktop: + hosts: + dsk-cstm-0: + ansible_host: 172.23.100.1 db: hosts: db1.test.desu.ltd: diff --git a/roles/grub/defaults/main.yml b/roles/grub/defaults/main.yml new file mode 100644 index 0000000..f62b5af --- /dev/null +++ b/roles/grub/defaults/main.yml @@ -0,0 +1,14 @@ +# vim:ft=ansible: +# Defaults are for a super-simple pared-down instant GRUB +grub_default: 0 +grub_hidden_timeout: 0 +grub_hidden_timeout_quiet: "true" +grub_timeout: 0 +grub_timeout_style: hidden +grub_recordfail_timeout: 0 +grub_distributor: "`lsb_release -i -s 2> /dev/null`" +grub_cmdline_linux_default: "quiet splash" +grub_cmdline_linux: "" + +# Workaroundies +grub_disable_os_prober: "true" diff --git a/roles/grub/handlers/main.yml b/roles/grub/handlers/main.yml new file mode 100644 index 0000000..e2381ab --- /dev/null +++ b/roles/grub/handlers/main.yml @@ -0,0 +1,5 @@ +#!/usr/bin/env ansible-playbook +# vim:ft=ansible: +- name: grub mkconfig + command: "grub-mkconfig -o /boot/grub/grub.cfg" + become: yes diff --git a/roles/grub/tasks/main.yml b/roles/grub/tasks/main.yml new file mode 100644 index 0000000..4f15f65 --- /dev/null +++ b/roles/grub/tasks/main.yml @@ -0,0 +1,8 @@ +#!/usr/bin/env ansible-playbook +# vim:ft=ansible: +--- +- name: configure grub + block: + - name: template out grub config + template: src=grub.conf dest=/etc/default/grub + notify: grub mkconfig diff --git a/roles/grub/templates/grub.conf b/roles/grub/templates/grub.conf new file mode 100644 index 0000000..8fafd47 --- /dev/null +++ b/roles/grub/templates/grub.conf @@ -0,0 +1,12 @@ +# vim:ft=bash +GRUB_DEFAULT="{{ grub_default }}" +GRUB_HIDDEN_TIMEOUT="{{ grub_hidden_timeout }}" +GRUB_HIDDEN_TIMEOUT_QUIET="{{ grub_hidden_timeout_quiet }}" +GRUB_TIMEOUT="{{ grub_timeout }}" +GRUB_TIMEOUT_STYLE="{{ grub_timeout_style }}" +GRUB_RECORDFAIL_TIMEOUT="{{ grub_recordfail_timeout }}" +GRUB_DISTRIBUTOR="{{ grub_distributor }}" +GRUB_CMDLINE_LINUX_DEFAULT="{{ grub_cmdline_linux_default }}" +GRUB_CMDLINE_LINUX="{{ grub_cmdline_linux }}" +# Work around probing for other OSs resetting timeout +GRUB_DISABLE_OS_PROBER="{{ grub_disable_os_prober }}" diff --git a/roles/udev/handlers/main.yml b/roles/udev/handlers/main.yml new file mode 100644 index 0000000..100127d --- /dev/null +++ b/roles/udev/handlers/main.yml @@ -0,0 +1,5 @@ +#!/usr/bin/env ansible-playbook +# vim:ft=ansible: +- name: reload udev + command: udevadm trigger + become: yes diff --git a/roles/udev/tasks/main.yml b/roles/udev/tasks/main.yml new file mode 100644 index 0000000..6672c71 --- /dev/null +++ b/roles/udev/tasks/main.yml @@ -0,0 +1,9 @@ +#!/usr/bin/env ansible-playbook +# vim:ft=ansible: +--- +- name: configure udev rules + block: + - name: add custom udev rules + lineinfile: path=/etc/udev/rules.d/50-ansible.rules line={{ item }} create=yes + loop: "{{ udev_rules }}" + notify: reload udev diff --git a/site.yml b/site.yml index c2f3b95..d00dca6 100755 --- a/site.yml +++ b/site.yml @@ -8,6 +8,19 @@ tags: [ common ] - role: ansible-pull tags: [ ansible, common ] + # Home desktops +- hosts: desktop + roles: + - role: grub + become: yes + tags: [ desktop, grub ] + - role: udev + vars: + udev_rules: + # Switch RCM stuff + - SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0664", GROUP="plugdev" + become: yes + tags: [ desktop, udev ] # Database servers - hosts: db1.test.desu.ltd roles: