我正在努力学习 Chef ,而且对此还很陌生。
我有一个 requirements.txt
文件,我试图通过 Chef Recipe 执行该文件来安装一些 Python 模块。我尝试了代码的不同变体,但是我觉得我错过了一些东西。我尝试在 Chef Recipe 中编写以下代码:
template '/etc' do
source 'requirements.txt.erb'
owner 'root'
group 'root'
mode '0644'
end
execute 'requirements.txt' do
command 'pip install -r requirements.txt'
action 'run'
end
我期望在运行 vagrant up 时调用需求文件,并安装应用程序的模块/依赖项。但是,我收到此错误:
Error executing action
run
on resource 'execute[requirements.txt]'
最佳答案
查看 https://docs.chef.io/resource_execute.html 中的示例
execute 'upgrade script' do
command 'php upgrade-application.php && touch /var/application/.upgraded'
creates '/var/application/.upgraded'
action :run
end
您需要指定上面所示的运行操作 (:run),而不是像您发布的示例中所示使用单引号。
关于python - 在 Chef Recipe 中执行requirements.txt文件来安装python模块的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56403843/