diff --git a/manifests/tunnel.pp b/manifests/tunnel.pp index 2e2fb26..87c6e08 100644 --- a/manifests/tunnel.pp +++ b/manifests/tunnel.pp @@ -17,6 +17,7 @@ # A define to add an autossh tunnel define autossh::tunnel ( $ensure = running, + $user, $ssh_port = '22', $ssh_host, $ssh_user, diff --git a/templates/autossh-command.erb b/templates/autossh-command.erb index 2c8f161..73eda26 100644 --- a/templates/autossh-command.erb +++ b/templates/autossh-command.erb @@ -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 %>