Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58555

Ansible Plugin CredentialsID Overriden by ansible_ssh_key variable



    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: ansible-plugin
    • Labels:
    • Environment:
      Jenkins v2.185 running on jenkins-kubernetes-plugin
      Ansible Plugin v1.0
    • Similar Issues:


      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 :

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



          There are no comments yet on this issue.


            sirot Jean-Christophe Sirot
            dimasrizkyhp Dimas Rizky
            0 Vote for this issue
            1 Start watching this issue