[JIRA] (JENKINS-58555) Ansible Plugin CredentialsID Overriden by ansible_ssh_key variable

8 views
Skip to first unread message

dimas.rizky.hp@gmail.com (JIRA)

unread,
Jul 18, 2019, 11:19:02 AM7/18/19
to jenkinsc...@googlegroups.com
Dimas Rizky created an issue
 
Jenkins / Bug JENKINS-58555
Ansible Plugin CredentialsID Overriden by ansible_ssh_key variable
Issue Type: Bug Bug
Assignee: Jean-Christophe Sirot
Components: ansible-plugin
Created: 2019-07-18 15:18
Environment: Jenkins v2.185 running on jenkins-kubernetes-plugin
Ansible Plugin v1.0
Priority: Minor Minor
Reporter: Dimas Rizky

So, in my private ansible repository, I have define `all` variables in each inventory group_vars. In those `all` group_vars I defined `ansible_ssh_key` to keys to other directory in same repository. Since I save it up on my git repo I'm not uploading my key files content, there's only placeholder for it, and to use it I manually copy the key content to the ansible controller after I clone the repository

The problem comes when I use jenkins to run my playbook, since I'm using k8s jenkins plugin, the executor will only spawned whenever the jobs get queued, and before I can ran my playbook, I have to clone my ansible repository. Which means the executor will only have my cloned ansible repository with `empty placeholder key` file. Since ansible plugin is providing `credentialsId` for the ssh access, I think it should just go fine, because the provided credentials will be used instead of my self declared `ansible_ssh_key`. But i was wrong, the key that is being used is the one I define on `ansible_ssh_key` variables.

My question is, is this expected behaviour ? Or there's something that I missing here ? Pls pardon me with my long explanation just to ask such simple question. Thanks gentlement

This is how I invoke the stage to clone & run the playbook :

pipeline{
{{  agent { label 'Jenkins-slave' }}}
   stages {
    stage('Clone Ansible'){
     steps {
      echo 'Cloning Ansible to ansible'
      git changelog: false, credentialsId: 'buildbot-pk', poll: false, url: 'g...@github.com:myrepo/ansible.git'{{}}
{{     }}}
{{    }}}
    stage('Run Ansible'){
     steps {}}{{
      ansiblePlaybook colorized: true, credentialsId: 'root-production', disableHostKeyChecking: true, inventory: 'myinventory', playbook: 'myplaybook.yml', tags: 'mytag'
{{     }}}
{{    }}}
{{   }}}
 }

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

dimas.rizky.hp@gmail.com (JIRA)

unread,
Jul 18, 2019, 11:23:03 AM7/18/19
to jenkinsc...@googlegroups.com
Dimas Rizky updated an issue
Change By: Dimas Rizky
So, in my private ansible repository, I have define `all` variables in each inventory group_vars. In those `all` group_vars I defined `ansible_ssh_key` to keys to other directory in same repository. Since I save it up on my git repo I'm not uploading my key files content, there's only placeholder for it, and to use it I manually copy the key content to the ansible controller after I clone the repository

The problem comes when I use jenkins to run my playbook, since I'm using k8s jenkins plugin, the executor will only spawned whenever the jobs get queued, and before I can ran my playbook, I have to clone my ansible repository. Which means the executor will only have my cloned ansible repository with `empty placeholder key` file. Since ansible plugin is providing `credentialsId` for the ssh access, I think it should just go fine, because the provided credentials will be used instead of my self declared `ansible_ssh_key`. But i was wrong, the key that is being used is the one I define on `ansible_ssh_key` variables.

 

My question is, * is this expected behaviour * ? Or there's something that I missing here ? Pls pardon me with my long explanation just to ask such simple question. Thanks gentlement

 

This is how I invoke the stage to clone & run the playbook :
{code:java}

pipeline{
    agent { label 'Jenkins-slave' }
    stages {
        stage('Clone Ansible'){
            steps {
                echo 'Cloning Ansible to ansible'
                git changelog: false, credentialsId: 'buildbot-pk', poll: false, url: 'g...@github.com:myrepo/ansible.git'
            }
        }
        stage('Run Ansible'){
            steps {
                ansiblePlaybook colorized: true, credentialsId: 'root-production', disableHostKeyChecking: true, inventory: 'myinventory', playbook: 'myplaybook.yml', tags: 'mytag'
            }
        }
    }
}{code}

dimas.rizky.hp@gmail.com (JIRA)

unread,
Jul 18, 2019, 11:23:03 AM7/18/19
to jenkinsc...@googlegroups.com
Dimas Rizky updated an issue
So, in my private ansible repository, I have define `all` variables in each inventory group_vars. In those `all` group_vars I defined `ansible_ssh_key` to keys to other directory in same repository. Since I save it up on my git repo I'm not uploading my key files content, there's only placeholder for it, and to use it I manually copy the key content to the ansible controller after I clone the repository

The problem comes when I use jenkins to run my playbook, since I'm using k8s jenkins plugin, the executor will only spawned whenever the jobs get queued, and before I can ran my playbook, I have to clone my ansible repository. Which means the executor will only have my cloned ansible repository with `empty placeholder key` file. Since ansible plugin is providing `credentialsId` for the ssh access, I think it should just go fine, because the provided credentials will be used instead of my self declared `ansible_ssh_key`. But i was wrong, the key that is being used is the one I define on `ansible_ssh_key` variables.

My question is, is this expected behaviour ? Or there's something that I missing here ? Pls pardon me with my long explanation just to ask such simple question. Thanks gentlement


This is how I invoke the stage to clone & run the playbook :

 
{code:java}
pipeline{
    agent { label 'Jenkins-slave' }
    stages {
        stage('Clone Ansible'){
            steps {
                echo 'Cloning Ansible to ansible'
                git changelog: false, credentialsId: 'buildbot-pk', poll: false, url: 'g...@github.com:myrepo/ansible.git'
            }
        }
        stage('Run Ansible'){
            steps {
                ansiblePlaybook colorized: true, credentialsId: 'root-production', disableHostKeyChecking: true, inventory: 'myinventory', playbook: 'myplaybook.yml', tags: 'mytag'
            }
        }
    }
}{code}

dimas.rizky.hp@gmail.com (JIRA)

unread,
Jul 18, 2019, 11:23:04 AM7/18/19
to jenkinsc...@googlegroups.com
Dimas Rizky updated an issue
So, in my private ansible repository, I have define `all` variables in each inventory group_vars. In those `all` group_vars I defined `ansible_ssh_key` to keys to other directory in same repository. Since I save it up on my git repo I'm not uploading my key files content, there's only placeholder for it, and to use it I manually copy the key content to the ansible controller after I clone the repository

The problem comes when I use jenkins to run my playbook, since I'm using k8s jenkins plugin, the executor will only spawned whenever the jobs get queued, and before I can ran my playbook, I have to clone my ansible repository. Which means the executor will only have my cloned ansible repository with `empty placeholder key` file. Since ansible plugin is providing `credentialsId` for the ssh access, I think it should just go fine, because the provided credentials will be used instead of my self declared `ansible_ssh_key`. But i was wrong, the key that is being used is the one I define on `ansible_ssh_key` variables.

My question is, is this expected behaviour ? Or there's something that I missing here ? Pls pardon me with my long explanation just to ask such simple question. Thanks gentlement

This is how I invoke the stage to clone & run the playbook :

 
{ {pipeline{ code:java } }
pipeline {
agent \ { label 'Jenkins-slave' } }}
{{   stages { }}
{{    stage('Clone Ansible'){ }}
{{     steps { }}
{{      echo 'Cloning Ansible to ansible' }}
{{      git changelog: false, credentialsId: 'buildbot-pk', poll: false, url: 'g...@github.com:myrepo/ansible.git' }}{{}}
{{     } }}
{{    } }}
{{    stage('Run Ansible'){ }}
{{     steps { }}{{}}{{}}
{{      ansiblePlaybook colorized: true, credentialsId: 'root-production', disableHostKeyChecking: true, inventory: 'myinventory', playbook: 'myplaybook.yml', tags: 'mytag' }}
{{     } }}
{{    } }}
{{   } }}
} { code } }}
Reply all
Reply to author
Forward
0 new messages