# Pass more than one credential to a job template

**URL:** <https://forum.ansible.com/t/pass-more-than-one-credential-to-a-job-template/31010>\
**Category:** AWX Project\
**Tags:** vmware, awx\
**Created:** [August 9, 2019, 3:13pm UTC](https://forum.ansible.com/t/pass-more-than-one-credential-to-a-job-template/31010 "2019-08-09T15:13:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angel\_Rengifo\_Cancin](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Angel\_Rengifo\_Cancin](https://forum.ansible.com/u/Angel_Rengifo_Cancin)\
**Post date:** [August 9, 2019, 3:13pm UTC](https://forum.ansible.com/t/pass-more-than-one-credential-to-a-job-template/31010/1 "2019-08-09T15:13:11Z")

</div>

Hello people:

I wonder if would be possible, somehow, to pass more than 1 credential set to a certain job template in AWX. It happens that I use ansible for creating VM templates on VMware, so I’m currently using a vCenter credential to my playbook, but also I’d like to pass another credentials for setting up the root or administrator password for the operating system VM.

Hope someone can give me some idea about how to achieve this, if there’s some way to do it.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Scott\_R\_Bowe](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@Scott\_R\_Bowe](https://forum.ansible.com/u/Scott_R_Bowe)\
**Post date:** [August 9, 2019, 3:20pm UTC](https://forum.ansible.com/t/pass-more-than-one-credential-to-a-job-template/31010/2 "2019-08-09T15:20:40Z")

</div>

I handle situations like that by putting my credentials into a vault file that is part of my project - apply those credentials via groups and then have the credential for the vault file in the Alex job template

---

<div class="post-metadata">

**Author:** ![David\_Maple](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@David\_Maple](https://forum.ansible.com/u/David_Maple)\
**Post date:** [August 9, 2019, 4:01pm UTC](https://forum.ansible.com/t/pass-more-than-one-credential-to-a-job-template/31010/3 "2019-08-09T16:01:11Z")

</div>

You can only pass one machine credential, but you can attach other credential types to the same template or job. You could set up a custom credential type to hold anything you want to add. I usually add credentials that contain values for notification modules, like Slack or API credentials that include tokens and/or URLs.

Best of luck,

Dave

---

<div class="post-metadata">

**Author:** ![Angel\_Rengifo\_Cancin](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Angel\_Rengifo\_Cancin](https://forum.ansible.com/u/Angel_Rengifo_Cancin)\
**Post date:** [August 9, 2019, 5:11pm UTC](https://forum.ansible.com/t/pass-more-than-one-credential-to-a-job-template/31010/4 "2019-08-09T17:11:09Z")

</div>

Hi:

---

<div class="post-metadata">

**Author:** ![Angel\_Rengifo\_Cancin](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Angel\_Rengifo\_Cancin](https://forum.ansible.com/u/Angel_Rengifo_Cancin)\
**Post date:** [August 9, 2019, 5:12pm UTC](https://forum.ansible.com/t/pass-more-than-one-credential-to-a-job-template/31010/5 "2019-08-09T17:12:17Z")

</div>

Hi:

> You can only pass one machine credential, but you can attach other credential types to the same template or job. You could set up a custom credential type to hold anything you want to add. I usually add credentials that contain values for notification modules, like Slack or API credentials that include tokens and/or URLs.

OK, great, I can create custom credentials, but how do I reference those custom credentials in my playbook invoked through AWX? I haven’t created any custom credential yet, but I guess I would pass it as argument in the same way as a Network credential, am I right?

---

<div class="post-metadata">

**Author:** ![David\_Maple](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@David\_Maple](https://forum.ansible.com/u/David_Maple)\
**Post date:** [August 9, 2019, 8:05pm UTC](https://forum.ansible.com/t/pass-more-than-one-credential-to-a-job-template/31010/6 "2019-08-09T20:05:31Z")

</div>

Add credential values to a job as extra\_vars using the injector configuration of your custom credential type. For example, I create a custom credential type like this:

CREDENTIAL TYPE  
Slack Token

INPUT CONFIGURATION  
fields:

- id: token  
type: string  
required:
- token

INJECTOR CONFIGURATION  
extra\_vars:  
slack\_token: ‘{{ token }}’

Then, create a credential with that type and attach it to your template, in addition to a machine credential. Then, in the playbook, I can reference the variable “slack\_token” as if I set it in the extra\_vars field of the template:

```auto
- name: notify-slack
  delegate_to: localhost
  become: no
  slack:
    token: "{{ **slack_token** }}"
    channel: "{{ slack_channel | default('#ansible') }}"
    username: "{{ slack_user | default('Enterprise-Ansible') }}"
    msg: "{{ slack_message }}"

```

---

<div class="post-metadata">

**Author:** ![Angel\_Rengifo\_Cancin](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Angel\_Rengifo\_Cancin](https://forum.ansible.com/u/Angel_Rengifo_Cancin)\
**Post date:** [August 9, 2019, 8:30pm UTC](https://forum.ansible.com/t/pass-more-than-one-credential-to-a-job-template/31010/7 "2019-08-09T20:30:40Z")

</div>

Ooh I got it, thank you so much. I’m going to test this to see how it works.

Thanks again everyone!
