Skip to content

Instantly share code, notes, and snippets.

@wtcross
Last active August 29, 2015 14:19
Show Gist options
  • Save wtcross/71221c6bf1d65839de12 to your computer and use it in GitHub Desktop.
Save wtcross/71221c6bf1d65839de12 to your computer and use it in GitHub Desktop.
become_user example

In a play All tasks are ran as the become_user user.

- name: Super awesome play.
  become_user: tyler

  tasks:
    - name: Some task
      copy: src=/foo dest=/bar

In a task Just this task ran as the become_user user.

- name: Some task
  copy: src=/foo dest=/bar
  become_user: tyler

Parameterized task file All tasks are ran as the become_user user.

# tasks/user-specific-tasks.yml
- name: Some task
  copy: src=/foo dest=/bar
  become_user: "{{ user }}"
# playbook.yml
- name: Super awesome play.

  tasks:
    - include: tasks/user-specific-tasks.yml user=tyler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment