Sha256: f7aa3723d58c433c2d594c92bdda0ff7a86384ba8f2283cfcf0a8be8211bd170

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

class SSHExecutionProvider < RemoteExecutionProvider

  EFFECTIVE_USER_METHODS = %w[sudo su]

  class << self
    def proxy_command_options(template_invocation, host)
      super.merge(:ssh_user => ssh_user(host),
                  :effective_user => effective_user(template_invocation),
                  :effective_user_method => effective_user_method(host))
    end

    def humanized_name
      _('SSH')
    end

    def supports_effective_user?
      true
    end

    private

    def ssh_user(host)
      host.params['remote_execution_ssh_user']
    end

    def effective_user(template_invocation)
      template_invocation.effective_user
    end

    def effective_user_method(host)
      method = host.params['remote_execution_effective_user_method'] || Setting[:remote_execution_effective_user_method]
      unless EFFECTIVE_USER_METHODS.include?(method)
        raise _('Effective user method "%{current_value}" is not one of %{valid_methods}') %
                  { :current_value => method, :valid_methods => EFFECTIVE_USER_METHODS}
      end
      method
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
foreman_remote_execution-1.2.1 app/models/ssh_execution_provider.rb
foreman_remote_execution-1.2.0 app/models/ssh_execution_provider.rb
foreman_remote_execution-1.1.1 app/models/ssh_execution_provider.rb
foreman_remote_execution-1.1.0 app/models/ssh_execution_provider.rb
foreman_remote_execution-1.0.0 app/models/ssh_execution_provider.rb
foreman_remote_execution-0.3.2 app/models/ssh_execution_provider.rb
foreman_remote_execution-0.3.1 app/models/ssh_execution_provider.rb
foreman_remote_execution-0.3.0 app/models/ssh_execution_provider.rb
foreman_remote_execution-0.2.3 app/models/ssh_execution_provider.rb
foreman_remote_execution-0.2.2 app/models/ssh_execution_provider.rb
foreman_remote_execution-0.2.1 app/models/ssh_execution_provider.rb