I need to use two different credentials for a single playbook in Ansible Tower Job-Template. In the playbook, I include two roles(one for Windows machine, one for Linux machine). While configuring the job-template, I have noticed that I am not able to select two machine credentials, hence the playbook fails.
I have found a solution here https://stackoverflow.com/a/55870311/4715624, which includes creating two Ansible vaults (with the same vault password) under host_vars
folder and saving the passwords there. This solution works from the command line e.g.
ansible-playbook -v test-multi-credential-playbook-in-ansible-tower.yml --ask-vault-pass
Then I have created a vault type credential in Ansible Tower and tried to run the corresponding job with the that credential. But this doesn't work (authentication problem). Can someone please show me the correct way to use multiple credentials for a single playbook in Ansible Tower? Or it's not possible at all in Ansible Tower?
UPDATE: My playbook looks like this:
---
- hosts: all
gather_facts: true
tasks:
- name: Include ping linux task
include_role:
name: roles/linux
when: ansible_os_family != "Windows"
- name: Include ping windows task
include_role:
name: roles/windows
when: ansible_os_family == "Windows"