How to add password variables?

I have a task that calls a root password from my vault.yml by adding it to the task as:

vars: ansible_become_pass:"{{ root }}"

However, I have to use it multiple times within my tasks/main.yml. Is is possible to add that variable once to vars/main.yml

Here is what my tasks/main.yml looks like:

`

OK, I figured this out. I added the following to my site.yml:

`

  • name: install app to all test servers
    hosts: testservers
    become: yes
    user: service_account
    vars_files:
  • vault.yml
    vars:
    ansible_become_pass: “{{ root }}”

roles:

  • pb_install_test

`