Fix duplicatded 'ssh-rsa' issue with template authorized_keys.erb

Even the input ssh_key has a string 'ssh-rsa', it would still generate
a new 'ssh-rsa' in authorized_keys with the template authorized_keys.erb
which would lead fail to authorize.

Change-Id: I851399ff30f611cc8fbae6651661b54117a4b8ae
This commit is contained in:
Yu Zhang 2017-11-03 14:03:35 +08:00
parent 7a9eafd698
commit dcb0568dfe
1 changed files with 12 additions and 4 deletions

View File

@ -1,10 +1,18 @@
# HEADER: This file has been autogenerated by puppet.
# HEADER: While it can still be managed manually, it
# HEADER: is definitely not recommended.
<% if @ssh_key.is_a? Array -%>
<% @ssh_key.each do |key| -%>
<% if @ssh_key.is_a? Array %>
<% @ssh_key.each do |key| %>
<% if key.include? 'ssh-rsa' %>
<%= key %>
<% else %>
ssh-rsa <%= key %>
<% end -%>
<% end %>
<% end %>
<% else %>
<% if @ssh_key.include? 'ssh-rsa' %>
<%= @ssh_key %>
<% else %>
ssh-rsa <%= @ssh_key %>
<% end -%>
<% end %>
<% end %>