Doorway
Sane set of utility methods to provision remote servers over SSH and SCP.
Installation
Add this line to your application's Gemfile:
gem 'doorway'
And then execute:
$ bundle
Or install it yourself as:
$ gem install doorway
Usage
doorway = Doorway.connect(:root, "10.0.1.20", :ssh_key => "~/.keys/somekey.pem")
doorway.exec "ls -la"
# -or-
Doorway.connect(:deployer, "10.0.1.20", :ssh_key => "~/.keys/deployer.pem") do |conn|
# Raw command execution
conn.exec "whoami"
conn.exec_as :root, "REALLY_GEM_UPDATE_SYSTEM=y gem update --system"
# Script execution
conn.exec_script "\n #!/bin/bash\n apt-get install -y some-package\n\n EOS\n\n conn.exec_script_as :git, \"scripts/add-public-ip\"\n\n # Remote files\n\n conn.remote_file \"/etc/nginx/nginx.conf\", \"nginx/nginx.conf\"\n conn.remote_file \"/etc/init.d/nginx\", \"nginx/nginx.init.d\"\n conn.append_from \"/etc/nginx/nginx.conf\", \"nginx/include\"\n\n # ERB templates \n\n conn.remote_file \"/etc/nginx/conf.d/site.conf\",\n :template => \"nginx/vhost.conf.erb\",\n :server => \"www.example.org\",\n :root => \"/var/www/example\"\n\n conn.append_from \"/etc/sudoers.d/my_sudoers\",\n :template => \"sudoers/god.erb\",\n :user => \"fcoury\",\n :allow => \"/var/bin/all_your_base\"\n\n # Download a file to server\n\n conn.get \"https://webbynode_packages.s3.amazonaws.com/icecream-8.30.tar.gz\", \"/usr/local/src\"\n\n # Ubuntu specific package management\n\n conn.add_ppa \"chris-lea/node.js\"\n conn.install \"nodejs\"\n\n # Advanced commands\n\n conn.sed \"/home/git/repo/.git/config\", \n /remote \"github\"/, 'remote \"bitbucket\"'\nend\n".strip_heredoc
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request