---- hosts: server gather_facts: no
tasks: - name: Create a file in the server /etc file system file: path: /etc/test.txt state: touch become: yes become_password: mySecretpw # this does NOT work, what should?
- command: whoami
become: yes
become_user: user
vars:
ansible_become_password: password
The vars key can be used to set any variable for that particular task and it can even include ansible_become_user if you want to override the host variable if set where become_user is just a fallback.
Thanks
Jordan