How to pass multiple windows credentials in AWX credential section?

Current Setup.:

  • Currently we have created multiple certificates for multiple windows servers.
  • Added all the certificates in AWX tower with name cert57, cert58.
  • Now I want to ping the both windows server from Jenkins with the help of ansible tower pluging.
pipeline {
    agent { label 'linux' }

    stages {
        stage('Launch AWX job') {
            steps {
                script {
                    wrap([$class: 'AnsiColorBuildWrapper', colorMapName: "xterm"]) {
                        ansibleTower(
                            towerServer: 'stg-awx',
                            jobTemplate: 'win_ping',
                            jobType: 'run',
                            importTowerLogs: true,
                            removeColor: false,
                            credential: 'cert57',
                            verbose: true
                        )
                    }
                }
            }
        }
    }
}

  • in the above pipeline if I pass 1 credentials it works fine.
  • anyone have any idea how to pass multiple credentials at once ?

I’m not familiar with how that Jenkins plugin works, but generally credentials are passed in as a list when called via the api. Looking at the plugin’s site, Ansible Tower it kinda seems like you can’t pass in multiple credentials. Maybe you can get around this by having the job template itself be set up multiple credentials rather than having Jenkins set it.

However, the other problem you’re going to run in to is that you can only associate one of each credential type to a job template. So if cert57 and cert58 are the same credential type, such as a “Machine” credential, you’re going to have to get creative to make it work. It’s difficult to lay out what options exist without knowing what you’re trying to do and how you intend to do it, but at a high level, you can have your job reach out to a secret store like Hashicorp vault to retrieve the certs or use ansible-vault to decrypt the certificates from somewhere.

Thanks for the reply @mcen1 , is it supported via api call ?

Having multiple credentials of the same type is not supported by AWX itself. I think this is because the credentials occupy one variable name, so it wouldn’t work. You’d be boiling down multiple usernames/passwords/certs to one output, so you’d inevitably lose info about all but one of them.

If you create a new custom credential type, that’d be a third way of getting multiple credentials on the same template, but you need to be fully aware of what you’re doing and how you’re doing it. You’d need to know which sets of servers belong with which credential. It will get messy and complicated quickly.