create an vault in AWX 5.0 multi environment

Hi can somebody help me with an advice on how to create an vault in AWX. I am trying to have the vcenter login data encrypted as string variable in a vault but don’t know how.
Thanks.

Hello,

Why don’t you use the VMWare vCenter credential type in AWX?
https://docs.ansible.com/ansible-tower/latest/html/userguide/credentials.html#vmware-vcenter

You can access the credentials from the environment variables like VMWARE_HOST, VMWARE_USER, etc.

Yes I did tried that but is not working. I am adding the credentials to the template (the credentials are ok because I can sync the inventory using them) but when running the playbook I get the error bellow. Is like the credentials are not there.

fatal: [localhost]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘VMWARE_USER’ is undefined\n\nThe error appears to be in ‘/var/lib/awx/projects/oracle-vm/create-vm-oracle-11g.yml’: line 8, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Clone VM from template\n ^ here\n”}

Hi,

The credentials are exposed as environment variables, not Ansible variable.

You need to use something like “{{ lookup(‘env’, ‘VMWARE_HOST’) }}” to access them.

Regards,

Thanks Sergio,

It is working I found later also an example in the documentation but it was not on the authentification page but on the template:

https://docs.ansible.com/ansible-tower/latest/html/userguide/job_templates.html#id6

But I am also curios how to use the Vault credential type. I am not able to find an example in the documentation.

Thanks.
daniel