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的执行。

阅读 3.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进