Reputation: 1553
I have a list of chef templates that are being dropped like so:
scripts.each do |script|
template "#{dir}/{script}.py" do
variables({ "keys" => keys })
end
end
Each template outputs a python script. One of these scripts has a pip requirement. Since the scripts that we run change from server to server, I can't simply pip install this on all the servers. I tried doing this:
<%
python_pip "python-dateutil" do
virtualenv "/path/to/env"
version "2.2"
end
%>
from dateutil import parser
However, this sort of thing isn't possible within a chef template, chef complains that python_pip
isn't a real method. What is the best, most elegant, cheffy way to do this?
Upvotes: 0
Views: 200
Reputation: 54267
Make scripts a hash like:
{
'script1.py' => [],
'script2.py' => %w{dep1 dep2},
}.each do |script, deps|
deps.each do |dep|
python_pip dep do
#stuff
end
end
template "#{dir}/{script}.py" do
variables({ "keys" => keys })
end
end
This keeps all the logic in the recipe where it belongs.
Upvotes: 2