chef-ssh icon indicating copy to clipboard operation
chef-ssh copied to clipboard

TypeError: no implicit conversion of Symbol into Integer when empty line is present in the authorized_keys file

Open saper opened this issue 6 years ago • 0 comments

I don't know how the empty line got in to the authorized_keys file (maybe this is another bug in this cookbook), but when the first line is empty and we try to maintain the key which already exists (nothing should change) we get an exception.

Removing a line by hand works.

Cookbook version:

name             'ssh'
maintainer       'Tejay Cardon'
maintainer_email '[email protected]'
license          'Apache 2.0'
description      'LWRPs for managing SSH known_hosts and config files'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version          '0.10.24'
issues_url 'https://github.com/markolson/chef-ssh/issues'
source_url 'https://github.com/markolson/chef-ssh'

supports 'ubuntu'
supports 'rhel'

Stacktrace:

  * ssh_authorized_keys[remote server access for Xxxx - 201909] action add
    
    ================================================================================
    Error executing action `add` on resource 'ssh_authorized_keys[remote server access for Xxxx - 201909]'
    ================================================================================
    
    TypeError
    ---------
    no implicit conversion of Symbol into Integer
    
    Cookbook Trace:
    ---------------
    /etc/chef/local-mode-cache/cache/cookbooks/ssh/providers/authorized_keys.rb:25:in `[]'
    /etc/chef/local-mode-cache/cache/cookbooks/ssh/providers/authorized_keys.rb:25:in `block (2 levels) in class_from_file'
    /etc/chef/local-mode-cache/cache/cookbooks/ssh/providers/authorized_keys.rb:25:in `each'
    /etc/chef/local-mode-cache/cache/cookbooks/ssh/providers/authorized_keys.rb:25:in `find'
    /etc/chef/local-mode-cache/cache/cookbooks/ssh/providers/authorized_keys.rb:25:in `block in class_from_file'
    /etc/chef/local-mode-cache/cache/cookbooks/ssh/providers/authorized_keys.rb:13:in `block in class_from_file'
    
    Resource Declaration:
    ---------------------
    # In /etc/chef/local-mode-cache/cache/cookbooks/lmcrm/recipes/user.rb
    
     76: ssh_authorized_keys "remote server access for Xxxx - 201909" do
     77: 	user 'xxx'
     78: 	key 'AAAAB3NzaC1yc2EAAAABJQAAAQEA4ntKq2j33CIKgoqNpd1aYPWVs3sR1yNV/G8kdpV1VNs7oAJqkVugEX7cbSlP8UEdYDfIvu0yEzwL850eoze03SY0ZCELfPeh9mR/zqd1i0a8cK7BQrUpruerCtEy8mXEtSh9DqcjTSpDqeuJC9eHJHbMkSR9OEOkCh4GPVNUUho0tSvzPBN07ewP4cuRe2Fx0xLtuVWllPFGELE48MW+l5hYLcfV5gIegQzgoYtjAX2XrSs8/gpQsp0IcVjPCC4wj9tLhLkTfs8sJR4mpFwZIbHide2fAyb7xKkdDU7lkS+ZDVcbM41Cia5noTJoQIcqoLmnfjTCOxtCI19ahZJuZQ=='
     79: 	comment 'Xxxx'
     80: 
     81: end
     82: user 'zzzz' do
    
    Compiled Resource:
    ------------------
    # Declared in /etc/chef/local-mode-cache/cache/cookbooks/lmcrm/recipes/user.rb:76:in `from_file'
    
    ssh_authorized_keys("remote server access for Xxxx - 201909") do
      action [:add]
      default_guard_interpreter :default
      declared_type :ssh_authorized_keys
      cookbook_name "yyy"
      recipe_name "user"
      user "xxx"
      key "AAAAB3NzaC1yc2EAAAABJQAAAQEA4ntKq2j33CIKgoqNpd1aYPWVs3sR1yNV/G8kdpV1VNs7oAJqkVugEX7cbSlP8UEdYDfIvu0yEzwL850eoze03SY0ZCELfPeh9mR/zqd1i0a8cK7BQrUpruerCtEy8mXEtSh9DqcjTSpDqeuJC9eHJHbMkSR9OEOkCh4GPVNUUho0tSvzPBN07ewP4cuRe2Fx0xLtuVWllPFGELE48MW+l5hYLcfV5gIegQzgoYtjAX2XrSs8/gpQsp0IcVjPCC4wj9tLhLkTfs8sJR4mpFwZIbHide2fAyb7xKkdDU7lkS+ZDVcbM41Cia5noTJoQIcqoLmnfjTCOxtCI19ahZJuZQ=="
      comment "Xxxx"
    end
    
    System Info:
    ------------
    chef_version=13.0.118
    platform=debian
    platform_version=6.0.4
    ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
    program_name=chef-solo worker: ppid=28010;start=11:32:37;
    executable=/opt/chef/bin/chef-solo
    

saper avatar Sep 20 '19 09:09 saper