尝试构建用于安装气流的剧本(在virtualenv文件夹上)。无法在virtualenv环境中执行命令

时间:2019-01-31 14:31:20

标签: ansible airflow

尝试构建可在virtualenv环境上安装apache-ariflow的剧本。无法在virtualenv文件夹内执行命令。以下是我的剧本和错误。

Playbook内容:-

    - 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

任务[安装气流]

> ********************************************************* 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"}

2 个答案:

答案 0 :(得分:0)

任务是独立的,因此在以下任务中将无法导出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

答案 1 :(得分:0)

pip 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