Execute shell command as a different user?

I am probably missing something somewhere in the documentation but it is not clear to me how to execute a shell command as a different user.

Eg I would like to do something like:

  • name: Upload the compressed terminal preferences
    copy: src=dot_gconf.zip dest={{home_dir}}/dot_gconf.zip
  • name: Uncompress the terminal preferences
    shell: unzip -u {{home_dir}}/dot_gconf.zip
  • name: Remove the compressed terminal preferences
    file: path={{home_dir}}/dot_gconf.zip state=absent

But I need the unzip to run from user {{user_name}} Ie I would like to say something like:

  • name: Uncompress the terminal preferences

shell: unzip -u {{home_dir}}/dot_gconf.zip
user: {{user_name}}

What is the best way to do this? (Everything else should be executed , copied, evaluated from a different setup admin user)

Thanks!
Jason

You will need to start a new play below the current one.

You can specify “sudo_user” on a per task basis in Ansible 1.3, however.

Thanks!