Module: SSHKeygen::SSHKeygenProvider
- Included in:
- Provider
- Defined in:
- lib/ssh_keygen/provider.rb
Overview
provider fucntions for the SSHKeygen Chef resoruce provider class
Instance Method Summary collapse
- #create_key ⇒ Object
- #save_private_key ⇒ Object
- #save_public_key ⇒ Object
- #update_directory_permissions ⇒ Object
Instance Method Details
#create_key ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ssh_keygen/provider.rb', line 76 def create_key converge_by("Create SSH #{new_resource.type} #{new_resource.strength}-bit key (#{new_resource.comment})") do @key = ::SSHKeygen::Generator.new( new_resource.strength, new_resource.type, new_resource.passphrase, new_resource.comment ) end end |
#save_private_key ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ssh_keygen/provider.rb', line 87 def save_private_key converge_by("Create SSH private key at #{new_resource.path}") do f = file new_resource.path do action :nothing owner new_resource.owner group new_resource.group mode 0600 sensitive true end f.content(@key.private_key) f.run_action(:create) end end |
#save_public_key ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ssh_keygen/provider.rb', line 101 def save_public_key converge_by("Create SSH public key at #{new_resource.path}") do f = file "#{new_resource.path}.pub" do action :nothing owner new_resource.owner group new_resource.group mode 0600 end f.content(@key.ssh_public_key) f.run_action(:create) end end |
#update_directory_permissions ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ssh_keygen/provider.rb', line 114 def return false unless new_resource.secure_directory converge_by("Update directory permissions at #{File.dirname(new_resource.path)}") do directory ::File.dirname(new_resource.path) do action :create owner new_resource.owner group new_resource.group mode 0700 end end end |