Skip to content

Instantly share code, notes, and snippets.

@ryanteck
Created July 9, 2024 21:20
Show Gist options
  • Save ryanteck/1178a8e4431e0cc587d533f922b5c773 to your computer and use it in GitHub Desktop.
Save ryanteck/1178a8e4431e0cc587d533f922b5c773 to your computer and use it in GitHub Desktop.
Basic ansible playbook for configuring a PC to stream Moonlight
- name: Moonstream
hosts: myhosts
pre_tasks:
- name: Check Hosts Online
ansible.builtin.ping:
- name: Update APT
become: true
apt:
name: "*"
state: latest
update_cache: yes
- name: Install XFCE Desktop
async: 30
poll: 0
become: true
apt:
name:
- xubuntu-core
state: present
install_recommends: true
- name: Install Moonlight
become: true
community.general.snap:
name:
- moonlight
- name: Utilities
become: true
apt:
name:
- cabextract
- unzip
- dkms
- curl
- btop
- pamixer
state: present
install_recommends: true
- name: XONE - Create Folder
when: xone_driver|d('false')
stat:
path: "/opt/xone"
become: true
- name: XONE - Git Clone
when: xone_driver|d('false')
git:
repo: "https://github.com/medusalix/xone.git"
dest: /opt/xone
accept_newhostkey: true
become: true
- name: XONE - check
when: xone_driver|d('false')
command:
cmd: dkms status
register: result
ignore_errors: true
- name: XONE - Build
when: xone_driver|d('false') and result is failed
command:
chdir: /opt/xone
cmd: ./install.sh --release
- name: XONE - Firmware
when: xone_driver|d('false') and result is not failed
command:
chdir: /opt/xone
cmd: xone-get-firmware.sh --skip-disclaimer
become: true
tasks:
- name: XFCE - Configure Power Button
xfconf:
channel: "xfce4-power-manager"
property: "/xfce4-power-manager/power-button-action"
value_type: "uint"
value: "1"
- name: XFCE - Disable Lock Screen
xfconf:
channel: "xfce4-session"
property: "/shutdown/LockScreen"
value_type: "bool"
value: "false"
- name: XFCE - Disable Screensaver
xfconf:
channel: "xfce4-screensaver"
property: "/lock/sleep-activation"
value_type: "bool"
value: "false"
- name: XFCE - Disable Lock On Suspend
xfconf:
channel: "xfce4-power-manager"
property: "/xfce4-power-manager/lock-screen-suspend-hibernate"
value_type: "bool"
value: "false"
- name: XFCE - Disable Display Sleep
xfconf:
channel: "xfce4-power-manager"
property: "/xfce4-power-manager/dpms-enabled"
value_type: "bool"
value: "false"
- name: XFCE - Enable Sleep Mode
xfconf:
channel: "xfce4-power-manager"
property: "/xfce4-power-manager/inactivity-on-ac"
value_type: "uint"
value: "15"
- name: XFCE - Disable Screensaver
xfconf:
channel: "xfce4-screensaver"
property: "/saver/enabled"
value_type: "bool"
value: "false"
- name: XFCE - Disable Screensaver Lock
xfconf:
channel: "xfce4-screensaver"
property: "/lock/enabled"
value_type: "bool"
value: "false"
- name: XFCE - Set Resolution
xfconf:
channel: "displays"
property: "/Default/HDMI-1/Resolution"
value_type: "string"
value: "1920x1080"
- name: XFCE - Set Refresh
xfconf:
channel: "displays"
property: "/Default/HDMI-1/RefreshRate"
value_type: "double"
value: "60.00"
- name: XFCE - Display Profile
xfconf:
channel: "displays"
property: "/ActiveProfile"
value_type: "string"
value: "Default"
- name: AUDIO - Set HDMI
shell: "pactl set-card-profile alsa_card.pci-0000_00_1f.3 output:hdmi-stereo"
- name: AUDIO - Set Volume
shell: pamixer --set-volume 100
- name: Moonlight - Autostart Folder
file:
path: "/home/ryanw/.config/autostart"
state: directory
- name: Moonlight - Autostart
template:
src: "Moonlight.desktop"
dest: /home/ryanw/.config/autostart/Moonlight.desktop
owner: ryanw
group: ryanw
mode: '0665'
- name: Moonlight - Height
replace:
path: "/home/ryanw/.var/app/com.moonlight_stream.Moonlight/config/Moonlight Game Streaming Project/Moonlight.conf"
regexp: 'height=\d{3,4}'
replace: 'height=1080'
- name: Moonlight - Width
replace:
path: "/home/ryanw/.var/app/com.moonlight_stream.Moonlight/config/Moonlight Game Streaming Project/Moonlight.conf"
regexp: 'width=\d{3,4}'
replace: 'width=1920'
- name: Moonlight - FPS
replace:
path: "/home/ryanw/.var/app/com.moonlight_stream.Moonlight/config/Moonlight Game Streaming Project/Moonlight.conf"
regexp: 'fps=\d{2,3}'
replace: 'fps=72'
- name: Moonlight - Bitrate
replace:
path: "/home/ryanw/.var/app/com.moonlight_stream.Moonlight/config/Moonlight Game Streaming Project/Moonlight.conf"
regexp: 'bitrate=\d{4,6}'
replace: 'bitrate=150000'
- name: Moonlight - Fullscreen UI
replace:
path: "/home/ryanw/.var/app/com.moonlight_stream.Moonlight/config/Moonlight Game Streaming Project/Moonlight.conf"
regexp: 'uidisplaymode=\d'
replace: 'uidisplaymode=2'
- name: Moonlight - Enable HDR
replace:
path: "/home/ryanw/.var/app/com.moonlight_stream.Moonlight/config/Moonlight Game Streaming Project/Moonlight.conf"
regexp: 'uidisplaymode=\d'
replace: 'uidisplaymode=2'
post_tasks:
- name: Reboot
reboot:
become: true
roles:
- role: gantsign.lightdm
lightdm_autologin_user: ryanw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment