Module: EY::Metadata::SshAliasHelper
- Included in:
- ChefDna, EngineYardCloudApi
- Defined in:
- lib/engineyard-metadata/ssh_alias_helper.rb
Instance Method Summary collapse
-
#ssh_alias(counter, role_group, public_hostname) ⇒ Object
Used internally to generate a single ssh alias.
-
#ssh_aliases ⇒ Object
Aliases like ‘my_env-app_master’ or ‘my_env-utilities-5’ that go in .ssh/config.
Instance Method Details
#ssh_alias(counter, role_group, public_hostname) ⇒ Object
Used internally to generate a single ssh alias.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/engineyard-metadata/ssh_alias_helper.rb', line 21 def ssh_alias(counter, role_group, public_hostname) id = case role_group when 'db_slaves', 'app_slaves', 'utilities' "#{role_group}-#{counter[role_group] += 1}" else role_group end %{Host #{environment_name}-#{id} Hostname #{public_hostname} User #{ssh_username} StrictHostKeyChecking no } end |
#ssh_aliases ⇒ Object
Aliases like ‘my_env-app_master’ or ‘my_env-utilities-5’ that go in .ssh/config
For example:
Host my_env-app_master
Hostname ec2-111-111-111-111.compute-1.amazonaws.com
User deploy
StrictHostKeyChecking no
11 12 13 14 15 16 17 18 |
# File 'lib/engineyard-metadata/ssh_alias_helper.rb', line 11 def ssh_aliases counter = Hash.new 0 %w{ app_master db_master db_slaves app_slaves utilities }.map do |role_group| [send(role_group)].flatten.map do |public_hostname| ssh_alias counter, role_group, public_hostname end end.flatten.join("\n") end |