ansiblePlaybook fails when running the playbook without sshagent block

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • Component/s: ansible-plugin
    • None

      Below pipeline codeĀ 

      stage('Ansible Run') {
                              ansiblePlaybook(
                                  become: true,
                                  colorized: true,
                                  credentialsId: "$params.Env",
                                  vaultCredentialsId: "$JENKINS_VAULT_ID",
                                  inventory: "inventory/$params.Env",
                                  limit: "$parsed_limit",
                                  playbook: 'playbooks/ng-app-expire-yum-cache.yml'
                              )
                              ansiblePlaybook(
                                  become: true,
                                  colorized: true,
                                  credentialsId: "$params.Env",
                                  vaultCredentialsId: "$JENKINS_VAULT_ID",
                                  inventory: "inventory/$params.Env",
                                  limit: "$parsed_limit",
                                  playbook: 'site-aws.yml',
                                  extras: "-e deployment=$JIRA"
                              )
                          }
      
      

      Gives the below errorĀ 

      PLAY [Expire Yum cache] ********************************************************
      
      TASK [Expire yum cache] ********************************************************
      Friday 08 October 2021  12:29:25 -0500 (0:00:00.439)       0:00:00.439 ******** 
      fatal: [ip-10-114-xx-xxx.eu-central-1.compute.internal]: UNREACHABLE! => {"changed": false, "msg": "Data could not be sent to remote host \"10.114.xx.xxx\". Make sure this host can be reached over ssh: Warning: Permanently added 'bastion.emea.trustwave.cloud,xx.xxx.xx.xxx' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\nssh_exchange_identification: Connection closed by remote host\r\n", "unreachable": true}
      fatal: [ip-10-114-xx-xxx.eu-central-1.compute.internal]: UNREACHABLE! => {"changed": false, "msg": "Data could not be sent to remote host \"10.114.xx.xxx\". Make sure this host can be reached over ssh: Warning: Permanently added 'bastion.emea.trustwave.cloud,xx.xxx.xx.xxx' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\nssh_exchange_identification: Connection closed by remote host\r\n", "unreachable": true}
      

      When adding the sshagent block and running the same pipeline code the ansible playbook runs fine.

      The plugin is not recognizing the credentialId option passed to the ansible playbook commandĀ 

           stage('Ansible Run') {
                              sshagent (credentials: ["$params.Env"]) {
                                  ansiblePlaybook(
                                      become: true,
                                      colorized: true,
                                      credentialsId: "$params.Env",
                                      vaultCredentialsId: "$JENKINS_VAULT_ID",
                                      inventory: "inventory/$params.Env",
                                      limit: "$parsed_limit",
                                      playbook: 'playbooks/ng-app-expire-yum-cache.yml'
                                  )
                                  ansiblePlaybook(
                                      become: true,
                                      colorized: true,
                                      credentialsId: "$params.Env",
                                      vaultCredentialsId: "$JENKINS_VAULT_ID",
                                      inventory: "inventory/$params.Env",
                                      limit: "$parsed_limit",
                                      playbook: 'site-aws.yml',
                                      extras: "-e deployment=$JIRA"
                                  )
                              }
                          }
      
      

            Assignee:
            Jean-Christophe Sirot
            Reporter:
            Tarun Hasija
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: