Hello Ia trying to run an ansible playbook from in a declarative pipeline and passing a user credential via a credential parameter.
When the jobs run I select a private credential and use it in the ansible-playbook step.
However the job fails, since it cannot connect to the target hots.
From looking in the logs it appears to be the problem, that the credential i pass is not used.
In the logs on can sees that the connection is tried as user none and the keys from the jenkins user homedirectory are tried.
However I would have expected the the username and the private key from the credential are used.
Is there a way to achieve this?
Here are the relevant code snippets from the pipeline
credentials credentialType: 'com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey',
name: 'DEPLOY_CRED', required: true, defaultValue: '',
description: 'The credential used on the target systems for the deployment (Username, SSH Key)'
In fact the support for the credentialId parameter was my main reason to use the ansible plugin instead of running the playbook via a sh step. It was my hope that this would simply the boilerplate code for passing the credentials from the credential parameter to the playbook.
for debugging I used the extra parameter to pass the -vvvv option to ansible-playbook and the playbook provided quit a lot debug output, especially concerning the connection establishment.
From what I saw in the log, is, that the credential parameter selected my credential containing my userid and my private key,
However from the log for establishing the SSL connection it seams it ignores these credentials.
The user is reported as none and as keys the keys form the jenkins User directory are used.