Puppet generated systemd unit files?
Solution 1:
Yes, you need to create a unit file. The command attribute you've specified there isn't actually a valid attribute for the service resource
You're best off adding an ERB template with your unit file, here's an example:
[Unit]
Description=My Ruby Service
Wants=basic.target
After=basic.target network.target
[Service]
WorkingDirectory=/vagrant/nginx-reverse-proxy/legacy
ExecStart=/usr/bin/bundle exec ruby app.rb -o 127.0.0.1 -e production -p 4567"
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
Then, set up the template in Puppet and make sure you refresh systemd. Some example code:
file { '/lib/systemd/system/myservice.service':
mode => '0644',
owner => 'root',
group => 'root',
content => template('modulename/myservice.systemd.erb'),
}~>
exec { 'myservice-systemd-reload':
command => 'systemctl daemon-reload',
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
refreshonly => true,
}
Now that's done, you can start the service as normal:
service { 'myservice':
ensure => running,
enable => true,
provider => provider,
}