Когда я пытаюсь запустить env с Ansible, у меня появляется эта ошибка:
/bin/bash: mkvirtualenv: command not found
на шаге «Создание env с usertwo». Когда я подключаюсь к серверу вручную, я замечаю, что virtualenv был успешно создан.
Вот мои задачи:
---
###############
# Create user #
###############
- name: Create usertwo
become: yes
user:
name: usertwo
shell: /bin/bash
password: "{{ user_pwd | password_hash('sha512') }}"
- name: Add ubuntu to usertwo group
become: yes
user:
name: ubuntu
groups: usertwo
append: yes
- name: Add permission to usertwo folder
become: yes
file:
path: /home/usertwo
owner: usertwo
group: usertwo
recurse: yes
- name: Add local ssh key to usertwo authorized_key
become: yes
authorized_key:
user: usertwo
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
####################################################
# Install pip and virtualenv and init the project #
####################################################
- name: Install Pip3
become: yes
apt:
name: python3-pip
state: latest
update_cache: yes
- name: Install virtualenv and virtualenvwrapper
become: yes
pip:
name:
- virtualenv
- virtualenvwrapper
- name: Source virtualenvwrapper_lazy
shell: source /usr/local/bin/virtualenvwrapper_lazy.sh
args:
executable: /bin/bash
- name: Add environment variables to usertwo
become: yes
blockinfile:
dest: /home/usertwo/.bashrc
block: |
# variables denvironnement pour virtualenv
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/usertwo/www
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'
source /usr/local/bin/virtualenvwrapper_lazy.sh
backup: yes
- name: Source virtualenvwrapper_lazy.sh
remote_user: usertwo
shell: source /usr/local/bin/virtualenvwrapper_lazy.sh
args:
executable: /bin/bash
- name: Create env with usertwo
remote_user: usertwo
shell: mkvirtualenv my_project -p /usr/bin/python3.6
args:
executable: /bin/bash
Моя доступная версия 2.8.6, мой сервер - Ubuntu 18.04.3 LTS, мой компьютер - Ubuntu 16.04.6 LTS.