Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How does one insert private key contents directly into private_key_or_path in jenkins::credentials? #452

Closed
coolguydork opened this issue Dec 15, 2015 · 3 comments

Comments

@coolguydork
Copy link

Hello,

I am on Puppet 3.8. I am using the jenkins::credentials. The declaration looks like this:

  jenkins::credentials { 'cred_for_deploying':
    password => '',
    private_key_or_path => '
    -----BEGIN RSA PRIVATE KEY-----
    content
    content
    content
    -----END RSA PRIVATE KEY-----'
  }

Puppet dislikes this. How do I put in a multiline value like this?

@jhoblitt
Copy link
Member

@haloflightleader There are few things you can do.

  • remove the newline from the start of the string, private_key_or_path => '-----Begin....
  • put the string in a variable or load it from hiera/enc
  • put the string in a template
  • migrate to puppet 4.x and use a heredoc.

@coolguydork
Copy link
Author

The script seems to be doing this:

/usr/bin/java -jar /usr/lib/jenkins/jenkins-cli.jar -s http://127.0.0.1:8080 groovy /usr/lib/jenkins/puppet_helper.groovy create_or_update_credentials user-sysadmin '' '' 'Managed by Puppet' '-----BEGIN RSA PRIVATE KEY-----
long private key contents
long private key contents
long private key contents
-----END RSA PRIVATE KEY-----
'

It tells me this when I run it by itself (this is also the output of puppet-agent):

"-----BEGIN RSA PRIVATE KEY-----
long private key contents
long private key contents
long private key contents
-----END RSA PRIVATE KEY-----
" is not a valid option
java -jar jenkins-cli.jar groovy [SCRIPT] [ARGUMENTS ...]
Executes the specified Groovy script. 
 SCRIPT    : Script to be executed. File, URL or '=' to represent stdin.
 ARGUMENTS : Command line arguments to pass into script.

I changed the declaration to a template as you had suggested:

  jenkins::credentials { 'user-sysadmin':
    password => '',
    private_key_or_path => template('common/private_key.erb'),
  }

This is the version of the module being used:

├── rtyler-jenkins (v1.6.1)

@bplunkert
Copy link

I'm also seeing this behavior. The workaround provided by @haloflightleader seems to work great. I think this is either still a bug, or an issue with the documentation (which reads: private_key_or_path is the text of key itself or an absolute path to a key file on the managed system.)

Could this be reopened since it seems to still be occurring? Or maybe the documentation should be updated if the recommended usage has changed?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants