Sha256: e305d4117d7ae6bfc9a1610a9ad826dc237a8dcb7d99158ff4626646ecfbe44e

Contents?: true

Size: 882 Bytes

Versions: 3

Compression:

Stored size: 882 Bytes

Contents

module Chake

  class Backend

    class Ssh < Backend

      def scp
        ['scp', ssh_config].flatten.compact
      end

      def scp_dest
        ssh_target + ':'
      end

      def rsync
        ['rsync', rsync_ssh].flatten.compact
      end

      def rsync_dest
        [ssh_target, node.path + '/'].join(':')
      end

      def command_runner
        ['ssh', ssh_config, ssh_target].flatten.compact
      end

      private

      def rsync_ssh
        File.exist?(ssh_config_file) && ['-e', 'ssh -F ' + ssh_config_file ] || []
      end

      def ssh_config
        File.exist?(ssh_config_file) && ['-F', ssh_config_file] || []
      end

      def ssh_config_file
        @ssh_config_file ||= ENV.fetch('CHAKE_SSH_CONFIG', '.ssh_config')
      end

      def ssh_target
        [node.remote_username, node.hostname].compact.join('@')
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chake-0.4.3 lib/chake/backend/ssh.rb
chake-0.4.2 lib/chake/backend/ssh.rb
chake-0.4.1 lib/chake/backend/ssh.rb