redis #4

Merged
wmantly merged 7 commits from redis into master 2019-05-28 02:43:27 +00:00
2 changed files with 45 additions and 0 deletions
Showing only changes of commit 69b621a643 - Show all commits

3
attributes/python.rb Normal file
View File

@ -0,0 +1,3 @@
default['python']['env_path'] = "/opt/theta42/#{node['app']['name']}/env/python"
default['python']['version'] = '3.6'
default['python']['pip_requirements_path'] = 'requirements.txt'

42
recipes/python.rb Normal file
View File

@ -0,0 +1,42 @@
#
# Cookbook:: django-bakend
# Recipe:: default
#
# Copyright:: 2019, The Authors, All Rights Reserved.
unless node['python']['working-dir'][0] == '/'
node.override['python']['working-dir'] = "#{node['working-dir']}/#{node['python']['working-dir']}"
end
apt_repository 'Python apt repo' do
uri 'ppa:deadsnakes/ppa'
repo_name 'ppa-deadsnakes'
deb_src true
action :add
end
apt_update
[
"python#{node['python']['version']}",
"python#{node['python']['version']}-dev",
"python#{node['python']['version'][0]}-pip",
].each do |pkg|
apt_package pkg
end
execute 'Install virtual' do
command "pip#{node['python']['version'][0]} install virtualenv"
end
bash 'Install python requirements file' do
# user 'root'
# cwd '/mydir'
code <<~EOH
virtualenv #{node['python']['env_path']}
source #{node['python']['env_path']}/bin/activate
pip install -r #{node['python']['working-dir']}/#{node['python']['pip_requirements_path']}
EOH
end