有没有更好的方法在远程机器上的 virtualenv 中运行 ansible?
到目前为止,我可以看到的方式是手动或使用 ansible 本身修改 .bashrc 文件。
例如:
tasks:
- name: "Enable virtualenv in .bashrc"
lineinfile: dest=.bashrc
line="source {{ PROJECT_HOME }}/venv/bin/activate"
#
# Put tasks that rely on this precondition here (?)
#
# Optionally, disable this later on
- name: "Disable virtualenv in .bashrc"
lineinfile: dest=.bashrc
line="source {{ PROJECT_HOME }}/venv/bin/activate"
state=absent
TODO:检查是否可以使用 ssh 授权密钥完成:http: //binblog.info/2008/10/20/openssh-going-flexible-with-forced-commands/