gpt4 book ai didi

python - Ansible Django 模块替代 Python 解释器

转载 作者:太空狗 更新时间:2023-10-30 01:38:08 24 4
gpt4 key购买 nike

我正在编写一个用于部署 Django 应用程序的 ansible 剧本。作为该过程的一部分,我想运行 staticcollect 命令。

我遇到的问题是远程服务器有两个 python 解释器,一个 Python2.6 和一个 Python2.7,默认为 Python2.6。

当我运行剧本时,它使用 Python2.6 解释器运行,我需要它针对 Python2.7 解释器运行。

关于如何实现这一点有什么想法吗?

我的剧本如下:

- hosts: xxxxxxxxx
vars:
hg_branch: dmv2
django_dir: /opt/app/xxxx
conf_file: /opt/app/conf/xx_uwsgi.ini
django_env:
STATIC_ROOT: /opt/app/serve/static
remote_user: xxxxxx
tasks:
- name: Update the hg repo
command: chdir=/opt/app/xxxxx hg pull -u --rev {{hg_branch}}
- name: Collect static resources
environment: django_env
django_manage: command=collectstatic app_path={{django_dir}}
- name: Restart the django service
command: touch {{conf_file}}
- name: check nginx is running
service: name=nginx state=started

最佳答案

/usr/bin/python 只是 /usr/bin/python2.6/usr/bin/python2.7< 的符号链接(symbolic link)。您可以只调用 bash 命令来更新符号链接(symbolic link)。

- name: Remove python --> python2.6 symlink
sudo: yes
command: rm /usr/bin/python

- name: Add python --> python2.7 symlink
sudo: yes
command: ln -s /usr/bin/python2.7 /usr/bin/python

关于python - Ansible Django 模块替代 Python 解释器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24865219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com