This Ansible task creates a virtualenv (good!), but the directory (/home/chris/.virtualenvs/foobar) is owned by root (not so good):
- name: install requirements
pip:
chdir: /home/chris/website
requirements: ./requirements.txt
virtualenv: /home/chris/.virtualenvs/foobar
But what's driving me nuts is that the next task fails, apparently because of the root ownership
- name: copy sitecustomize.py
file:
src: /home/chris/website/sitecustomize.py
dest: /home/chris/.virtualenvs/foobar/lib/python2.7/sitecustomize.py
remote_src: yes
I think the problem I really want to solve is creating the .virtualenv so that it's owned by "chris". Any idea how to force that?
Failing that, how can get the "copy" task to run with the same permissions as the "pip" task, so that I can copy my file?
EDIT: Solved second problem -- I needed to use the "copy" task, not the file task. So this...
- name: copy sitecustomize.py
copy:
src: /home/chris/website/sitecustomize.py
dest: /home/chris/.virtualenvs/foobar/lib/python2.7/sitecustomize.py
remote_src: yes
Try to run pip
as chris
:
- name: install requirements
pip:
chdir: /home/chris/website
requirements: ./requirements.txt
virtualenv: /home/chris/.virtualenvs/foobar
become: yes
become_user: chris
And to be consistent, make chris
the owner of sitecustomize.py
:
- name: copy sitecustomize.py
file:
src: /home/chris/website/sitecustomize.py
dest: /home/chris/.virtualenvs/foobar/lib/python2.7/sitecustomize.py
remote_src: yes
group: chris
owner: chris
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With