Dsl¶
-
class
Hutte::Dsl¶ The block you pass to
SshSession.runis given an instance of this class, and this is the main API in Hutte.This class conveniently includes the methods from the
Fileclass, e.g.dsl.file_exists?(path)will callFile.exists?.-
cd(path)¶ Change the remote directory.
This doesn’t have any immediate effect. A block with remote commands should be passed; their working directory will be changed as intended.
Calls to this method can be nested:
cd '/home' do run 'pwd' # Prints /home cd 'bastien' do run 'pwd' # Prints /home/bastien run 'ls' # Prints the content of /home/bastien end end
-
dsl()¶ Call the given block with self bound to this
Dslobject.Useful when decomposing the program into functions:
def print_home(s) s.dsl do # Note we don't need to write ``s.run'' run 'ls -l /home' end end Hutte::SshSession.run('user', 'host') do print_home(self) end
-
local(command[, options])¶ Execute command (a string) locally, blocking until it is completed and return a
CommandResultinstance.Options include:
output: whether the output of the command should be printed (currently, the content of stderr is always printed). True by default.ok_exit_statuses: an array of process exit statuses that indicate success. [0] by default.dry_run: the value you set inSshSession‘s options. May be overriden.verbose: the value you set inSshSession‘s options. May be overriden.
-
rsync(options)¶ Call the rsync tool to synchronize a local directory with the server.
options is a hash that must include the following keys:
remote_dir: the remote directory that will be synced.local_dir: the local directory that will be synced. Add a trailing/if you want the content oflocal_dirto be dropped insideremote_dir. Otherwise, rsync will place the files atremote_dir/local_dir.
These keys are optional:
exclude: an array of strings for the paths that rsync should ignore, using a--excludeoption for each item in the array. [] by default.delete: pass the--deleteoptions to rsync. Of course, you should be very careful with this. False by default.dry_run: pass the--dry_runoptions to rsync. False by default. Please note that unfortunately, rsync will still perform some checks. For example, it will raise an error if a directory doesn’t exist.verbose: pass the--verboseoptions to rsync. False by default.extra_options: a string that will be appended to the rsync command.
-
run(command[, options])¶ Execute command (a string) on the server, blocking until it is completed and return a
CommandResultinstance.The final command will look like this:
bash -l -c "{escaped_command}"Options include:
output: whether the output of the command should be printed (currently, the content of stderr is always printed). True by default.ok_exit_statuses: an array of process exit statuses that indicate success. [0] by default.dry_run: the value you set inSshSession‘s options. May be overriden.verbose: the value you set inSshSession‘s options. May be overriden.characters_to_escape: the value you set inSshSession‘s options. May be overriden.shell: the value you set inSshSession‘s options. May be overriden.
-