安装虚拟环境并使用 yml(ansible) 在虚拟环境中安装 cassandra-driver
Install virtual environment and install cassandra-driver inside virtual environment using yml(ansible)
我正在学习ansible。
我想安装虚拟环境,在venv里面安装cassandra-driver。有人可以建议我怎么做吗?
这是我试过的代码。
- hosts: localhost
gather_facts: no
connection: local
name: install cassendra-driver
become: true
become_user: root
tasks:
- name: Install the latest version of pip
apt:
name: python-pip
state: latest
force_apt_get: yes
- name: Install virtualenv
pip:
name:
- virtualenv
- name: Install "cassandra-driver"
pip:
name:
- cassandra-driver==3.19.0
请帮帮我..
您的剧本有两个问题:
- 您正在本地计算机上安装 pip 和 cassandra-driver,但您正在尝试将它们安装在虚拟环境中
- 虚拟环境已经包含 pip,因此您无需安装它
这应该可以解决您的问题:
tasks:
- name: Manually create the initial virtualenv
command: python3 -m venv env
- name: Install "cassandra-driver"
command: env/bin/python -m pip install cassandra-driver
我正在学习ansible。
我想安装虚拟环境,在venv里面安装cassandra-driver。有人可以建议我怎么做吗?
这是我试过的代码。
- hosts: localhost
gather_facts: no
connection: local
name: install cassendra-driver
become: true
become_user: root
tasks:
- name: Install the latest version of pip
apt:
name: python-pip
state: latest
force_apt_get: yes
- name: Install virtualenv
pip:
name:
- virtualenv
- name: Install "cassandra-driver"
pip:
name:
- cassandra-driver==3.19.0
请帮帮我..
您的剧本有两个问题:
- 您正在本地计算机上安装 pip 和 cassandra-driver,但您正在尝试将它们安装在虚拟环境中
- 虚拟环境已经包含 pip,因此您无需安装它
这应该可以解决您的问题:
tasks:
- name: Manually create the initial virtualenv
command: python3 -m venv env
- name: Install "cassandra-driver"
command: env/bin/python -m pip install cassandra-driver