• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • ansible-tower-plugin
    • None
    • Jenkins ver. 2.126
      Ansible Tower Plugin 0.8.5

      I have problem with the plugin when I want to use credentials other then the default.

      The credential id is 11

      "id": 11,
      "type": "credential",
      "url": "/api/v2/credentials/11/",
      

      The name of the credential is:
      "Secret Server MS Michal"

      "name": "Secret Server MS Michal"
      

       

      Does not matter if the ID or a Name is used in the configuration, the plugin is not able to find the credential in the Tower:

      Beginning Ansible Tower Run on Prod
      Requesting tower to run job template 37
      ERROR: Unable to request job template invocation Unable to find credential Secret Server MS Michal: Unable to get any results when looking up Secret Server MS Michal
      

      or

      ERROR: Unable to request job template invocation Credential 11 does not exist in tower
      

          [JENKINS-51770] Unable to find credential

          m t added a comment - - edited

          The difference between this credential and the rest is that this is a custom one, created through credential types.

          When checking the API the credentials are presented as follows:

          GET /api/v2/job_templates/33/
          
           "id": 33,
              "type": "job_template",
              "url": "/api/v2/job_templates/33/",
              "related": {
                  "named_url": "/api/v2/job_templates/!! DEV !! zadara provision vpsa/",
                  "created_by": "/api/v2/users/2/",
                  "modified_by": "/api/v2/users/2/",
                  "labels": "/api/v2/job_templates/33/labels/",
                  "inventory": "/api/v2/inventories/2/",
                  "project": "/api/v2/projects/20/",
                  "credential": "/api/v2/credentials/3/",
                  "vault_credential": "/api/v2/credentials/4/",
                  "extra_credentials": "/api/v2/job_templates/33/extra_credentials/",
          
          <...>
          
          "credential": {
                      "id": 3,
                      "name": "Default Credential",
                      "description": "Default credential for most of the jobs run localy",
                      "kind": "ssh",
                      "cloud": false,
                      "credential_type_id": 1
                  },
          
          <...>
          
          "extra_credentials": [
                      {
                          "description": "",
                          "credential_type_id": 15,
                          "id": 11,
                          "kind": null,
                          "name": "Secret Server MS Michal"
                      }
                  ]
          

          Looking at you code I guess the issue is with the key being called "extra_credentials" rather then "credential"

          m t added a comment - - edited The difference between this credential and the rest is that this is a custom one, created through credential types. When checking the API the credentials are presented as follows: GET /api/v2/job_templates/33/ "id" : 33, "type" : "job_template" , "url" : "/api/v2/job_templates/33/" , "related" : { "named_url" : "/api/v2/job_templates/!! DEV !! zadara provision vpsa/" , "created_by" : "/api/v2/users/2/" , "modified_by" : "/api/v2/users/2/" , "labels" : "/api/v2/job_templates/33/labels/" , "inventory" : "/api/v2/inventories/2/" , "project" : "/api/v2/projects/20/" , "credential" : "/api/v2/credentials/3/" , "vault_credential" : "/api/v2/credentials/4/" , "extra_credentials" : "/api/v2/job_templates/33/extra_credentials/" , <...> "credential" : { "id" : 3, "name" : "Default Credential" , "description" : "Default credential for most of the jobs run localy" , "kind" : "ssh" , "cloud" : false , "credential_type_id" : 1 }, <...> "extra_credentials" : [ { "description" : "", "credential_type_id" : 15, "id" : 11, "kind" : null , "name" : "Secret Server MS Michal" } ] Looking at you code I guess the issue is with the key being called "extra_credentials" rather then "credential"

          m t added a comment - - edited

          I tested the API and for the "extra credentials" it's expecting a key "extra credentials" with a list of id's.

          "extra_credentials": [11]
          

          Are you able to add this as a feture to your polugin, I guess the same issue will be with vault credentials since they have a uniqe key as well

           "vault_credential" 

          m t added a comment - - edited I tested the API and for the "extra credentials" it's expecting a key "extra credentials" with a list of id's. "extra_credentials" : [11] Are you able to add this as a feture to your polugin, I guess the same issue will be with vault credentials since they have a uniqe key as well "vault_credential"

          John Westcott added a comment -

          Thanks for your work on this. Let me reach out to the Tower folks at Red Hat. Instead of having multiple fields in Jenkins I'm wondering if I can query the credential type and then assign it to either credential, vault_credential or extra_credentials on the fly.

          John Westcott added a comment - Thanks for your work on this. Let me reach out to the Tower folks at Red Hat. Instead of having multiple fields in Jenkins I'm wondering if I can query the credential type and then assign it to either credential, vault_credential or extra_credentials on the fly.

          m t added a comment -

          I'm not sure that having just one credential options is vialable. I for one use multiple(different types) credentials in a play. So I would have a machine credential (required by Tower) a custom credential and some time a vault credential.

          m t added a comment - I'm not sure that having just one credential options is vialable. I for one use multiple(different types) credentials in a play. So I would have a machine credential (required by Tower) a custom credential and some time a vault credential.

          John Westcott added a comment -

          My thought was that we would have one credential(s) filed in jenkins which would take a comma delimited list. We could then parse the list, lookup the credentials and based on their credential types determine if they should be passed in as credential, vault_credential or extra_credentials. It looks like in the upcoming version of Tower instead of splitting them out into different categories we can just pass a single field called credentials and Tower will split them out. 

          John Westcott added a comment - My thought was that we would have one credential(s) filed in jenkins which would take a comma delimited list. We could then parse the list, lookup the credentials and based on their credential types determine if they should be passed in as credential, vault_credential or extra_credentials. It looks like in the upcoming version of Tower instead of splitting them out into different categories we can just pass a single field called credentials and Tower will split them out. 

          John Westcott added a comment -

          The could should be all set but I need to setup some environments to test the change on. If I commit the code to GitHub would you be able to download, build and test the plugin as well?

          John Westcott added a comment - The could should be all set but I need to setup some environments to test the change on. If I commit the code to GitHub would you be able to download, build and test the plugin as well?

          m t added a comment -

          johnwestcottiv I have not done any builds of plugins for Jenkins so I'm not sure if I'll be of any help. I can definitely test it, when it's available through Jenkins though.

          m t added a comment - johnwestcottiv I have not done any builds of plugins for Jenkins so I'm not sure if I'll be of any help. I can definitely test it, when it's available through Jenkins though.

          John Westcott added a comment -

          Sorry for the delay in getting this out, I had some vacation at the end of June. Please test out version 8.6.0 and let me know if you run into an issues. If not, please let me know and I an close this ticket.

          John Westcott added a comment - Sorry for the delay in getting this out, I had some vacation at the end of June. Please test out version 8.6.0 and let me know if you run into an issues. If not, please let me know and I an close this ticket.

          Matthew Winfield added a comment - - edited

          johnwestcottiv should multiple credential support be available in version 0.9.1?

          Also how would you specify multiple credentials in a pipeline job? I currently have a use case where I need to define 2 credentials for a job that I am trying to run from Jenkins with this plugin.

          Matthew Winfield added a comment - - edited johnwestcottiv should multiple credential support be available in version 0.9.1? Also how would you specify multiple credentials in a pipeline job? I currently have a use case where I need to define 2 credentials for a job that I am trying to run from Jenkins with this plugin.

            johnwestcottiv John Westcott
            mmt m t
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: