ansible 创建virtulenv 环境
vars:
project:
virtualenv_path: "{{ ansible_env.HOME }}/.virtualenvs"
shell_rc_file: "{{ ansible_env.HOME }}/.bashrc"
python: /usr/bin/python3
---
- name: set workon home for virtualenvs
lineinfile: >
dest={{ project.shell_rc_file }}
regexp='export WORKON_HOME'
line='export WORKON_HOME={{ project.virtualenv_path }}'
state=present
backup=yes
create=yes
- name: set virtualenvwrapper python path
lineinfile: >
dest={{ project.shell_rc_file }}
regexp='export VIRTUALENVWRAPPER_PYTHON'
line='export VIRTUALENVWRAPPER_PYTHON={{ project.python }}'
state=present
backup=yes
create=yes
- name: load virtulenvwrapper script
lineinfile: >
dest={{ project.shell_rc_file }}
regexp='export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh'
line='export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh'
state=present
backup=yes
create=yes
- name: load virtulenvwrapper lazy
lineinfile: >
dest={{ project.shell_rc_file }}
regexp='source /usr/local/bin/virtualenvwrapper_lazy.sh'
line='source /usr/local/bin/virtualenvwrapper_lazy.sh'
state=present
backup=yes
create=yes
- name: source bashrc
command: source {{ project.shell_rc_file }}
args:
executable: /bin/bash
- name:
command: mkvirtulenv haha
args:
executable: /bin/bash
errors:
不能正确执行mkvirtulenv
命令, 感觉不能读取bashrc的执行。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论