【问题标题】:install django using vagrant with chef-solo provisioner使用 vagrant 和 chef-solo provisioner 安装 django
【发布时间】:2015-11-06 14:25:46
【问题描述】:

作为一个绝对的 Chef 初学者,我尝试使用最新的 python 和 django 设置一个 vm。我使用“ubuntu/trusty64”框,惊讶于它的 python3 版本没有安装 pip 和 pyvenv。 所以我不得不从源代码安装最新的 python 版本 3.4.3,这似乎工作正常。但是当尝试 pip install django with chef 时,我总是得到同样的错误:

Chef::Exceptions::Package: 没有可用于 django 的候选版本

我的 python3 配方:

package "python"

execute "update system" do
   command "sudo apt-get update -y"
   not_if { File.exists?('/tmp/Python-3.4.3')}
end

execute "get dependencies" do
   command "sudo apt-get install -y build-essential libbz2-dev libncurses5-dev libreadline6-dev libsqlite3-dev libgdbm-dev liblzma-dev tk8.6-dev libssl-dev python3-setuptools"
   not_if { File.exists?('/tmp/Python-3.4.3')}
end

%w[ /opt/python /djenv ].each do |path|
directory path do
    owner 'vagrant'
    group 'vagrant'
    mode '0755'
  end
end

bash 'install-python3.4.3' do
   user 'vagrant'
   cwd '/tmp'
   code <<-EOH
     set -e
     wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz
     tar -xvf Python-3.4.3.tgz
     rm Python-3.4.3.tgz
     cd Python-3.4.3
     ./configure --prefix=/opt/python
     make
     make install
     EOH
     not_if { File.exists?('/tmp/Python-3.4.3')}
end

execute "set pyvenv environment to /djenv" do
   command "/opt/python/bin/pyvenv /djenv"
   only_if{File.exists?('/opt/python/bin/python3')}
end

django 配方:

package 'django'

execute "activate env" do
   command "source /djenv/bin/activate"
end

execute "install django and gunicorn" do
   command "pip install gunicorn && pip install Django==1.8.3"
   not_if {File.exists('/vagrant/../manage.py')}
end

execute "deactivate" do
   command "deactivate"
end

我基本上遵循this 教程并尝试将其翻译成厨师。

【问题讨论】:

  • 我猜,你不明白 package 在厨师食谱中的含义。 docs.chef.io/resource_package.html
  • 好的.....所以这将是一个easy_install_package,因为没有pip_package ??或者只是离开包装声明?感谢您的提示。

标签: linux django bash python-3.x chef-infra


【解决方案1】:
package 'python3' #will install python
package 'python3-pip' #will install pip3

execute 'pip3 install django' do #install django from command line with pip
  not_if "pip3 list | grep django" #only if it is not installed yet
end
execute 'pip3 install gunicorn' do
  not_if "pip3 list | grep gunicorn"
end 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-11
    • 1970-01-01
    • 2016-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多