Skip to content

Instantly share code, notes, and snippets.

@disassembler
Created September 15, 2017 15:15
Show Gist options
  • Save disassembler/0e9116966d6bcf00adca1c5ed9010a2b to your computer and use it in GitHub Desktop.
Save disassembler/0e9116966d6bcf00adca1c5ed9010a2b to your computer and use it in GitHub Desktop.
# = Class: mosquitto
class mosquitto (
$backends = undef,
$hash = undef,
$version = undef,
) {
$pkg = "${hash}-mosquitto-${version}"
::nix::deploy { 'mosquitto':
hash => $hash,
pkg => 'mosquitto',
version => $version,
}
service { 'mosquitto':
ensure => running,
enable => true,
require => [
Nix::Deploy['mosquitto'],
File['/etc/mosquitto/mosquitto.conf'],
User['mosquitto'],
Systemd::Unit_file['mosquitto.service'],
]
}
user { 'mosquitto':
ensure => present,
}
::systemd::unit_file { 'mosquitto.service':
content => template('mosquitto/service.erb'),
}
file { '/etc/mosquitto':
ensure => directory,
mode => '0755',
owner => 'root',
group => 'root',
}
file { '/etc/mosquitto/mosquitto.conf':
ensure => present,
mode => '0644',
owner => 'root',
group => 'root',
notify => Service['mosquitto'],
content => template('mosquitto/mosquitto.conf.erb'),
}
}
[Unit]
Description=Mosquitto MQTT Server
After=network.target
[Service]
Type=simple
User=mosquitto
ExecStart=/nix/store/<%= @pkg %>/bin/mosquitto -c /etc/mosquitto/mosquitto.conf
LimitNOFILE=1000000
Restart=always
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment