'Ansible AWX / Tower - Use Vault credential in playbook

In Ansible AWX I created a Vault-credential (named: user-pw). Now I want to use that password in a playbook. But it doesn't work.

I created a template, add the Vault-credential (at the credential input). In the playbook I used the variable "{{ user-pw }}" at the place where the password should be.

What am I doing wrong? How do I get the AWX Vault password in the playbook as a variable?

This is the vault credential screen: Vault credential

And this is the template screen: Template

And this is the test playbook:

---
- name: Vaulttest
  hosts: win

  tasks:
    - name: View user pw
      debug:
        msg: "{{ user-pw }}"

Thanks in advance!



Solution 1:[1]

According the very minimal description it seems to be the correct approach for using Credentials, even Vault.

To debug Custom Credential Types I am using usually

- hosts: localhost
  gather_facts: yes

  tasks:

  - name: Get environment
    debug:
      msg: "{{ ansible_env }}"

resulting into an output of

TASK [Get environment] *********************************************************
ok: [localhost] => {
    "msg": [
        {
            ...
            "TEST_ACCOUNT_PASSWORD": "test_password", 
            "TEST_ACCOUNT_NAME": "test_account", 
            ...
        }
        ...

if such Custom Test Credentials are configured. This is working for AWX/Tower. You can then follow up with

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 U880D