Puppet Class: kiosk

Defined in:
manifests/init.pp

Summary

Configure kiosk display

Overview

Parameters:

  • urls (Array[String, 1, 3])

    sets the list of page to display (first is default, others use hotkeys)

  • username (String) (defaults to: 'kiosk')

    sets the username for the kiosk install

  • width (Integer) (defaults to: 3840)

    sets the width of the kiosk window

  • height (Integer) (defaults to: 2160)

    sets the height of the kiosk window

  • navigate_version (String) (defaults to: 'v0.0.4')

    sets the version to install of the navigate CLI

  • timezone (String) (defaults to: 'UTC')

    sets the timezone for the kiosk browser

  • custom_script (Optional[String]) (defaults to: undef)

    sets an alternate script instead of the default navigation hotkey

  • overscan_top (Optional[Integer]) (defaults to: undef)

    sets the top overscan value in pixels

  • overscan_bottom (Optional[Integer]) (defaults to: undef)

    sets the bottom overscan value in pixels

  • overscan_left (Optional[Integer]) (defaults to: undef)

    sets the left overscan value in pixels

  • overscan_right (Optional[Integer]) (defaults to: undef)

    sets the right overscan value in pixels

  • browser (Enum['chromium', 'firefox']) (defaults to: 'chromium')

    sets which browser to use (chromium or firefox)



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'manifests/init.pp', line 15

class kiosk (
  Array[String, 1, 3] $urls,
  String $username = 'kiosk',
  Integer $width = 3840,
  Integer $height = 2160,
  String $navigate_version = 'v0.0.4',
  String $timezone = 'UTC',
  Optional[String] $custom_script = undef,
  Optional[Integer] $overscan_top = undef,
  Optional[Integer] $overscan_bottom = undef,
  Optional[Integer] $overscan_left = undef,
  Optional[Integer] $overscan_right = undef,
  Enum['chromium', 'firefox'] $browser = 'chromium',
) {
  package { [
      $browser,
      'xorg-server',
      'xorg-xinit',
      'xorg-xset',
      'xdotool',
      'xbindkeys',
      'unclutter',
  ]: }

  user { $username:
    ensure     => present,
    home       => "/home/${username}",
    managehome => true,
  }

  file { "/home/${username}/.xinitrc":
    ensure => file,
    source => 'puppet:///modules/kiosk/xinitrc',
    owner  => $username,
  }

  file { "/home/${username}/.xbindkeysrc":
    ensure => file,
    source => 'puppet:///modules/kiosk/xbindkeysrc',
    owner  => $username,
  }

  file { "/home/${username}/.bashrc":
    ensure => file,
    source => 'puppet:///modules/kiosk/bashrc',
    owner  => $username,
  }

  $hotkey_script = $custom_script == undef ? {
    true  => file('kiosk/kiosk_hotkey.sh'),
    false => $custom_script,
  }

  file { "/home/${username}/.kiosk_hotkey.sh":
    ensure  => file,
    content => $hotkey_script,
    mode    => '0755',
    owner   => $username,
  }

  file { "/home/${username}/.kiosk_config":
    ensure  => file,
    content => template('kiosk/kiosk_config.erb'),
    owner   => $username,
  }

  file { '/etc/systemd/system/getty@tty1.service.d':
    ensure => directory,
  }

  file { '/etc/systemd/system/getty@tty1.service.d/autologin.conf':
    ensure  => file,
    content => template('kiosk/autologin.erb'),
  }

  if $facts['is_raspberry_pi'] {
    package { 'xf86-video-fbdev': }

    file { '/boot/config.txt':
      ensure  => file,
      content => template('kiosk/rpi_config.txt.erb'),
    }
  }

  $arch = $facts['os']['architecture'] ? {
    'x86_64'  => 'amd64',
    'arm64'   => 'arm64',
    'aarch64' => 'arm64',
    'arm'     => 'arm',
    default   => 'error',
  }

  $binfile = '/usr/local/bin/navigate'
  $filename = "navigate_${downcase($facts['kernel'])}_${arch}"
  $url = "https://github.com/akerl/navigate/releases/download/${navigate_version}/${filename}"

  exec { 'download navigate':
    command => "/usr/bin/curl -sLo '${binfile}' '${url}' && chmod a+x '${binfile}'",
    unless  => "/usr/bin/test -f ${binfile} && ${binfile} version | grep '${navigate_version}'",
  }
}