Add user parameter to allow running the service as a non-root user

This commit is contained in:
Ricardo Carrillo Cruz 2015-03-25 10:23:15 +00:00
parent 4c080ffbe3
commit da9eb4a323
2 changed files with 5 additions and 0 deletions

View File

@ -17,6 +17,7 @@
# A define to add an autossh tunnel
define autossh::tunnel (
$ensure = running,
$user,
$ssh_port = '22',
$ssh_host,
$ssh_user,

View File

@ -1 +1,5 @@
<% if @user == 'root' %>
/usr/lib/autossh/autossh -M 0 -N -f -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -o "StrictHostKeyChecking no" <% if @local_forward_args %> -L <%= @local_forward_args %> <% end %> <% if @remote_forward_args %> -R <%= @remote_forward_args %> <% end %> -i <%= @ssh_key %> <%= @ssh_user %>@<%= @ssh_host %> -p <%= @ssh_port %>
<% else %>
su <%= @user %> -c '/usr/lib/autossh/autossh -M 0 -N -f -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -o "StrictHostKeyChecking no" <% if @local_forward_args %> -L <%= @local_forward_args %> <% end %> <% if @remote_forward_args %> -R <%= @remote_forward_args %> <% end %> -i <%= @ssh_key %> <%= @ssh_user %>@<%= @ssh_host %> -p <%= @ssh_port %>'
<% end %>