From de11c5f3db95b3c3eb4b12a9ab79d69a65d19dc5 Mon Sep 17 00:00:00 2001 From: Gary Date: Sun, 9 Jan 2022 20:45:25 +0000 Subject: [PATCH] Initial Commit --- .gitignore | 1 + README.md | 16 +++++++++++++ files/lightdm.conf | 3 +++ install-python2-deb.yml | 7 ++++++ install-python3-deb.yml | 7 ++++++ inv.yml | 18 ++++++++++++++ screen-setup.yml | 44 +++++++++++++++++++++++++++++++++++ template/openbox-autostart.j2 | 14 +++++++++++ 8 files changed, 110 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 files/lightdm.conf create mode 100644 install-python2-deb.yml create mode 100644 install-python3-deb.yml create mode 100644 inv.yml create mode 100644 screen-setup.yml create mode 100644 template/openbox-autostart.j2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a8b42eb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.retry diff --git a/README.md b/README.md new file mode 100644 index 0000000..a78bc80 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Raspberry Pi NOC Screen + +This Ansible playbook will install the necessary software and configuration to point at a NOC Screen webpage + +> __NOTE:__ This will not change the password, you will either need to change this before or after +> You can either change the password beforehand, alternatively install SSH Keys and remove passwords + +To invoke the playbook make sure you have updated the `inv.yml` for your needs, then run as follows: +```bash +# Run against all hosts (-kK is to ask for the SSH/SUDO Password) +ansible-playbook -i inv.yml setup-screen.yml -kK + +# Run against limited hosts +ansible-playbook -i inv.yml setup-screen.yml -kK -l *host* + +``` diff --git a/files/lightdm.conf b/files/lightdm.conf new file mode 100644 index 0000000..366ff80 --- /dev/null +++ b/files/lightdm.conf @@ -0,0 +1,3 @@ +[SeatDefaults] +autologin-user=screen-user +user-session=openbox diff --git a/install-python2-deb.yml b/install-python2-deb.yml new file mode 100644 index 0000000..bfb8beb --- /dev/null +++ b/install-python2-deb.yml @@ -0,0 +1,7 @@ +- hosts: all + gather_facts: False + become: yes + + tasks: + - name: install python 2 + raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) diff --git a/install-python3-deb.yml b/install-python3-deb.yml new file mode 100644 index 0000000..36a640d --- /dev/null +++ b/install-python3-deb.yml @@ -0,0 +1,7 @@ +- hosts: all + gather_facts: False + become: yes + + tasks: + - name: install python 3 + raw: test -e /usr/bin/python || (apt -y update && apt install -y python3-minimal) diff --git a/inv.yml b/inv.yml new file mode 100644 index 0000000..d457b5f --- /dev/null +++ b/inv.yml @@ -0,0 +1,18 @@ +all: + vars: + nocweburl: https://www.example.com/screen/ + ansible_user: pi + children: + prod: + hosts: + screen1: + ansible_host: 203.0.113.47 + screen2: + ansible_host: 203.0.113.49 + screen3: + ansible_host: 203.0.113.49 + dev: + hosts: + screen0: + ansible_host: 203.0.113.50 + ansible_user: sysadmin diff --git a/screen-setup.yml b/screen-setup.yml new file mode 100644 index 0000000..8d41bd0 --- /dev/null +++ b/screen-setup.yml @@ -0,0 +1,44 @@ +--- +- hosts: all + become: yes + tasks: + - name: Apt Update Cache + apt: + update_cache: yes + cache_valid_time: 3600 + + - name: Install Needed Packages + apt: name={{item}} state=installed + with_items: + - vim + - sudo + - xorg + - chromium-browser + - openbox + - lightdm + - unclutter + + - name: lightdm config + copy: src=files/lightdm.conf dest=/etc/lightdm/lightdm.conf + notify: + - restart host + + - name: Add User + user: name=screen-user + + - name: screen-user config directory + file: path=/home/screen-user/.config/openbox state=directory group=screen-user owner=screen-user recurse=yes + + - name: screen-user openbox config + copy: src=template/openbox-autostart.j2 dest=/home/screen-user/.config/openbox/autostart + notify: + - restart host + + + handlers: + + - name: restart host + command: systemd-run --on-active=1 systemctl reboot + async: 0 + poll: 0 + diff --git a/template/openbox-autostart.j2 b/template/openbox-autostart.j2 new file mode 100644 index 0000000..94978d2 --- /dev/null +++ b/template/openbox-autostart.j2 @@ -0,0 +1,14 @@ +# Disable Screensaver +xset -dpms s off 2>&1 | tee /tmp/xset-log +# Launch Chrome +chromium-browser \ + --no-first-run \ + --disable \ + --disable-translate \ + --disable-infobars \ + --disable-suggestions-service \ + --disable-save-password-bubble \ + --start-maximized \ + --kiosk --app="{{ nocweburl }}?hostname=$(hostname -s)" & +# Unclutter +unclutter -idle 0 &