首页 > ansible 创建virtulenv 环境

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

【热门文章】
【热门文章】