How would you install a python module with chef?
Asked Answered
C

3

7

We're using EngineYard which has Python installed by default. But when we enabled SSL we received the following error message from our logentries chef recipe.

"WARNING: The "ssl" module is not present. Using unreliable workaround, host identity cannot be verified. Please install "ssl" module or newer version of Python (2.6) if possible."

I'm looking for a way to install the SSL module with chef recipe but I simply don't have enough experience. Could someone point me in the right direction?

Resources: Logentries chef recipe: https://github.com/logentries/le_chef

Logentries EY docs: https://logentries.com/doc/engineyard/

SSL Module: http://pypi.python.org/pypi/ssl/

Caesarean answered 27/11, 2012 at 11:50 Comment(1)
1. Can you install your ssl module by hand (without using chef)? 2. Write down the steps, you had to make to install it. 3. Convert your steps into chef resources. 4. Write them down as a whole recipe. Which of these steps is problematic for you?Jean
T
3

I just wrote a recipe for this, and now am able to run the latest Logentries client on EngineYard. Here you go:

file_dir = "/mnt/src/python-ssl"
file_name = "ssl-1.15.tar.gz"
file_path = File.join(file_dir,file_name)
uncompressed_file_dir = File.join(file_dir, file_name.split(".tar.gz").first)

directory file_dir do
  owner "deploy"
  group "deploy"
  mode "0755"
  recursive true
  action :create
end

remote_file file_path do
  source "http://pypi.python.org/packages/source/s/ssl/ssl-1.15.tar.gz"
  mode "0644"
  not_if { File.exists?(file_path) }
end

execute "gunzip ssl" do
  command "gunzip -c #{file_name} | tar xf -"
  cwd file_dir
  not_if { File.exists?(uncompressed_file_dir) }
end

installed_file_path = File.join(uncompressed_file_dir, "installed")

execute "install python ssl module" do
  command "python setup.py install"
  cwd uncompressed_file_dir
  not_if { File.exists?(installed_file_path) }
end

execute "touch #{installed_file_path}" do
  action :run
end
Tolliver answered 29/12, 2012 at 23:51 Comment(0)
P
14

There now appears to be a solution with better community support (based on the fact that it is documented on the opscode website).

You might try:

include_recipe 'python'
python_pip 'ssl'

As documented: here or here

Pantomimist answered 18/7, 2014 at 16:7 Comment(2)
The cookbook references in this answer is now deprecated. README now forwards to github.com/poise/poise-pythonVuillard
the poise-python project has now been archived with no recommended replacment :/Misrepresent
T
3

I just wrote a recipe for this, and now am able to run the latest Logentries client on EngineYard. Here you go:

file_dir = "/mnt/src/python-ssl"
file_name = "ssl-1.15.tar.gz"
file_path = File.join(file_dir,file_name)
uncompressed_file_dir = File.join(file_dir, file_name.split(".tar.gz").first)

directory file_dir do
  owner "deploy"
  group "deploy"
  mode "0755"
  recursive true
  action :create
end

remote_file file_path do
  source "http://pypi.python.org/packages/source/s/ssl/ssl-1.15.tar.gz"
  mode "0644"
  not_if { File.exists?(file_path) }
end

execute "gunzip ssl" do
  command "gunzip -c #{file_name} | tar xf -"
  cwd file_dir
  not_if { File.exists?(uncompressed_file_dir) }
end

installed_file_path = File.join(uncompressed_file_dir, "installed")

execute "install python ssl module" do
  command "python setup.py install"
  cwd uncompressed_file_dir
  not_if { File.exists?(installed_file_path) }
end

execute "touch #{installed_file_path}" do
  action :run
end
Tolliver answered 29/12, 2012 at 23:51 Comment(0)
F
0

You could install a new Python using PythonBrew: https://github.com/utahta/pythonbrew. Just make you install libssl before you build, or it still won't be able to use SSL. However, based on the warning, it seems that SSL might work, but it won't be able to verify host. Of course, that is one major purposes of SSL, so that is likely a non-starter.

HTH

Familiar answered 30/11, 2012 at 19:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.