sous-chefs / jenkins

Development repository for the jenkins cookbook
https://supermarket.chef.io/cookbooks/jenkins
Apache License 2.0
424 stars 635 forks source link

private_key_credentials fails without setting id parameter 2 #701

Closed bish0polis closed 5 years ago

bish0polis commented 5 years ago

Cookbook version

Uploading jenkins-farm [0.1.0] Uploading apt [6.1.4] Uploading java [2.2.0] Uploading jenkins [6.2.0] Uploading windows [3.1.3] Uploading homebrew [5.0.5] Uploading runit [4.3.0] Uploading dpkg_autostart [0.2.0] Uploading ohai [5.2.0] Uploading packagecloud [1.0.0] Uploading yum-epel [2.1.2] Uploading compat_resource [12.19.0]

Chef-client version

14.5.33

Platform Details

centos-release-7-5.1804.5.el7.centos.x86_64

Scenario:

I suspect I'm running into a bug similar to #232 , but only because the message is very similar.

As per https://github.com/myspotontheweb/chef-jenkins-farm/blob/master/recipes/master.rb#L23 ,

# create SSH credential
jenkins_private_key_credentials node['jenkins']['master']['user'] do
  username node['jenkins']['master']['user']
  description 'Jenkins Slave SSH Key'
  private_key lazy { File.read(privkey) }
end

It's running the same bit of code as #232 and, bobsled track that it is, it arrives at the same result:

host.name     Chef::Exceptions::ValidationFailed
host.name     ----------------------------------
host.name     id is a required property
host.name

But let's see if you see it too.

Steps to Reproduce:

chef-client -o java,jenkins-farm::master -j '<(echo {\"java\":{\"jdk_version\":\"8\"}})' -W

(the latter bit is to ensure it gets JRE 8)

Actual Result:

https://gist.github.com/bish0polis/4ef3060220aed737f5d201c63fda7811

So. Does this look like #232 is back? If it doesn't repro. let me know and I'll be good. I just can't see where I can be provoking this. I'm a noob, but I'm usually better at picking out the Learning Opportunities. ;-)

welcomebot commented 5 years ago

Hey There It looks like this is the first issue you've filed against the chef-cookbooks project. I'm here to offer you a bit of extra help to make sure we can quickly get back to you. Make sure you've filled out all the fields in our issue template. Make sure you've provided us with the version of chef-client you're running, your operating system and the version of the cookbook. If you're not using the most up to date version of the cookbook then please make sure to update first. Lots of things change between versions even if you're issue isn't listed in the changelog. Finally please give us a detailed description of the issue you're having. The more we know about what you're trying to do, what actually happens, and how you can reproduce the problem, the better.

If you're looking for more immediate troubleshooting help make sure to check out #general on the Chef Community Slack. There's plenty of folks there willing to lend a helping hand. Thanks for the first issue. We hope we can get back to you soon with a solution.

djessich commented 5 years ago

@bish0polis The username is the name property and the id is a required property (see examples in readme). Write it as follows and it should work:

# create SSH credential
jenkins_private_key_credentials node['jenkins']['master']['user'] do
  id "#{node['jenkins']['master']['user']}-key" # or whatever the id should be ...
  description 'Jenkins Slave SSH Key'
  private_key lazy { File.read(privkey) }
  # optional: passphrase 'some passphrase' 
end

For me the jenkins_private_key_credentials resource is working properly with the above structure.

bish0polis commented 5 years ago

Great! The particular project (jenkins) has become back-burnered after the devs discovered gitlab-ci would do most of what they need, but I'll test this once I have cycles to bring it back in.

So it looks like the ID was required, maybe for that field in the pubkey generation, but can be any format or content that's valid for ssh keys (e.g no spaces) . If so, then that's just too easy.

Thank you for coming back to this issue and ensuring I had something usable. I'll close this now, and reopen if it doesn't 100% solve my case (which it will, I'm sure).