Module: SshAuthorizedKeysCookbook::TemplateHelpers
- Defined in:
- libraries/template_helpers.rb
Overview
Some helpers to use from ssh_authorized_keys
cookbook templates.
Instance Method Summary collapse
-
#render_key(keytype, key, comment) ⇒ String
Returns a rendered key line for the authorized_keys file.
-
#render_option_value(name, value) ⇒ String
Returns the SSH key option properly escaped.
-
#render_options(options) ⇒ String
Returns the SSH key option list properly formated.
Instance Method Details
#render_key(keytype, key, comment) ⇒ String
Returns a rendered key line for the authorized_keys file.
70 71 72 |
# File 'libraries/template_helpers.rb', line 70 def render_key(keytype, key, comment) "#{keytype} #{key} #{comment}" end |
#render_option_value(name, value) ⇒ String
Returns the SSH key option properly escaped.
39 40 41 42 43 |
# File 'libraries/template_helpers.rb', line 39 def render_option_value(name, value) return name.to_s if value == true value_escaped = value.to_s.gsub('\\', '\\\\\\\\').gsub('"', '\\"') %(#{name}="#{value_escaped}") end |
#render_options(options) ⇒ String
Returns the SSH key option list properly formated.
57 58 59 |
# File 'libraries/template_helpers.rb', line 57 def () .map { |name, value| render_option_value(name, value) }.join(',') end |