http://stackoverflow.com/questions/37200337/is-there-anyway-to-run-multiple-ansible-playbooks-as-multiple-users-more-efficie/
Ansible uses the
become
, become_user
, and become_method
directives to achieve privilege escalation. You can apply them to an entire play or playbook, set them in an included playbook, or set them for a particular task.- name: checkout repo
git: repo=https://github.com/some/repo.git version=master dest={{ dst }}
become: yes
become_user: some_user
You can set the become
options per:
- playbook
- role
- task
Per playbook:
- hosts: whatever
become: yes
become_user: my_username
roles:
- checkout_sources
- install_dependencies
- make_dirs
Per role:
- hosts: whatever
roles:
- checkout_sources
- role: install_dependencies
become: yes
become_user: my_username
- make_dirs
Per task:
- shell: do something
become: yes
become_user: my_username
You can combine this however you like. The playbook can run as user A, a role as user B and finally a task inside the role as user C.
No comments:
Post a Comment