Reputation: 170470
I am fully aware about the become_user
functionality in Ansible but there is something that I don't really get: how to easily perform actions as different users without having to specify the user for each of them.
It seems to be a real pain to add the become for every task, I am looking for a way to switch current user for multiple tasks.
Having to create new task files for each "block" would make the entire deployment logic quite hard to follow.
Upvotes: 1
Views: 85
Reputation: 59989
There only are two options: Includes or blocks.
Includes are the only option in Ansible 1:
- include: run_as_user_x.yml
become: true
become_user: x
In Ansible 2 the blocks concept has been introduced:
- block:
- some task
- another task
- task n
become: true
become_user: x
Upvotes: 2