Ansible but more better
This commit is contained in:
parent
29b2beca5a
commit
b7ce9d850d
13 changed files with 172 additions and 0 deletions
20
ansible_deploy/display/inventory.yml
Normal file
20
ansible_deploy/display/inventory.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
predavalnice_pi:
|
||||||
|
# Skupne spremenljivke za vse zaslone
|
||||||
|
vars:
|
||||||
|
ansible_user: pi
|
||||||
|
|
||||||
|
# Check here: https://github.com/leukipp/touchkio/releases
|
||||||
|
touchkio_version: "1.3.1"
|
||||||
|
# Multimedia network
|
||||||
|
static_ip_cidr: "24"
|
||||||
|
static_ip_gateway: "192.168.192.1"
|
||||||
|
static_ip_dns_servers:
|
||||||
|
- "212.235.188.28"
|
||||||
|
- "212.235.188.29"
|
||||||
|
hosts:
|
||||||
|
p01_touch_display:
|
||||||
|
predavalnica: p01
|
||||||
|
static_ip: "192.168.192.111"
|
||||||
|
hostname: "p01_touch_display.local"
|
||||||
|
kiosk_url: "http://192.168.192.42?room=P01"
|
||||||
|
mqtt_host: "192.168.192.42"
|
37
ansible_deploy/display/pi_stuff.yml
Normal file
37
ansible_deploy/display/pi_stuff.yml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
# - name: Change splash image
|
||||||
|
# become: true
|
||||||
|
# copy:
|
||||||
|
# src: splash.png
|
||||||
|
# dest: /usr/share/plymouth/themes/pix/splash.png
|
||||||
|
|
||||||
|
- name: Enable boot splash screen
|
||||||
|
become: true
|
||||||
|
shell: "raspi-config nonint get_boot_splash && raspi-config nonint do_boot_splash 0"
|
||||||
|
register: boot_splash
|
||||||
|
changed_when:
|
||||||
|
- boot_splash == "1"
|
||||||
|
|
||||||
|
- name: Disable color splash
|
||||||
|
become: true
|
||||||
|
community.general.ini_file:
|
||||||
|
path: /boot/firmware/config.txt
|
||||||
|
option: disable_splash
|
||||||
|
value: 1
|
||||||
|
no_extra_spaces: true
|
||||||
|
|
||||||
|
- name: Remove desktop bloat
|
||||||
|
become: true
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- gvfs
|
||||||
|
- gnome-keyring
|
||||||
|
- cups
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Switch to wayfire
|
||||||
|
become: true
|
||||||
|
shell: "raspi-config nonint is_wayfire && raspi-config nonint do_wayland W2"
|
||||||
|
register: result
|
||||||
|
failed_when: ( result.rc not in [ 0, 1 ] )
|
||||||
|
changed_when: ( result.rc == 1 )
|
7
ansible_deploy/display/playbook.yml
Normal file
7
ansible_deploy/display/playbook.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
- hosts: predavalnice_pi
|
||||||
|
# TODO: better include (import playbook)
|
||||||
|
tasks:
|
||||||
|
- include_tasks: static_ip.yml
|
||||||
|
# - include_tasks: wifi_temp.yml # TODO: remove this when we don't need wifi anymore
|
||||||
|
- include_tasks: pi_stuff.yml
|
||||||
|
- include_tasks: touch_display.yml
|
32
ansible_deploy/display/static_ip.yml
Normal file
32
ansible_deploy/display/static_ip.yml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
- name: Configure static IP address (using Network Manager)
|
||||||
|
become: yes
|
||||||
|
community.general.nmcli:
|
||||||
|
conn_name: "Multimedia net"
|
||||||
|
ifname: eth0
|
||||||
|
type: ethernet
|
||||||
|
ip4: "{{ static_ip }}/{{ static_ip_cidr }}"
|
||||||
|
# Sorry timi
|
||||||
|
method6: disabled
|
||||||
|
# Multimedia net doesn't have Internet access, so this iface shouldn't be used for Internet access
|
||||||
|
never_default4: true
|
||||||
|
routes4_extended:
|
||||||
|
- ip: 192.168.0.0/16
|
||||||
|
next_hop: "{{ static_ip_gateway }}"
|
||||||
|
metric: 9999
|
||||||
|
- ip: 10.0.0.0/8
|
||||||
|
next_hop: "{{ static_ip_gateway }}"
|
||||||
|
metric: 9999
|
||||||
|
# gw4: "{{ static_ip_gateway }}"
|
||||||
|
state: present
|
||||||
|
conn_reload: true
|
||||||
|
|
||||||
|
- name: Wait for network to be available
|
||||||
|
become: yes
|
||||||
|
wait_for_connection:
|
||||||
|
timeout: 60
|
||||||
|
|
||||||
|
- name: Display new IP configuration
|
||||||
|
debug:
|
||||||
|
msg: "Static IP configured: {{ static_ip }}/{{ static_ip_cidr }}"
|
||||||
|
|
||||||
|
|
38
ansible_deploy/display/touch_display.yml
Normal file
38
ansible_deploy/display/touch_display.yml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
- name: Fix fonts
|
||||||
|
become: true
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- fonts-noto-core
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Download .deb file
|
||||||
|
get_url:
|
||||||
|
url: "https://github.com/leukipp/touchkio/releases/download/v{{ touchkio_version }}/touchkio_{{ touchkio_version }}_arm64.deb"
|
||||||
|
dest: "/home/pi/touchkio_{{ touchkio_version }}_arm64.deb"
|
||||||
|
register: deb_download
|
||||||
|
|
||||||
|
- name: Install the latest .deb package
|
||||||
|
become: yes
|
||||||
|
apt:
|
||||||
|
deb: "/home/pi/touchkio_{{ touchkio_version }}_arm64.deb"
|
||||||
|
when: deb_download is succeeded
|
||||||
|
|
||||||
|
- name: Create systemd user service directory
|
||||||
|
file:
|
||||||
|
path: "{{ ansible_env.HOME }}/.config/systemd/user"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Create systemd user service
|
||||||
|
template:
|
||||||
|
src: touchkio.service.j2
|
||||||
|
dest: "{{ ansible_env.HOME }}/.config/systemd/user/touchkio.service"
|
||||||
|
|
||||||
|
- name: Enable systemd service
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: touchkio
|
||||||
|
enabled: true
|
||||||
|
state: restarted
|
||||||
|
scope: user
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
|
when: ansible_check_mode == false
|
12
ansible_deploy/display/touchkio.service.j2
Normal file
12
ansible_deploy/display/touchkio.service.j2
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Kiosk browser
|
||||||
|
After=graphical.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/touchkio --web-url="{{ kiosk_url }}" --web-zoom=1.0 "--mqtt-url=mqtt://{{ mqtt_host }}"
|
||||||
|
#ExecStart=/usr/bin/chromium-browser --ozone-platform=x11 --noerrdialogs --disable-infobars --kiosk --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 --app="{{ kiosk_url }}"
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5s
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
26
ansible_deploy/display/wifi_temp.yml
Normal file
26
ansible_deploy/display/wifi_temp.yml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
- name: Set wifi country
|
||||||
|
become: true
|
||||||
|
shell: "raspi-config nonint get_wifi_country && raspi-config nonint do_wifi_country SI; true"
|
||||||
|
register: wifi_country
|
||||||
|
changed_when:
|
||||||
|
- wifi_country != "SI"
|
||||||
|
|
||||||
|
- name: Configure P2P wifi
|
||||||
|
become: yes
|
||||||
|
community.general.nmcli:
|
||||||
|
conn_name: "MALINCA"
|
||||||
|
ifname: wlan0
|
||||||
|
type: wifi
|
||||||
|
ssid: "MALINCA"
|
||||||
|
wifi_sec:
|
||||||
|
key-mgmt: wpa-psk
|
||||||
|
psk: "MALINCA123"
|
||||||
|
autoconnect: true
|
||||||
|
method4: auto
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Restart NetworkManager
|
||||||
|
become: yes
|
||||||
|
service:
|
||||||
|
name: NetworkManager
|
||||||
|
state: restarted
|
Loading…
Add table
Add a link
Reference in a new issue