Puppet Class: keyboard

Defined in:
manifests/init.pp

Summary

Configure keyboard gadget

Overview

Parameters:

  • kvmtoggle_secret (String)

    sets the shared key to authenticate kvmtoggle requests

  • kvmtoggle_version (String) (defaults to: 'v0.0.1')

    is the version of the kvmtoggle binary to download



5
6
7
8
9
10
11
12
13
14
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
# File 'manifests/init.pp', line 5

class keyboard (
  String $kvmtoggle_secret,
  String $kvmtoggle_version = 'v0.0.1',
) {
  package { 'usbutils': }

  file { '/boot/config.txt':
    ensure => file,
    source => 'puppet:///modules/keyboard/config.txt',
  }

  file { '/etc/modules-load.d/keyboard':
    ensure  => file,
    content => 'dwc2',
  }

  file { '/usr/local/bin/hid_gadget_setup.sh':
    ensure => file,
    mode   => '0755',
    source => 'puppet:///modules/keyboard/hid_gadget_setup.sh',
  }

  -> file { '/etc/systemd/system/hid-setup.service':
    ensure => file,
    source => 'puppet:///modules/keyboard/hid-setup.service',
  }

  ~> service { 'hid-setup':
    ensure => running,
    enable => true,
  }

  $binfile = '/usr/local/bin/kvmtoggle'
  $arch = $facts['os']['architecture'] ? {
    'x86_64'  => 'amd64',
    'arm64'   => 'arm64',
    'aarch64' => 'arm64',
    'arm'     => 'arm',
    'armv7l'  => 'arm',
    default   => 'error',
  }
  $url = "https://github.com/akerl/kvmtoggle/releases/download/${kvmtoggle_version}/kvmtoggle_linux_${arch}"

  file { $binfile:
    ensure => file,
    source => $url,
    mode   => '0755',
    owner  => 'root',
    group  => 'root',
  }

  -> file { '/etc/systemd/system/kvmtoggle.service':
    ensure  => file,
    content => template('keyboard/kvmtoggle.service.erb'),
  }

  ~> service { 'kvmtoggle':
    ensure => running,
    enable => true,
  }

  firewall { '100 allow inbound 8080 for kvmtoggle':
    dport  => 8080,
    proto  => 'tcp',
    action => 'accept',
  }
}