有没有更好的方法在远程机器上的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
Run Code Online (Sandbox Code Playgroud)
TODO:检查是否可以使用ssh授权密钥完成:http://binblog.info/2008/10/20/openssh-going-flexible-with-forced-commands/
ansible ×1