title: run a particular command on all remote servers as a particular user?
body: <p>I am trying to run a specific Ansible task as a different user than the one who is running the playbook. On my local box I have below playbook and I am logged in as <code>david</code> user and I want to run this command <code>/tek/ghy/bin/ss.sh start</code> on all remote servers as <code>goldy</code> user only.</p>
  
  <p>My .yml file looks like this:</p>
  
  <pre><code>---
  - name: start server
    hosts: one_box
    serial: "{{ num_serial }}"
    tasks:
        - name: start server
          command: /tek/ghy/bin/ss.sh start
          become: true
          become_user: goldy
  </code></pre>
  
  <p>Below is how I am running it:</p>
  
  <pre><code>david@machineA:~$ ansible-playbook -e 'host_key_checking=False' -e 'num_serial=1' start_box.yml -u david --ask-pass --sudo -U goldy --ask-become-pass
  [DEPRECATION WARNING]: The sudo command line option has been deprecated in favor of the "become" command line arguments. This feature will be removed in version 2.6. Deprecation warnings
  can be disabled by setting deprecation_warnings=False in ansible.cfg.
  SSH password:
  SUDO password[defaults to SSH password]:
  
  PLAY [start server] ***************************************************************************************************************************************************************************
  
  TASK [Gathering Facts] **********************************************************************************************************************************************************************
  fatal: [remote_machineA]: FAILED! =&gt; {"msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: changing ownership of ‘/tmp/ansible-tmp-1527357815.74-165519966271795/’: Operation not permitted\nchown: changing ownership of ‘/tmp/ansible-tmp-1527357815.74-165519966271795/setup.py’: Operation not permitted\n}). For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"}
  </code></pre>
  
  <p>What wrong I am doing here? I am running ansible 2.4.3.0</p>