努力打造剧本可以在virtualenv中环境中安装Apache的气流。 Ansible不是的virtualenv文件夹内执行命令。下面是我的剧本和错误。
剧本内容: -
- name: Active virtual Environment
shell: source bin/activate
args:
chdir: "{{ directory }}"
- name: Upgrade pip to latest version
shell: pip install --upgrade pip
- name: Execute export GPL
shell: export AIRFLOW_GPL_UNIDECODE=yes
- name: Execute export slugify
shell: SLUGIFY_USES_TEXT_UNIDECODE=yes
- name: Install airflow
pip: name=apache-airflow state=present
TASK [安装气流]
> ********************************************************* fatal: [host2.domain.local]: FAILED! => {"changed": false, "cmd":
> "/usr/bin/pip2 install apache-airflow", "msg": "stdout: Collecting
> apache-airflow\n Using cached
> https://files.pythonhosted.org/packages/e4/06/45fe64a358ae595ac562640ce96a320313ff098eeff88afb3ca8293cb6b9/apache-airflow-1.10.2.tar.gz\n
> Complete output from command python setup.py egg_info:\n Traceback
> (most recent call last):\n File \"<string>\", line 1, in
> <module>\n File
> \"/tmp/pip-install-yvZQsO/apache-airflow/setup.py\", line 429, in
> <module>\n do_setup()\n File
> \"/tmp/pip-install-yvZQsO/apache-airflow/setup.py\", line 287, in
> do_setup\n verify_gpl_dependency()\n File
> \"/tmp/pip-install-yvZQsO/apache-airflow/setup.py\", line 53, in
> verify_gpl_dependency\n raise RuntimeError(\"By default one of
> Airflow's dependencies installs a GPL \"\n RuntimeError: By default
> one of Airflow's dependencies installs a GPL dependency (unidecode).
> To avoid this dependency set SLUGIFY_USES_TEXT_UNIDECODE=yes in your
> environment when you install or upgrade Airflow. To force installing
> the GPL version set AIRFLOW_GPL_UNIDECODE\n \n
> ----------------------------------------\n\n:stderr: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please
> upgrade your Python as Python 2.7 won't be maintained after that date.
> A future version of pip will drop support for Python 2.7.\nCommand
> \"python setup.py egg_info\" failed with error code 1 in
> /tmp/pip-install-yvZQsO/apache-airflow/\n"}
任务是独立的,以便出口像AIRFLOW_GPL_UNIDECODE=yes
变量不会在以下任务可用,如果你想传递的环境变量,使用关键字environment:
在任务此方法将它传递
- name: Install airflow
pip: name=apache-airflow state=present
environment:
SLUGIFY_USES_TEXT_UNIDECODE: yes
AIRFLOW_GPL_UNIDECODE: yes
(见https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html)
画中画ansible模块virtuanlenv
参数为好。文档:https://docs.ansible.com/ansible/latest/modules/pip_module.html
- name: Install airflow
pip: name=apache-airflow state=present
virtualenv: '{{ airflow_virtualenv }}'
virtualenv_python: '{{ airflow_python_version }}'
environment:
SLUGIFY_USES_TEXT_UNIDECODE: yes
AIRFLOW_GPL_UNIDECODE: yes