How to add become password in a task?

I’ve read the docs and it seems like all of them point me to coding the p/w either on the CLI or in group vars, but I want to do this

`

What works is in the documentation.
The reason you don't find something like this in the documentation is because the feature doesn't exist.

This can still be done, you can set the ansible_become_password variable using the vars argument like so;

- 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