diff --git a/ansible_deploy/controller_script.service.j2 b/ansible_deploy/controller/controller_script.service.j2 similarity index 100% rename from ansible_deploy/controller_script.service.j2 rename to ansible_deploy/controller/controller_script.service.j2 diff --git a/ansible_deploy/inventory.yml b/ansible_deploy/controller/inventory.yml similarity index 100% rename from ansible_deploy/inventory.yml rename to ansible_deploy/controller/inventory.yml diff --git a/ansible_deploy/malinaConfig.toml.j2 b/ansible_deploy/controller/malinaConfig.toml.j2 similarity index 100% rename from ansible_deploy/malinaConfig.toml.j2 rename to ansible_deploy/controller/malinaConfig.toml.j2 diff --git a/ansible_deploy/mm-controller.target.j2 b/ansible_deploy/controller/mm-controller.target.j2 similarity index 100% rename from ansible_deploy/mm-controller.target.j2 rename to ansible_deploy/controller/mm-controller.target.j2 diff --git a/ansible_deploy/mosquitto.conf b/ansible_deploy/controller/mosquitto.conf similarity index 100% rename from ansible_deploy/mosquitto.conf rename to ansible_deploy/controller/mosquitto.conf diff --git a/ansible_deploy/playbook.yaml b/ansible_deploy/controller/playbook.yaml similarity index 100% rename from ansible_deploy/playbook.yaml rename to ansible_deploy/controller/playbook.yaml diff --git a/ansible_deploy/display/inventory.yml b/ansible_deploy/display/inventory.yml new file mode 100644 index 0000000..a7dd4e8 --- /dev/null +++ b/ansible_deploy/display/inventory.yml @@ -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" diff --git a/ansible_deploy/display/pi_stuff.yml b/ansible_deploy/display/pi_stuff.yml new file mode 100644 index 0000000..8130dc2 --- /dev/null +++ b/ansible_deploy/display/pi_stuff.yml @@ -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 ) diff --git a/ansible_deploy/display/playbook.yml b/ansible_deploy/display/playbook.yml new file mode 100644 index 0000000..3f05325 --- /dev/null +++ b/ansible_deploy/display/playbook.yml @@ -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 diff --git a/ansible_deploy/display/static_ip.yml b/ansible_deploy/display/static_ip.yml new file mode 100644 index 0000000..bea6891 --- /dev/null +++ b/ansible_deploy/display/static_ip.yml @@ -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 }}" + + diff --git a/ansible_deploy/display/touch_display.yml b/ansible_deploy/display/touch_display.yml new file mode 100644 index 0000000..f95e62f --- /dev/null +++ b/ansible_deploy/display/touch_display.yml @@ -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 diff --git a/ansible_deploy/display/touchkio.service.j2 b/ansible_deploy/display/touchkio.service.j2 new file mode 100644 index 0000000..3cbd11b --- /dev/null +++ b/ansible_deploy/display/touchkio.service.j2 @@ -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 diff --git a/ansible_deploy/display/wifi_temp.yml b/ansible_deploy/display/wifi_temp.yml new file mode 100644 index 0000000..4c45096 --- /dev/null +++ b/ansible_deploy/display/wifi_temp.yml @@ -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