Context: I'm running my playbook against a docker container that is local 
to ansible's control machine. 

All of the various examples below result in files that are owned by `root` 
instead of `<username>` (become_user). One caveat *might* be that my 
`<username>` has a `/sbin/nologin` shell defined for it's account. 

Now, when I run the following in the Docker container directly the results 
are what I expect:
su <username> -s /bin/bash -c "<command>"


- name: Create virtualenv for {{ package_name }}
  shell: "{{ package_virtualenv }}  --python={{ package_python }} {{ 
package_virtualenv_dir }}"
  become: yes
  become_user: '<username>'
  when: check_venv_path.stat.exists == false


- name: Create virtualenv for {{ package_name }}
  shell: "{{ package_virtualenv }}  --python={{ package_python }} {{ 
package_virtualenv_dir }}"
  become: yes
  become_user: '<username>'
  become_method: su
#  become_flags: '-s /bin/bash'
  when: check_venv_path.stat.exists == false


- name: Create virtualenv for {{ package_name }}
  shell: "{{ package_virtualenv }}  --python={{ package_python }} {{ 
package_virtualenv_dir }}"
  become: yes
  become_user: '<username>'
  become_method: su
  become_flags: '-s /bin/bash'
  when: check_venv_path.stat.exists == false

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7cae034f-13e0-4172-8bd8-2f9589fe116b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to