Class: Anvil::Cloudinit::Generator
- Inherits:
-
Struct
- Object
- Struct
- Anvil::Cloudinit::Generator
- Defined in:
- lib/anvil/cloudinit/generator.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#public_key_path ⇒ Object
Returns the value of attribute public_key_path.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename
5 6 7 |
# File 'lib/anvil/cloudinit/generator.rb', line 5 def filename @filename end |
#hostname ⇒ Object
Returns the value of attribute hostname
5 6 7 |
# File 'lib/anvil/cloudinit/generator.rb', line 5 def hostname @hostname end |
#public_key_path ⇒ Object
Returns the value of attribute public_key_path
5 6 7 |
# File 'lib/anvil/cloudinit/generator.rb', line 5 def public_key_path @public_key_path end |
#user ⇒ Object
Returns the value of attribute user
5 6 7 |
# File 'lib/anvil/cloudinit/generator.rb', line 5 def user @user end |
Instance Method Details
#call ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/anvil/cloudinit/generator.rb', line 6 def call public_key = public_key_path.to_s.gsub("~", Dir.home) if File.exist?(public_key) puts File.read(filename).gsub("%{USER}", user).gsub("%{HOSTNAME}", hostname).gsub("%{PUBLIC_KEY}", File.read(public_key)) else puts "Cannot find public key file at #{public_key}" end end |