cookbooks were modified in order to deploy nailgun application
This commit is contained in:
parent
bcfd8e8420
commit
6fda96a80c
|
@ -1,20 +1,3 @@
|
|||
# Attributes for celery
|
||||
#
|
||||
# Copyright 2011, Rafael Durán Castañeda
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Generic settings
|
||||
default[:celery][:create_user] = false
|
||||
default[:celery][:virtualenv] = false
|
||||
default[:celery][:group] = 'celery'
|
||||
default[:celery][:user] = 'celery'
|
||||
default[:celery][:venv] = false
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
define :celery_instance do
|
||||
define :celery_instance, :virtualenv => false do
|
||||
|
||||
node.set[:celery][:venv] = params[:virtualenv] if params[:virtualenv]
|
||||
include_recipe 'celery'
|
||||
|
||||
name = params[:name]
|
||||
|
||||
params[:user] ||= 'vagrant'
|
||||
params[:user] ||= node.celery.user
|
||||
# validate :cwd, :kind_of => String, :required => true
|
||||
# validate :log_file, :kind_of => String
|
||||
# validate :pid_file, :kind_of => String
|
||||
|
|
|
@ -1,26 +1,3 @@
|
|||
#
|
||||
# Cookbook Name:: celery
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2011, Rafael Durán Castañeda
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "python"
|
||||
|
||||
python_pip "celery" do
|
||||
virtualenv node[:celery][:virtualenv] if node[:celery][:virtualenv]
|
||||
action :install
|
||||
python_pip 'celery' do
|
||||
virtualenv node.celery.venv
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
cobbler cobbler/password string cobbler
|
||||
cobbler cobbler/server_and_next_server string 10.0.0.1
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
package "cobbler" do
|
||||
action :install
|
||||
response_file "cobbler.seed"
|
||||
end
|
||||
|
||||
package "cobbler-web" do
|
||||
|
@ -97,17 +98,12 @@ file "/etc/dnsmasq.d/mirantis.net.conf" do
|
|||
notifies :restart, "service[dnsmasq]", :immediately
|
||||
end
|
||||
|
||||
|
||||
link "#{node["cobbler"]["bootstrap_ks_mirror_dir"]}/linux" do
|
||||
to node["cobbler"]["bootstrap_kernel"]
|
||||
owner "root"
|
||||
group "root"
|
||||
to "#{node["cobbler"]["bootstrap_kernel"]}"
|
||||
end
|
||||
|
||||
link "#{node["cobbler"]["bootstrap_ks_mirror_dir"]}/initrd.gz" do
|
||||
to node["cobbler"]["bootstrap_initrd"]
|
||||
owner "root"
|
||||
group "root"
|
||||
to "#{node["cobbler"]["bootstrap_initrd"]}"
|
||||
end
|
||||
|
||||
# FIXME
|
||||
|
|
|
@ -1,22 +1,3 @@
|
|||
#
|
||||
# Cookbook Name:: django
|
||||
# Recipe:: default
|
||||
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
||||
#
|
||||
# Copyright 2010, Opscode, Inc
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
default[:django][:web_server] = "mod_wsgi"
|
||||
default[:django][:install_from] = "pip"
|
||||
default[:django][:version] = "1.4"
|
||||
default[:django][:venv] = false
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
"suggestions": {
|
||||
},
|
||||
"attributes": {
|
||||
},
|
||||
"maintainer_email": "cookbooks@opscode.com",
|
||||
"conflicting": {
|
||||
},
|
||||
"dependencies": {
|
||||
"python": [
|
||||
|
||||
],
|
||||
"apache2": [
|
||||
|
||||
]
|
||||
},
|
||||
"recipes": {
|
||||
"django": "Installs django and apache2 with mod_python"
|
||||
},
|
||||
"providing": {
|
||||
},
|
||||
"platforms": {
|
||||
"debian": [
|
||||
|
||||
],
|
||||
"ubuntu": [
|
||||
|
||||
]
|
||||
},
|
||||
"license": "Apache 2.0",
|
||||
"version": "0.8.0",
|
||||
"replacing": {
|
||||
},
|
||||
"groupings": {
|
||||
},
|
||||
"name": "django",
|
||||
"recommendations": {
|
||||
},
|
||||
"description": "Installs DJango",
|
||||
"maintainer": "Opscode, Inc.",
|
||||
"long_description": "= DESCRIPTION:\n\nInstalls Python Django package and sets up Apache2 to serve a django application.\n\n= REQUIREMENTS:\n\nOpscode cookbooks, http://github.com/opscode/cookbooks/tree/master:\n\n* python\n* apache2\n\n= ATTRIBUTES:\n\nnode[:django][:web_server] - set whether to use mod_python or mod_wsgi. Defaults to mod_wsgi because that is the recommended web server strategy to use by the Django creator.\n\n= USAGE:\n\nCreate the django application using the Apache2 cookbook's web_app define. Normally this would be done in a site-cookbook.\n\n web_app \"mysite\" do\n docroot \"/srv/mysite\"\n template \"mysite.conf.erb\"\n end\n\nCreate the template, 'mysite.conf.erb' within the site-cookbook. Make sure the django settings are correct. The web_app define copies the template over and enables it as an apache2 site.\n\nThe Opscode \"application\" cookbook is going to grow the ability to deploy a Django application from a source repository. This cookbook will be used to get the Django and Apache software installed and ready.\n\n= LICENSE & AUTHOR:\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\nCopyright:: 2009, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n"
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
maintainer "Opscode, Inc."
|
||||
maintainer_email "cookbooks@opscode.com"
|
||||
maintainer "Mirantis Inc."
|
||||
maintainer_email "product@mirantis.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs DJango"
|
||||
description "Installs Django"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
|
||||
version "0.8.0"
|
||||
version "0.0.1"
|
||||
|
||||
recipe "django", "Installs django and apache2 with mod_python"
|
||||
|
||||
%w{ ubuntu debian }.each do |os|
|
||||
%w{ubuntu}.each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
%w{ apache2 python}.each do |cb|
|
||||
%w{apache2 python}.each do |cb|
|
||||
depends cb
|
||||
end
|
||||
|
|
|
@ -1,24 +1,7 @@
|
|||
#
|
||||
# Cookbook Name:: django
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2009, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
include_recipe "apache2"
|
||||
include_recipe "apache2::#{node[:django][:web_server]}"
|
||||
include_recipe "python"
|
||||
|
||||
include_recipe "django::#{node.django.install_from}"
|
||||
|
||||
local_python_pip 'Django' do
|
||||
version node[:django][:version] if node[:django][:version]
|
||||
virtualenv node[:django][:venv]
|
||||
end
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
package "python-django" do
|
||||
action :install
|
||||
end
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
|
||||
python_pip 'Django' do
|
||||
version node[:django][:version] if node[:django][:version]
|
||||
action :install
|
||||
end
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
default[:nailgun][:root] = "/vagrant/nailgun"
|
||||
default[:nailgun][:user] = "vagrant"
|
||||
default[:nailgun][:eggsdir] = "/var/lib/mirror/eggs"
|
||||
default[:nailgun][:root] = "/opt/nailgun"
|
||||
default[:nailgun][:group] = "nailgun"
|
||||
default[:nailgun][:user] = "nailgun"
|
||||
default[:nailgun][:venv] = "/opt/nailgun-venv"
|
||||
default[:nailgun][:python] = "/opt/nailgun-venv/bin/python"
|
||||
default[:nailgun][:pip] = "/opt/nailgun-venv/bin/pip"
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
maintainer "Maxim Kulkin"
|
||||
maintainer_email "mkulkin@mirantis.com"
|
||||
license "BSD"
|
||||
maintainer "Mirantis Inc."
|
||||
maintainer_email "product@mirantis.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs/Configures nailgun"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "0.0.1"
|
||||
recipe "server", "Include Nailgun daemon install/configuration"
|
||||
recipe "deps", "Installs nailgun deps"
|
||||
|
||||
supports "ubuntu" # It should work on debian too, but not tested yet
|
||||
|
||||
|
@ -15,10 +16,10 @@ end
|
|||
attribute "nailgun/root",
|
||||
:display_name => "Root directory",
|
||||
:description => "Nailgun daemon root directory",
|
||||
:default => "/vagrant/ngui"
|
||||
:default => "/opt/nailgun"
|
||||
|
||||
attribute "nailgun/user",
|
||||
:display_name => "Nailgun user",
|
||||
:description => "Nailgun daemon user",
|
||||
:default => "vagrant"
|
||||
:default => "nailgun"
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
local_python_pip 'django-piston' do
|
||||
version '0.2.3-20120528'
|
||||
fromdir node[:nailgun][:eggsdir]
|
||||
virtualenv "#{node[:nailgun][:venv]}" do
|
||||
site_packages false
|
||||
end
|
||||
|
||||
{
|
||||
'django-piston' => '0.2.3-20120528',
|
||||
'django-celery' => '2.5.5',
|
||||
'redis' => '2.4.12',
|
||||
'jsonfield' => '0.9',
|
||||
|
@ -12,7 +12,13 @@ end
|
|||
}.each do |package, version|
|
||||
local_python_pip package do
|
||||
version version
|
||||
fromdir node[:nailgun][:eggsdir]
|
||||
virtualenv node.nailgun.venv
|
||||
end
|
||||
end
|
||||
|
||||
['python-paramiko'].each do |deb|
|
||||
package deb do
|
||||
action :install
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,22 +1,64 @@
|
|||
|
||||
node.set[:django][:venv] = node.nailgun.venv
|
||||
include_recipe 'django'
|
||||
|
||||
# FIXME
|
||||
# it is nice to encapsulate all these components into os package
|
||||
# installing deps, creating system user, installing nailgun files
|
||||
|
||||
include_recipe 'nailgun::deps'
|
||||
|
||||
group node.nailgun.group do
|
||||
action :create
|
||||
end
|
||||
|
||||
user node.nailgun.user do
|
||||
home node.nailgun.root
|
||||
gid node.nailgun.group
|
||||
system true
|
||||
end
|
||||
|
||||
file "#{node[:nailgun][:root]}/nailgun/venv.py" do
|
||||
content "VENV = #{node.nailgun.venv}/local/lib/python2.7/site-packages"
|
||||
owner node.nailgun.user
|
||||
group node.nailgun.group
|
||||
mode 644
|
||||
end
|
||||
|
||||
# it is assumed that nailgun files already installed into nailgun.root
|
||||
execute 'chown #{node[:nailgun][:root]}' do
|
||||
command "chown -R #{node.nailgun.user}:#{node.nailgun.group} #{node.nailgun.root}"
|
||||
end
|
||||
|
||||
execute 'chmod #{node[:nailgun][:root]}' do
|
||||
command "chmod -R u+w #{node.nailgun.root}"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
execute 'Preseed Nailgun database' do
|
||||
command '#{node.nailgun.python} manage.py loaddata nailgun/fixtures/default_env.json'
|
||||
cwd node.nailgun.root
|
||||
user node.nailgun.user
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute 'Sync Nailgun database' do
|
||||
command 'python manage.py syncdb --noinput'
|
||||
command '#{node.nailgun.python} manage.py syncdb --noinput'
|
||||
cwd node.nailgun.root
|
||||
user node.nailgun.user
|
||||
notifies :run, resources('execute[Preseed Nailgun database]')
|
||||
|
||||
not_if "test -e #{node.nailgun.root}/nailgun.sqlite"
|
||||
end
|
||||
|
||||
redis_instance 'nailgun'
|
||||
|
||||
celery_instance 'nailgun-jobserver' do
|
||||
command 'python manage.py celeryd_multi'
|
||||
command '#{node.nailgun.python} manage.py celeryd_multi'
|
||||
cwd node.nailgun.root
|
||||
events true
|
||||
user node.nailgun.user
|
||||
virtualenv node.nailgun.venv
|
||||
end
|
||||
|
||||
web_app 'nailgun' do
|
||||
|
|
|
@ -1,4 +1,2 @@
|
|||
|
||||
WSGIScriptAlias "/<%= @application_name %>" "<%= node.nailgun.root %>/nailgun/wsgi.py"
|
||||
WSGIPythonPath "<%= node.nailgun.root %>"
|
||||
|
||||
WSGIPythonPath "<%= node.nailgun.root %>"
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
## v1.0.6:
|
||||
|
||||
* [COOK-1036] - correctly grep for python-module version
|
||||
* [COOK-1046] - run pip inside the virtualenv
|
||||
|
||||
## v1.0.4:
|
||||
|
||||
* [COOK-960] - add timeout to python_pip
|
||||
* [COOK-651] - 'install_path' not correctly resolved when using python::source
|
||||
* [COOK-650] - Add ability to specify version when installing distribute.
|
||||
* [COOK-553] - FreeBSD support in the python cookbook
|
|
@ -1,165 +0,0 @@
|
|||
Description
|
||||
===========
|
||||
|
||||
Installs and configures Python. Also includes LWRPs for managing python packages with `pip` and `virtualenv` isolated Python environments.
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
Platform
|
||||
--------
|
||||
|
||||
* Debian, Ubuntu
|
||||
* CentOS, Red Hat, Fedora
|
||||
|
||||
Cookbooks
|
||||
---------
|
||||
|
||||
* build-essential
|
||||
|
||||
Attributes
|
||||
==========
|
||||
|
||||
See `attributes/default.rb` for default values.
|
||||
|
||||
* `node["python"]["install_method"]` - method to install python with, default `package`.
|
||||
* `node["python"]["distribute_install_py_version"]` - version of python to use when installing distribute. default '', specify version like '2.6' (uses python2.6 binary).
|
||||
|
||||
The file also contains the following attributes:
|
||||
|
||||
* platform specific locations and settings.
|
||||
* source installation settings
|
||||
|
||||
Resource/Provider
|
||||
=================
|
||||
|
||||
This cookbook includes LWRPs for managing:
|
||||
|
||||
* pip packages
|
||||
* virtualenv isolated Python environments
|
||||
|
||||
`python_pip`
|
||||
------------
|
||||
|
||||
Install packages using the new hotness in Python package management...[`pip`](http://pypi.python.org/pypi/pip). Yo dawg...easy_install is so 2009, you better ask your local Pythonista if you don't know! The usage semantics are like that of any normal package provider.
|
||||
|
||||
# Actions
|
||||
|
||||
- :install: Install a pip package - if version is provided, install that specific version
|
||||
- :upgrade: Upgrade a pip package - if version is provided, upgrade to that specific version
|
||||
- :remove: Remove a pip package
|
||||
- :purge: Purge a pip package (this usually entails removing configuration files as well as the package itself). With pip packages this behaves the same as `:remove`
|
||||
|
||||
# Attribute Parameters
|
||||
|
||||
- package_name: name attribute. The name of the pip package to install
|
||||
- version: the version of the package to install/upgrade. If no version is given latest is assumed.
|
||||
- virtualenv: virtualenv environment to install pip package into
|
||||
- options: Add additional options to the underlying pip package command
|
||||
- timeout: timeout in seconds for the command to execute. Useful for pip packages that may take a long time to install. Default 900 seconds.
|
||||
|
||||
# Example
|
||||
|
||||
# install latest gunicorn into system path
|
||||
python_pip "gunicorn" do
|
||||
action :install
|
||||
end
|
||||
|
||||
# target a virtualenv
|
||||
python_pip "gunicorn" do
|
||||
virtualenv "/home/ubunut/my_ve"
|
||||
action :install
|
||||
end
|
||||
|
||||
# install Django 1.1.4
|
||||
python_pip "django" do
|
||||
version "1.1.4"
|
||||
action :install
|
||||
end
|
||||
|
||||
# use this provider with the core package resource
|
||||
package "django" do
|
||||
provider Chef::Provider::PythonPip
|
||||
action :install
|
||||
end
|
||||
|
||||
`python_virtualenv`
|
||||
-------------------
|
||||
|
||||
[`virtualenv`](http://pypi.python.org/pypi/virtualenv) is a great tool that creates isolated python environments. Think of it as RVM without all those hipsters and tight jeans.
|
||||
|
||||
# Actions
|
||||
|
||||
- :create: creates a new virtualenv
|
||||
- :delete: deletes an existing virtualenv
|
||||
|
||||
# Attribute Parameters
|
||||
|
||||
- path: name attribute. The path where the virtualenv will be created
|
||||
- interpreter: The Python interpreter to use. default is `python2.6`
|
||||
- owner: The owner for the virtualenv
|
||||
- group: The group owner of the file (string or id)
|
||||
|
||||
# Example
|
||||
|
||||
# create a 2.6 virtualenv owned by ubuntu user
|
||||
python_virtualenv "/home/ubuntu/my_cool_ve" do
|
||||
owner "ubuntu"
|
||||
group "ubuntu"
|
||||
action :create
|
||||
end
|
||||
|
||||
# create a Python 2.4 virtualenv
|
||||
python_virtualenv "/home/ubuntu/my_old_ve" do
|
||||
interpreter "python2.4"
|
||||
owner "ubuntu"
|
||||
group "ubuntu"
|
||||
action :create
|
||||
end
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
default
|
||||
-------
|
||||
|
||||
Include default recipe in a run list, to get `python`, `pip` and `virtualenv`. Installs python by package or source depending on the platform.
|
||||
|
||||
package
|
||||
-------
|
||||
|
||||
Installs Python from packages.
|
||||
|
||||
source
|
||||
------
|
||||
|
||||
Installs Python from source.
|
||||
|
||||
pip
|
||||
---
|
||||
|
||||
Installs `pip` from source.
|
||||
|
||||
virtualenv
|
||||
----------
|
||||
|
||||
Installs virtualenv using the `python_pip` resource.
|
||||
|
||||
License and Author
|
||||
==================
|
||||
|
||||
Author:: Seth Chisamore (<schisamo@opscode.com>)
|
||||
|
||||
Copyright:: 2011, Opscode, Inc
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,30 +1,2 @@
|
|||
#
|
||||
# Author:: Seth Chisamore (<schisamo@opscode.com>)
|
||||
# Cookbook Name:: python
|
||||
# Attribute:: default
|
||||
#
|
||||
# Copyright 2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
default['python']['distribute_install_py_version'] = ''
|
||||
|
||||
default['python']['install_method'] = 'package'
|
||||
|
||||
default['python']['url'] = 'http://www.python.org/ftp/python'
|
||||
default['python']['version'] = '2.7.1'
|
||||
default['python']['checksum'] = '80e387bcf57eae8ce26726753584fd63e060ec11682d1145af921e85fd612292'
|
||||
default['python']['prefix_dir'] = '/usr/local'
|
||||
|
||||
default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}}
|
||||
default[:python][:version] = "2.7"
|
||||
default[:python][:fromdir] = "/var/lib/mirror/eggs"
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
# Install python package right from cookbook.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# cookbook_python_pip 'foo' do
|
||||
# version '0.1.1'
|
||||
# end
|
||||
#
|
||||
# The package file should be inside files/ tree and have name:
|
||||
# <name>-<version>.tar.gz
|
||||
# or
|
||||
# <name>.tar.gz
|
||||
# if you do not specify version
|
||||
#
|
||||
# E.g.
|
||||
# foo-0.1.1.tar.gz
|
||||
#
|
||||
|
||||
define :cookbook_python_pip, :version => nil do
|
||||
package_file = params[:name]
|
||||
package_file += "-#{params[:version]}" if params[:version]
|
||||
package_file += '.tar.gz'
|
||||
|
||||
cookbook_file "/tmp/#{package_file}" do
|
||||
source params[:source] if params[:source]
|
||||
cookbook params[:cookbook] if params[:cookbook]
|
||||
end
|
||||
|
||||
python_pip params[:name] do
|
||||
package_name "file:///tmp/#{package_file}"
|
||||
version 'latest'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
define :local_python_pip, :version => nil do
|
||||
package_file = params[:name]
|
||||
package_file += "-#{params[:version]}" if params[:version]
|
||||
package_file += '.tar.gz'
|
||||
|
||||
fromdir = params[:fromdir]
|
||||
|
||||
python_pip params[:name] do
|
||||
package_name "#{package_file}"
|
||||
options "-f file://#{fromdir}"
|
||||
version 'latest'
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
define :local_python_pip, :virtualenv => nil, :version => nil, :fromdir => nil do
|
||||
include_recipe 'python'
|
||||
|
||||
package_name = "#{params[:name]}"
|
||||
|
||||
if params[:virtualenv]
|
||||
pip = "#{params[:virtualenv]}/bin/pip"
|
||||
else
|
||||
pip = "pip"
|
||||
end
|
||||
|
||||
if params[:version]
|
||||
package_version = "==#{params[:version]}"
|
||||
else
|
||||
package_version = ""
|
||||
end
|
||||
|
||||
if params[:fromdir]
|
||||
fromdir = params[:fromdir]
|
||||
else
|
||||
fromdir = node.python.fromdir
|
||||
end
|
||||
|
||||
execute "#{pip} install #{package_name}" do
|
||||
command "#{pip} install -f file://#{fromdir} #{package_name}#{package_version}"
|
||||
only_if "which #{pip}"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
# same as local_python_pip implementation
|
||||
|
||||
define :python_pip, :virtualenv => nil, :version => nil do
|
||||
local_python_pip params[:name] do
|
||||
virtualenv params[:virtualenv]
|
||||
version params[:version]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
define :virtualenv, :site_packages => false do
|
||||
include_recipe 'python'
|
||||
|
||||
if params[:path]
|
||||
venvpath = params[:path]
|
||||
else
|
||||
venvpath = params[:name]
|
||||
end
|
||||
|
||||
if params[:site_packages]
|
||||
site_packages = ""
|
||||
else
|
||||
site_packages = "--no-site-packages"
|
||||
end
|
||||
|
||||
execute "virtualenv #{venvpath}" do
|
||||
command "virtualenv #{site_packages} #{venvpath}"
|
||||
end
|
||||
end
|
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"name": "python",
|
||||
"description": "Installs Python, pip and virtualenv. Includes LWRPs for managing Python packages with `pip` and `virtualenv` isolated Python environments.",
|
||||
"long_description": "",
|
||||
"maintainer": "Opscode, Inc.",
|
||||
"maintainer_email": "cookbooks@opscode.com",
|
||||
"license": "Apache 2.0",
|
||||
"platforms": {
|
||||
"debian": ">= 0.0.0",
|
||||
"ubuntu": ">= 0.0.0",
|
||||
"centos": ">= 0.0.0",
|
||||
"redhat": ">= 0.0.0",
|
||||
"fedora": ">= 0.0.0",
|
||||
"freebsd": ">= 0.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"build-essential": ">= 0.0.0"
|
||||
},
|
||||
"recommendations": {
|
||||
},
|
||||
"suggestions": {
|
||||
},
|
||||
"conflicting": {
|
||||
},
|
||||
"providing": {
|
||||
},
|
||||
"replacing": {
|
||||
},
|
||||
"attributes": {
|
||||
},
|
||||
"groupings": {
|
||||
},
|
||||
"recipes": {
|
||||
"python": "Installs python, pip, and virtualenv",
|
||||
"python::package": "Installs python using packages.",
|
||||
"python::source": "Installs python from source.",
|
||||
"python::pip": "Installs pip from source.",
|
||||
"python::virtualenv": "Installs virtualenv using the python_pip resource."
|
||||
},
|
||||
"version": "1.0.6"
|
||||
}
|
|
@ -1,17 +1,9 @@
|
|||
maintainer "Opscode, Inc."
|
||||
maintainer_email "cookbooks@opscode.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs Python, pip and virtualenv. Includes LWRPs for managing Python packages with `pip` and `virtualenv` isolated Python environments."
|
||||
version "1.0.6"
|
||||
maintainer "Mirantis Inc."
|
||||
maintainer_email "product@mirantis.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs python"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
|
||||
version "0.0.1"
|
||||
supports "ubuntu", "= 12.04"
|
||||
recipe "python", "Installs python itself"
|
||||
|
||||
depends "build-essential"
|
||||
|
||||
recipe "python", "Installs python, pip, and virtualenv"
|
||||
recipe "python::package", "Installs python using packages."
|
||||
recipe "python::source", "Installs python from source."
|
||||
recipe "python::pip", "Installs pip from source."
|
||||
recipe "python::virtualenv", "Installs virtualenv using the python_pip resource."
|
||||
|
||||
%w{ debian ubuntu centos redhat fedora freebsd }.each do |os|
|
||||
supports os
|
||||
end
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
#
|
||||
# Author:: Seth Chisamore <schisamo@opscode.com>
|
||||
# Cookbook Name:: python
|
||||
# Provider:: pip
|
||||
#
|
||||
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mixin/shell_out'
|
||||
require 'chef/mixin/language'
|
||||
include Chef::Mixin::ShellOut
|
||||
|
||||
# the logic in all action methods mirror that of
|
||||
# the Chef::Provider::Package which will make
|
||||
# refactoring into core chef easy
|
||||
|
||||
action :install do
|
||||
# If we specified a version, and it's not the current version, move to the specified version
|
||||
if @new_resource.version != nil && @new_resource.version != @current_resource.version
|
||||
install_version = @new_resource.version
|
||||
# If it's not installed at all, install it
|
||||
elsif @current_resource.version == nil
|
||||
install_version = candidate_version
|
||||
end
|
||||
|
||||
# Set the timeout (units in seconds)
|
||||
timeout = 900
|
||||
if @new_resource.timeout
|
||||
timeout = @new_resource.timeout
|
||||
end
|
||||
|
||||
if install_version
|
||||
Chef::Log.info("Installing #{@new_resource} version #{install_version}")
|
||||
status = install_package(@new_resource.package_name, install_version, timeout)
|
||||
if status
|
||||
@new_resource.updated_by_last_action(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :upgrade do
|
||||
# Set the timeout (units in seconds)
|
||||
timeout = 900
|
||||
if @new_resource.timeout
|
||||
timeout = @new_resource.timeout
|
||||
end
|
||||
|
||||
if @current_resource.version != candidate_version
|
||||
orig_version = @current_resource.version || "uninstalled"
|
||||
Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}")
|
||||
status = upgrade_package(@new_resource.package_name, candidate_version, timeout)
|
||||
if status
|
||||
@new_resource.updated_by_last_action(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :remove do
|
||||
# Set the timeout (units in seconds)
|
||||
timeout = 900
|
||||
if @new_resource.timeout
|
||||
timeout = @new_resource.timeout
|
||||
end
|
||||
|
||||
if removing_package?
|
||||
Chef::Log.info("Removing #{@new_resource}")
|
||||
remove_package(@current_resource.package_name, @new_resource.version, timeout)
|
||||
@new_resource.updated_by_last_action(true)
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
def removing_package?
|
||||
if @current_resource.version.nil?
|
||||
false # nothing to remove
|
||||
elsif @new_resource.version.nil?
|
||||
true # remove any version of a package
|
||||
elsif @new_resource.version == @current_resource.version
|
||||
true # remove the version we have
|
||||
else
|
||||
false # we don't have the version we want to remove
|
||||
end
|
||||
end
|
||||
|
||||
def expand_options(options)
|
||||
options ? " #{options}" : ""
|
||||
end
|
||||
|
||||
# these methods are the required overrides of
|
||||
# a provider that extends from Chef::Provider::Package
|
||||
# so refactoring into core Chef should be easy
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource::PythonPip.new(@new_resource.name)
|
||||
@current_resource.package_name(@new_resource.package_name)
|
||||
@current_resource.version(nil)
|
||||
|
||||
unless current_installed_version.nil?
|
||||
@current_resource.version(current_installed_version)
|
||||
end
|
||||
|
||||
@current_resource
|
||||
end
|
||||
|
||||
def current_installed_version
|
||||
@current_installed_version ||= begin
|
||||
delimeter = /==/
|
||||
|
||||
version_check_cmd = "#{pip_cmd(@new_resource)} freeze | grep -i '^#{@new_resource.package_name}=='"
|
||||
# incase you upgrade pip with pip!
|
||||
if @new_resource.package_name.eql?('pip')
|
||||
delimeter = /\s/
|
||||
version_check_cmd = "pip --version"
|
||||
end
|
||||
p = shell_out!(version_check_cmd)
|
||||
p.stdout.split(delimeter)[1].strip
|
||||
rescue Mixlib::ShellOut::ShellCommandFailed
|
||||
end
|
||||
end
|
||||
|
||||
def candidate_version
|
||||
@candidate_version ||= begin
|
||||
# `pip search` doesn't return versions yet
|
||||
# `pip list` may be coming soon:
|
||||
# https://bitbucket.org/ianb/pip/issue/197/option-to-show-what-version-would-be
|
||||
@new_resource.version||'latest'
|
||||
end
|
||||
end
|
||||
|
||||
def install_package(name, version, timeout)
|
||||
v = "==#{version}" unless version.eql?('latest')
|
||||
shell_out!("#{pip_cmd(@new_resource)} install#{expand_options(@new_resource.options)} #{name}#{v}", :timeout => timeout)
|
||||
end
|
||||
|
||||
def upgrade_package(name, version, timeout)
|
||||
v = "==#{version}" unless version.eql?('latest')
|
||||
shell_out!("#{pip_cmd(@new_resource)} install --upgrade#{expand_options(@new_resource.options)} #{name}#{v}", :timeout => timeout)
|
||||
end
|
||||
|
||||
def remove_package(name, version, timeout)
|
||||
shell_out!("#{pip_cmd(@new_resource)} uninstall -y#{expand_options(@new_resource.options)} #{name}", :timeout => timeout)
|
||||
end
|
||||
|
||||
# TODO remove when provider is moved into Chef core
|
||||
# this allows PythonPip to work with Chef::Resource::Package
|
||||
def pip_cmd(nr)
|
||||
(nr.respond_to?("virtualenv") && nr.virtualenv) ? ::File.join(nr.virtualenv,'/bin/pip') : 'pip'
|
||||
end
|
|
@ -1,60 +0,0 @@
|
|||
#
|
||||
# Author:: Seth Chisamore <schisamo@opscode.com>
|
||||
# Cookbook Name:: python
|
||||
# Provider:: virtualenv
|
||||
#
|
||||
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mixin/shell_out'
|
||||
require 'chef/mixin/language'
|
||||
include Chef::Mixin::ShellOut
|
||||
|
||||
action :create do
|
||||
unless exists?
|
||||
Chef::Log.info("Creating virtualenv #{@new_resource} at #{@new_resource.path}")
|
||||
execute "virtualenv --python=#{@new_resource.interpreter} #{@new_resource.path}" do
|
||||
user new_resource.owner if new_resource.owner
|
||||
group new_resource.group if new_resource.group
|
||||
end
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if exists?
|
||||
Chef::Log.info("Deleting virtualenv #{@new_resource} at #{@new_resource.path}")
|
||||
FileUtils.rm_rf(@new_resource.path)
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource::PythonVirtualenv.new(@new_resource.name)
|
||||
@current_resource.path(@new_resource.path)
|
||||
|
||||
if exists?
|
||||
cstats = ::File.stat(@current_resource.path)
|
||||
@current_resource.owner(cstats.uid)
|
||||
@current_resource.group(cstats.gid)
|
||||
end
|
||||
@current_resource
|
||||
end
|
||||
|
||||
private
|
||||
def exists?
|
||||
::File.exist?(@current_resource.path) && ::File.directory?(@current_resource.path) \
|
||||
&& ::File.exists?("#{@current_resource.path}/bin/activate")
|
||||
end
|
|
@ -1,23 +1,11 @@
|
|||
#
|
||||
# Author:: Seth Chisamore <schisamo@opscode.com>
|
||||
# Cookbook Name:: python
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
package "python#{node.python.version}" do
|
||||
action :install
|
||||
end
|
||||
|
||||
include_recipe "python::#{node['python']['install_method']}"
|
||||
include_recipe "python::pip"
|
||||
include_recipe "python::virtualenv"
|
||||
package "python-pip" do
|
||||
action :install
|
||||
end
|
||||
|
||||
package "python-virtualenv" do
|
||||
action :install
|
||||
end
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
#
|
||||
# Author:: Seth Chisamore <schisamo@opscode.com>
|
||||
# Cookbook Name:: python
|
||||
# Recipe:: package
|
||||
#
|
||||
# Copyright 2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
python_pkgs = value_for_platform(
|
||||
["debian","ubuntu"] => {
|
||||
"default" => ["python","python-dev"]
|
||||
},
|
||||
["centos","redhat","fedora"] => {
|
||||
"default" => ["python26","python26-devel"]
|
||||
},
|
||||
["freebsd"] => {
|
||||
"default" => ["python"]
|
||||
},
|
||||
"default" => ["python","python-dev"]
|
||||
)
|
||||
|
||||
python_pkgs.each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
end
|
||||
end
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#
|
||||
# Author:: Seth Chisamore <schisamo@opscode.com>
|
||||
# Cookbook Name:: python
|
||||
# Recipe:: pip
|
||||
#
|
||||
# Copyright 2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Ubuntu's python-setuptools, python-pip and python-virtualenv packages
|
||||
# are broken...this feels like Rubygems!
|
||||
# http://stackoverflow.com/questions/4324558/whats-the-proper-way-to-install-pip-virtualenv-and-distribute-for-python
|
||||
# https://bitbucket.org/ianb/pip/issue/104/pip-uninstall-on-ubuntu-linux
|
||||
remote_file "#{Chef::Config[:file_cache_path]}/distribute_setup.py" do
|
||||
source "http://python-distribute.org/distribute_setup.py"
|
||||
mode "0644"
|
||||
not_if "which pip"
|
||||
end
|
||||
|
||||
use_version = node['python']['distribute_install_py_version']
|
||||
|
||||
bash "install-pip" do
|
||||
cwd Chef::Config[:file_cache_path]
|
||||
code <<-EOF
|
||||
python#{use_version} distribute_setup.py
|
||||
easy_install pip
|
||||
EOF
|
||||
not_if "which pip"
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
#
|
||||
# Author:: Seth Chisamore <schisamo@opscode.com>
|
||||
# Cookbook Name:: python
|
||||
# Recipe:: source
|
||||
#
|
||||
# Copyright 2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
configure_options = node['python']['configure_options'].join(" ")
|
||||
|
||||
packages = value_for_platform(
|
||||
["centos","redhat","fedora"] =>
|
||||
{"default" => ["openssl-devel","bzip2-devel","zlib-devel","expat-devel","db4-devel","sqlite-devel","ncurses-devel","readline-devel"]},
|
||||
"default" =>
|
||||
["libssl-dev","libbz2-dev","zlib1g-dev","libexpat1-dev","libdb4.8-dev","libsqlite3-dev","libncursesw5-dev","libncurses5-dev","libreadline-dev"]
|
||||
)
|
||||
|
||||
packages.each do |dev_pkg|
|
||||
package dev_pkg
|
||||
end
|
||||
|
||||
version = node['python']['version']
|
||||
install_path = "#{node['python']['prefix_dir']}/lib/python#{version.split(/(^\d+\.\d+)/)[1]}"
|
||||
|
||||
remote_file "#{Chef::Config[:file_cache_path]}/Python-#{version}.tar.bz2" do
|
||||
source "#{node['python']['url']}/#{version}/Python-#{version}.tar.bz2"
|
||||
checksum node['python']['checksum']
|
||||
mode "0644"
|
||||
not_if { ::File.exists?(install_path) }
|
||||
end
|
||||
|
||||
bash "build-and-install-python" do
|
||||
cwd Chef::Config[:file_cache_path]
|
||||
code <<-EOF
|
||||
tar -jxvf Python-#{version}.tar.bz2
|
||||
(cd Python-#{version} && ./configure #{configure_options})
|
||||
(cd Python-#{version} && make && make install)
|
||||
EOF
|
||||
not_if { ::File.exists?(install_path) }
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
#
|
||||
# Author:: Seth Chisamore <schisamo@opscode.com>
|
||||
# Cookbook Name:: python
|
||||
# Recipe:: virtualenv
|
||||
#
|
||||
# Copyright 2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "python::pip"
|
||||
|
||||
python_pip "virtualenv" do
|
||||
action :install
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
#
|
||||
# Author:: Seth Chisamore <schisamo@opscode.com>
|
||||
# Cookbook Name:: python
|
||||
# Resource:: pip
|
||||
#
|
||||
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :install, :upgrade, :remove, :purge
|
||||
|
||||
attribute :package_name, :kind_of => String, :name_attribute => true
|
||||
attribute :version, :default => nil
|
||||
attribute :timeout, :default => nil
|
||||
attribute :virtualenv, :kind_of => String
|
||||
attribute :options, :kind_of => String
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
@action = :install
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# Author:: Seth Chisamore <schisamo@opscode.com>
|
||||
# Cookbook Name:: python
|
||||
# Resource:: virtualenv
|
||||
#
|
||||
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :create, :delete
|
||||
|
||||
attribute :path, :kind_of => String, :name_attribute => true
|
||||
attribute :interpreter, :default => 'python2.6'
|
||||
attribute :owner, :regex => Chef::Config[:user_valid_regex]
|
||||
attribute :group, :regex => Chef::Config[:group_valid_regex]
|
|
@ -1,326 +0,0 @@
|
|||
{
|
||||
"name": "redis2",
|
||||
"description": "Installs/Configures redis",
|
||||
"long_description": "= DESCRIPTION:\nThis cookbooks installs Redis 2 key-value datastore server. Redis can be installed from packages (where available) or source.\n\n= REQUIREMENTS:\nFor compiling from source: build-essential\n\n= ATTRIBUTES: \n[\"redis2\"][\"install_from\"] - _package_ to install from distro packages, any other value to install from source.\n[\"redis2\"][\"instances\"][\"default\"] - default attributes for all redis instances, will be merged with per instance attributes\n[\"redis2\"][\"instances\"][instance_name] - per instance configuration attributes tree\n\n= USAGE:\nThis cookbook implements redis instances as a definition. If you plan to run only one instance, use the +redis::default_instance+ recipe which call a \"redis_default\" +redis_instance+.\nTo spawn instances of redis, use the +redis_instance+ definition, usage is pretty straight forward:\n<tt>\nredis_instance \"datastore\" do\n port 8866\n data_dir \"/mnt/redis/datastore\"\n master master_node\nend\n</tt>\n\n_port_, <em>data_dir</em> and _master_ are the only attributes directly configurable using the definition syntax. Other attributes can be configured using the normal attribute interface under the <tt>node[\"redis2\"][\"instances\"][<em>instance_name</em>]</tt> scope. Missing attributes will be merged from <tt>node[\"redis2\"][\"instances\"][\"default\"]</tt>\n\nThe _master_ attribute will set up redis as a slave of a the same redis instance on another server. It will not set node[\"redis2\"][\"instances\"][<em>instance_name</em>][\"replication\"][\"role\"]</tt> (which can be _slave_ or _master_), because redis can be both at the same time (e.g. chained masters).\n\n== Recipes\n* redis2::auto - automagically call redis_instance for every instance defined in the node[\"redis2\"][\"instances\"] tree.\n* redis2::default_instance - use this if you want a simple recipe with a single redis instance\nIt's generally not a good idea to use the redis2::default_instance recipe. If you want a single redis instance, either use redis_instance definition or redis2::auto and define your instance in the attributes tree.\n",
|
||||
"maintainer": "Fewbytes Technologies, Inc.",
|
||||
"maintainer_email": "avishai@fewbytes.com",
|
||||
"license": "Apache 2.0",
|
||||
"platforms": {
|
||||
"ubuntu": ">= 9.04",
|
||||
"debian": ">= 6.0",
|
||||
"centos": ">= 5.5",
|
||||
"redhat": ">= 5.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"runit": ">= 0.0.0"
|
||||
},
|
||||
"recommendations": {
|
||||
},
|
||||
"suggestions": {
|
||||
},
|
||||
"conflicting": {
|
||||
},
|
||||
"providing": {
|
||||
},
|
||||
"replacing": {
|
||||
},
|
||||
"attributes": {
|
||||
"redis2/source_url": {
|
||||
"display_name": "Redis source URL",
|
||||
"default": "http://redis.googlecode.com/files/redis-2.2.2.tar.gz",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/build_dir": {
|
||||
"display_name": "Redis build directory",
|
||||
"default": "/opt/redis2/build",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/conf_dir": {
|
||||
"display_name": "Redis configuration dir containing redis.conf",
|
||||
"default": "/etc/redis",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/log_dir": {
|
||||
"display_name": "Directory used for log files",
|
||||
"default": "/var/log",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/timeout": {
|
||||
"display_name": "Timeout before connection close",
|
||||
"description": "Close the connection after a client is idle for N seconds (0 to disable)",
|
||||
"default": "300",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/dumpdb_filename": {
|
||||
"display_name": "Database dump filename",
|
||||
"default": "dump.db",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/data_dir": {
|
||||
"display_name": "Directory for storing the database persistance files",
|
||||
"default": "/var/lib/redis",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/activerehashing": {
|
||||
"display_name": "Rehash redis table in memory",
|
||||
"description": "Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in order to help rehashing the main Redis hash table (the one mapping top-level keys to values). The hash table implementation redis uses (see dict.c) performs a lazy rehashing: the more operations you run into an hash table that is rehashing, the more rehashing \"steps\" are performed, so if the server is idle the rehashing is never complete and some more memory is used by the hash table.takes about 1ms every 100ms",
|
||||
"default": "yes",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/databases": {
|
||||
"display_name": "Number of Redis database",
|
||||
"default": "16",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/vm/enabled": {
|
||||
"display_name": "Enable Redis swapping to disk",
|
||||
"default": "no",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/vm/swap_file": {
|
||||
"display_name": "Swap file location",
|
||||
"default": "/var/lib/redis2/swap",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/vm/max_memory": {
|
||||
"display_name": "Maximum memory usage before swapping",
|
||||
"desription": "Configures the VM to use at max the specified amount of RAM. Everything that deos not fit will be swapped on disk *if* possible, that is, if there is still enough contiguous space in the swap file.",
|
||||
"default": "70% of total memory",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/vm/page_size": {
|
||||
"display_name": "Memory page size (bytes) in swap file",
|
||||
"description": "Redis swap files is split into pages. An object can be saved using multiple contiguous pages, but pages can't be shared between different objects. So if your page is too big, small objects swapped out on disk will waste a lot of space. If you page is too small, there is less space in the swap file (assuming you configured the same number of total swap file pages).",
|
||||
"default": "32",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/vm/pages": {
|
||||
"display_name": "Number of memory pages in the swap file",
|
||||
"description": "Number of total memory pages in the swap file. Given that the page table (a bitmap of free/used pages) is taken in memory, every 8 pages on disk will consume 1 byte of RAM. The total swap size is vm-page-size * vm-pages. With the default of 32-bytes memory pages and 134217728 pages Redis will use a 4 GB swap file, that will use 16 MB of RAM for the page table. It's better to use the smallest acceptable value for your application, but the default is large in order to work in most conditions.",
|
||||
"default": "134217728",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/vm/max_threads": {
|
||||
"display_name": "Number of VM IO threads",
|
||||
"default": "4",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/maxmemory": {
|
||||
"display_name": "Maximum memory to use for redis",
|
||||
"default": "Unset",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/maxmemory_samples": {
|
||||
"display_name": "Sample size for eviction algorithms",
|
||||
"default": "3",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/maxmemory_policy": {
|
||||
"display_name": "Memory eviction algorithm",
|
||||
"default": "volatile-lru",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/appendonly": {
|
||||
"display_name": "Write append log",
|
||||
"default": "no",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/appendfsync": {
|
||||
"display_name": "Call fsync after writing to append log",
|
||||
"default": "everysec",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/no_appendfsync_on_rewrite": {
|
||||
"display_name": "Don't use fsync on rewrites",
|
||||
"default": "no",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"redis2/instances/default/replication/master_role": {
|
||||
"display_name": "Master Redis chef role",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
}
|
||||
},
|
||||
"groupings": {
|
||||
},
|
||||
"recipes": {
|
||||
"redis2": "Installs and configures redis",
|
||||
"redis2::auto": "Configures and activates redis instances defined by attributes"
|
||||
},
|
||||
"version": "0.4.4"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
## v0.15.0:
|
||||
|
||||
* [COOK-1008] - Added parameters for names of different templates in runit
|
|
@ -0,0 +1,226 @@
|
|||
Description
|
||||
===========
|
||||
|
||||
Installs runit and provides `runit_service` definition for managing new
|
||||
services under runit.
|
||||
|
||||
This cookbook does not use runit to replace system init, nor are there
|
||||
plans to do so.
|
||||
|
||||
For more information about runit:
|
||||
|
||||
* http://smarden.org/runit/
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
## Platform:
|
||||
|
||||
* Debian/Ubuntu
|
||||
* Gentoo
|
||||
|
||||
Attributes
|
||||
==========
|
||||
|
||||
See `attributes/default.rb` for defaults.
|
||||
|
||||
* `node['runit']['sv_bin']` - Full path to the `sv` binary.
|
||||
* `node['runit']['chpst_bin']` - Full path to the `chpst` binary.
|
||||
* `node['runit']['service_dir']` - Full path to the default "services"
|
||||
directory where enabled services are linked.
|
||||
* `node['runit']['sv_dir']` - Full path to the directory where the
|
||||
service lives, which gets linked to `service_dir`.
|
||||
|
||||
Recipes
|
||||
=======
|
||||
|
||||
default
|
||||
-------
|
||||
|
||||
Installs and sets up runit on the system. Assumes a package
|
||||
installation, so native package must exist. This recipe will make sure
|
||||
that the runsvdir process gets started, ensures that inittab is
|
||||
updated with the SV entry. The package will be preseeded on
|
||||
ubuntu/debian signal init, otherwise the appropriate action is chosen
|
||||
to notify the runsvdir command.
|
||||
|
||||
Older versions of Ubuntu (<= 10.04) are supported, but support may be
|
||||
removed in a future version.
|
||||
|
||||
Definitions
|
||||
===========
|
||||
|
||||
The definition in this cookbook will be deprecated by an LWRP in a
|
||||
future version. See __Roadmap__.
|
||||
|
||||
runit\_service
|
||||
--------------
|
||||
|
||||
This definition includes `recipe[runit]` to ensure it is installed
|
||||
first. As LWRPs cannot use `include_recipe`, this will not be
|
||||
available in future versions, so runit will need to be in a role or
|
||||
node run list.
|
||||
|
||||
Sets up a new service to be managed and supervised by runit. It will
|
||||
be created in the `node['runit']['sv_dir']` unless otherwise specified
|
||||
in the `directory` parameter (see below).
|
||||
|
||||
### Parameters:
|
||||
|
||||
* `name` - Name of the service. This will be used in the template file
|
||||
names (see __Usage__), as well as the name of the service resource
|
||||
created in the definition.
|
||||
* `directory` - the directory where the service's configuration and
|
||||
scripts should be located. Default is `node['runit']['sv_dir']`.
|
||||
* `only_if` - unused, will be removed in a future version (won't be
|
||||
present in lwrp). Default is false.
|
||||
* `finish_script` - if true, a finish script should be created.
|
||||
Default is false. For more information see: [Description of runsv](http://smarden.org/runit/runsv.8.html).
|
||||
* `control` - Array of signals to create a control directory with
|
||||
control scripts (e.g., `sv-SERVICE-control-SIGNAL.erb`, where
|
||||
SERVICE is the name parameter for the service name, and SIGNAL is
|
||||
the Unix signal to send. Default is an empty array. For more
|
||||
information see:
|
||||
[Customize Control](http://smarden.org/runit/runsv.8.html)
|
||||
* `run_restart` - if true, the service resource will subscribe to
|
||||
changes to the run script and restart itself when it is modified.
|
||||
Default is true.
|
||||
* `active_directory` - used for user-specific services. Default is
|
||||
`node['runit']['service_dir']`.
|
||||
* `owner` - userid of the owner for the service's files, and should be
|
||||
used in the run template with chpst to ensure the service runs as
|
||||
that user. Default is root.
|
||||
* `group` - groupid of the group for the service's files, and should
|
||||
be used in the run template with chpst to ensure the service runs as
|
||||
that group. Default is root.
|
||||
* `template_name` - specify an alternate name for the templates
|
||||
instead of basing them on the name parameter. Default is the name parameter.
|
||||
* `log_template_name` - specify an alternate name for the runit log template
|
||||
instead of basing them on the template_name parameter. Default is the
|
||||
template_name parameter.
|
||||
* `control_template_names` - specify alternate names for runit control signal
|
||||
templates instead of basing them on the template_name parameter. Default
|
||||
is the template_name parameter.
|
||||
* `finish_script_template_name` - specify an altername for the finish script
|
||||
template. Default is the template_name parameter
|
||||
* `start_command` - The command used to start the service in
|
||||
conjunction with the `sv` command and the `service_dir` name.
|
||||
Default is `start`.
|
||||
* `stop_command` - The command used to stop the service in conjunction
|
||||
with the `sv` command and the `service_dir` name. Default is `stop`.
|
||||
* `restart_command` - The command used to restart the service in
|
||||
conjunction with the `sv` command and the `service_dir` name. You
|
||||
may need to modify this to send an alternate signal to restart the
|
||||
service depending on the nature of the process. Default is `restart`
|
||||
* `status_command` - The command used to check status for the service in
|
||||
conjunction with the `sv` command and the `service_dir` name. This
|
||||
is used by chef when checking the current resource state in managing
|
||||
the service. Default is `status`.
|
||||
* `options` - a Hash of variables to pass into the run and log/run
|
||||
templates with the template resource `variables` parameter.
|
||||
Available inside the template(s) as `@options`. Default is an empty Hash.
|
||||
* `env` -
|
||||
|
||||
### Examples:
|
||||
|
||||
Create templates for `sv-myservice-run.erb` and
|
||||
`sv-myservice-log-run.erb` that have the commands for starting
|
||||
myservice and its logger.
|
||||
|
||||
runit_service "myservice"
|
||||
|
||||
See __Usage__ for expanded examples.
|
||||
|
||||
Resources/Providers
|
||||
===================
|
||||
|
||||
None yet. See __Roadmap__.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To get runit installed on supported platforms, use `recipe[runit]`.
|
||||
Once it is installed, use the `runit_service` definition to set up
|
||||
services to be managed by runit. Do note that once
|
||||
[CHEF-154](http://tickets.opscode.com/browse/CHEF-154) is implemented,
|
||||
some of the usage/implementation here will change. In order to use the
|
||||
`runit_service` definition, two templates must be created for the
|
||||
service, `cookbook_name/templates/default/sv-SERVICE-run.erb` and
|
||||
`cookbook_name/templates/default/sv-SERVICE-log-run.erb`. Replace
|
||||
`SERVICE` with the name of the service you're managing. For more usage,
|
||||
see __Examples__.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
We'll set up `chef-client` to run as a service under runit, such as is
|
||||
done in the `chef-client` cookbook. This example will be more simple
|
||||
than in that cookbook. First, create the required run template,
|
||||
`chef-client/templates/default/sv-chef-client-run.erb`.
|
||||
|
||||
#!/bin/sh
|
||||
exec 2>&1
|
||||
exec /usr/bin/env chef-client -i 1800 -s 30
|
||||
|
||||
Then create the required log/run template,
|
||||
`chef-client/templates/default/sv-chef-client-run.erb`.
|
||||
|
||||
#!/bin/sh
|
||||
exec svlogd -tt ./main
|
||||
|
||||
__Note__ This will cause output of the running process to go to
|
||||
`/etc/sv/chef-client/log/main/current`.
|
||||
|
||||
Finally, set up the service in the `chef-client` recipe with:
|
||||
|
||||
runit_service "chef-client"
|
||||
|
||||
Next, let's set up memcached with some additional options. First, the
|
||||
`memcached/templates/default/sv-memcached-run.erb` template:
|
||||
|
||||
#!/bin/sh
|
||||
exec 2>&1
|
||||
exec chpst -u <%= @options[:user] %> /usr/bin/memcached -v -m <%= @options[:memory] %> -p <%= @options[:port] %>
|
||||
|
||||
Note that the script uses chpst (which comes with runit) to set the
|
||||
user option, then starts memcached on the specified memory and port
|
||||
(see below).
|
||||
|
||||
The log/run template,
|
||||
`memcached/templates/default/sv-memcached-log-run.erb`:
|
||||
|
||||
#!/bin/sh
|
||||
exec svlogd -tt ./main
|
||||
|
||||
Finally, the `runit_service` in our recipe:
|
||||
|
||||
runit_service "memcached" do
|
||||
options({
|
||||
:memory => node[:memcached][:memory],
|
||||
:port => node[:memcached][:port],
|
||||
:user => node[:memcached][:user]}.merge(params)
|
||||
)
|
||||
end
|
||||
|
||||
This is where the user, port and memory options used in the run
|
||||
template are used.
|
||||
|
||||
License and Author
|
||||
==================
|
||||
|
||||
Author:: Adam Jacob <adam@opscode.com>
|
||||
Author:: Joshua Timberman <joshua@opscode.com>
|
||||
|
||||
Copyright:: 2008-2011, Opscode, Inc
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,8 +1,8 @@
|
|||
#
|
||||
# Cookbook Name:: celery
|
||||
# Recipe:: user
|
||||
# Cookbook Name:: runit
|
||||
# Attribute File:: sv_bin
|
||||
#
|
||||
# Copyright 2011, Rafael Durán Castañeda
|
||||
# Copyright 2008-2009, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,11 +17,15 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
group "#{node[:celery][:group]}" do
|
||||
action :create
|
||||
end
|
||||
|
||||
user "#{node[:celery][:user]}" do
|
||||
gid "#{node[:celery][:group]}"
|
||||
system true
|
||||
case platform
|
||||
when "ubuntu","debian"
|
||||
set[:runit][:sv_bin] = "/usr/bin/sv"
|
||||
set[:runit][:chpst_bin] = "/usr/bin/chpst"
|
||||
set[:runit][:service_dir] = "/etc/service"
|
||||
set[:runit][:sv_dir] = "/etc/sv"
|
||||
when "gentoo"
|
||||
set[:runit][:sv_bin] = "/usr/bin/sv"
|
||||
set[:runit][:chpst_bin] = "/usr/bin/chpst"
|
||||
set[:runit][:service_dir] = "/etc/service"
|
||||
set[:runit][:sv_dir] = "/var/service"
|
||||
end
|
|
@ -0,0 +1,164 @@
|
|||
#
|
||||
# Cookbook Name:: runit
|
||||
# Definition:: runit_service
|
||||
#
|
||||
# Copyright 2008-2009, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :active_directory => nil, :owner => "root", :group => "root", :template_name => nil, :log_template_name => nil, :control_template_names => {}, :finish_script_template_name => nil, :start_command => "start", :stop_command => "stop", :restart_command => "restart", :status_command => "status", :options => Hash.new, :env => Hash.new do
|
||||
include_recipe "runit"
|
||||
|
||||
params[:directory] ||= node[:runit][:sv_dir]
|
||||
params[:active_directory] ||= node[:runit][:service_dir]
|
||||
params[:template_name] ||= params[:name]
|
||||
params[:log_template_name] ||= params[:template_name]
|
||||
params[:control].each do |signal|
|
||||
params[:control_template_names][signal] ||= params[:template_name]
|
||||
end
|
||||
params[:finish_script_template_name] ||= params[:template_name]
|
||||
|
||||
sv_dir_name = "#{params[:directory]}/#{params[:name]}"
|
||||
service_dir_name = "#{params[:active_directory]}/#{params[:name]}"
|
||||
params[:options].merge!(:env_dir => "#{sv_dir_name}/env") unless params[:env].empty?
|
||||
|
||||
directory sv_dir_name do
|
||||
owner params[:owner]
|
||||
group params[:group]
|
||||
mode 0755
|
||||
action :create
|
||||
end
|
||||
|
||||
directory "#{sv_dir_name}/log" do
|
||||
owner params[:owner]
|
||||
group params[:group]
|
||||
mode 0755
|
||||
action :create
|
||||
end
|
||||
|
||||
directory "#{sv_dir_name}/log/main" do
|
||||
owner params[:owner]
|
||||
group params[:group]
|
||||
mode 0755
|
||||
action :create
|
||||
end
|
||||
|
||||
template "#{sv_dir_name}/run" do
|
||||
owner params[:owner]
|
||||
group params[:group]
|
||||
mode 0755
|
||||
source "sv-#{params[:template_name]}-run.erb"
|
||||
cookbook params[:cookbook] if params[:cookbook]
|
||||
if params[:options].respond_to?(:has_key?)
|
||||
variables :options => params[:options]
|
||||
end
|
||||
end
|
||||
|
||||
template "#{sv_dir_name}/log/run" do
|
||||
owner params[:owner]
|
||||
group params[:group]
|
||||
mode 0755
|
||||
source "sv-#{params[:log_template_name]}-log-run.erb"
|
||||
cookbook params[:cookbook] if params[:cookbook]
|
||||
if params[:options].respond_to?(:has_key?)
|
||||
variables :options => params[:options]
|
||||
end
|
||||
end
|
||||
|
||||
unless params[:env].empty?
|
||||
directory "#{sv_dir_name}/env" do
|
||||
mode 0755
|
||||
action :create
|
||||
end
|
||||
|
||||
params[:env].each do |var, value|
|
||||
file "#{sv_dir_name}/env/#{var}" do
|
||||
content value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if params[:finish_script]
|
||||
template "#{sv_dir_name}/finish" do
|
||||
owner params[:owner]
|
||||
group params[:group]
|
||||
mode 0755
|
||||
source "sv-#{params[:finish_script_template_name]}-finish.erb"
|
||||
cookbook params[:cookbook] if params[:cookbook]
|
||||
if params[:options].respond_to?(:has_key?)
|
||||
variables :options => params[:options]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless params[:control].empty?
|
||||
directory "#{sv_dir_name}/control" do
|
||||
owner params[:owner]
|
||||
group params[:group]
|
||||
mode 0755
|
||||
action :create
|
||||
end
|
||||
|
||||
params[:control].each do |signal|
|
||||
template "#{sv_dir_name}/control/#{signal}" do
|
||||
owner params[:owner]
|
||||
group params[:group]
|
||||
mode 0755
|
||||
source "sv-#{params[:control_template_names][signal]}-control-#{signal}.erb"
|
||||
cookbook params[:cookbook] if params[:cookbook]
|
||||
if params[:options].respond_to?(:has_key?)
|
||||
variables :options => params[:options]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if params[:active_directory] == node[:runit][:service_dir]
|
||||
link "/etc/init.d/#{params[:name]}" do
|
||||
to node[:runit][:sv_bin]
|
||||
end
|
||||
end
|
||||
|
||||
unless node[:platform] == "gentoo"
|
||||
link service_dir_name do
|
||||
to sv_dir_name
|
||||
end
|
||||
end
|
||||
|
||||
ruby_block "supervise_#{params[:name]}_sleep" do
|
||||
block do
|
||||
Chef::Log.debug("Waiting until named pipe #{sv_dir_name}/supervise/ok exists.")
|
||||
(1..10).each {|i| sleep 1 unless ::FileTest.pipe?("#{sv_dir_name}/supervise/ok") }
|
||||
end
|
||||
not_if { FileTest.pipe?("#{sv_dir_name}/supervise/ok") }
|
||||
end
|
||||
|
||||
service params[:name] do
|
||||
control_cmd = node[:runit][:sv_bin]
|
||||
if params[:owner]
|
||||
control_cmd = "#{node[:runit][:chpst_bin]} -u #{params[:owner]} #{control_cmd}"
|
||||
end
|
||||
provider Chef::Provider::Service::Init
|
||||
supports :restart => true, :status => true
|
||||
start_command "#{control_cmd} #{params[:start_command]} #{service_dir_name}"
|
||||
stop_command "#{control_cmd} #{params[:stop_command]} #{service_dir_name}"
|
||||
restart_command "#{control_cmd} #{params[:restart_command]} #{service_dir_name}"
|
||||
status_command "#{control_cmd} #{params[:status_command]} #{service_dir_name}"
|
||||
if params[:run_restart]
|
||||
subscribes :restart, resources(:template => "#{sv_dir_name}/run"), :delayed
|
||||
end
|
||||
action :nothing
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
runit runit/signalinit boolean true
|
|
@ -0,0 +1,6 @@
|
|||
start on runlevel-2
|
||||
start on runlevel-3
|
||||
start on runlevel-4
|
||||
start on runlevel-5
|
||||
stop on shutdown
|
||||
respawn /usr/sbin/runsvdir-start
|
|
@ -0,0 +1,7 @@
|
|||
start on runlevel 2
|
||||
start on runlevel 3
|
||||
start on runlevel 4
|
||||
start on runlevel 5
|
||||
stop on shutdown
|
||||
respawn
|
||||
exec /usr/sbin/runsvdir-start
|
|
@ -0,0 +1,7 @@
|
|||
start on runlevel 2
|
||||
start on runlevel 3
|
||||
start on runlevel 4
|
||||
start on runlevel 5
|
||||
stop on shutdown
|
||||
respawn
|
||||
exec /usr/sbin/runsvdir-start
|
|
@ -0,0 +1,7 @@
|
|||
start on runlevel 2
|
||||
start on runlevel 3
|
||||
start on runlevel 4
|
||||
start on runlevel 5
|
||||
stop on shutdown
|
||||
respawn
|
||||
exec /usr/sbin/runsvdir-start
|
|
@ -0,0 +1,102 @@
|
|||
{
|
||||
"name": "runit",
|
||||
"description": "Installs runit and provides runit_service definition",
|
||||
"long_description": "",
|
||||
"maintainer": "Opscode, Inc.",
|
||||
"maintainer_email": "cookbooks@opscode.com",
|
||||
"license": "Apache 2.0",
|
||||
"platforms": {
|
||||
"ubuntu": ">= 0.0.0",
|
||||
"debian": ">= 0.0.0",
|
||||
"gentoo": ">= 0.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
},
|
||||
"recommendations": {
|
||||
},
|
||||
"suggestions": {
|
||||
},
|
||||
"conflicting": {
|
||||
},
|
||||
"providing": {
|
||||
},
|
||||
"replacing": {
|
||||
},
|
||||
"attributes": {
|
||||
"runit": {
|
||||
"display_name": "Runit",
|
||||
"description": "Hash of runit attributes",
|
||||
"type": "hash",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"runit/sv_bin": {
|
||||
"display_name": "Runit sv bin",
|
||||
"description": "Location of the sv binary",
|
||||
"default": "/usr/bin/sv",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"runit/chpst_bin": {
|
||||
"display_name": "Runit chpst bin",
|
||||
"description": "Location of the chpst binary",
|
||||
"default": "/usr/bin/chpst",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"runit/service_dir": {
|
||||
"display_name": "Runit service directory",
|
||||
"description": "Symlinks to services managed under runit",
|
||||
"default": "/etc/service",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
},
|
||||
"runit/sv_dir": {
|
||||
"display_name": "Runit sv directory",
|
||||
"description": "Location of services managed by runit",
|
||||
"default": "/etc/sv",
|
||||
"choice": [
|
||||
|
||||
],
|
||||
"calculated": false,
|
||||
"type": "string",
|
||||
"required": "optional",
|
||||
"recipes": [
|
||||
|
||||
]
|
||||
}
|
||||
},
|
||||
"groupings": {
|
||||
},
|
||||
"recipes": {
|
||||
"runit": "Installs and configures runit"
|
||||
},
|
||||
"version": "0.15.0"
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
maintainer "Opscode, Inc."
|
||||
maintainer_email "cookbooks@opscode.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs runit and provides runit_service definition"
|
||||
version "0.15.0"
|
||||
|
||||
recipe "runit", "Installs and configures runit"
|
||||
|
||||
%w{ ubuntu debian gentoo }.each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
attribute "runit",
|
||||
:display_name => "Runit",
|
||||
:description => "Hash of runit attributes",
|
||||
:type => "hash"
|
||||
|
||||
attribute "runit/sv_bin",
|
||||
:display_name => "Runit sv bin",
|
||||
:description => "Location of the sv binary",
|
||||
:default => "/usr/bin/sv"
|
||||
|
||||
attribute "runit/chpst_bin",
|
||||
:display_name => "Runit chpst bin",
|
||||
:description => "Location of the chpst binary",
|
||||
:default => "/usr/bin/chpst"
|
||||
|
||||
attribute "runit/service_dir",
|
||||
:display_name => "Runit service directory",
|
||||
:description => "Symlinks to services managed under runit",
|
||||
:default => "/etc/service"
|
||||
|
||||
attribute "runit/sv_dir",
|
||||
:display_name => "Runit sv directory",
|
||||
:description => "Location of services managed by runit",
|
||||
:default => "/etc/sv"
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
#
|
||||
# Cookbook Name:: runit
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2008-2010, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
case node[:platform]
|
||||
when "debian","ubuntu", "gentoo"
|
||||
execute "start-runsvdir" do
|
||||
command value_for_platform(
|
||||
"debian" => { "default" => "runsvdir-start" },
|
||||
"ubuntu" => { "default" => "start runsvdir" },
|
||||
"gentoo" => { "default" => "/etc/init.d/runit-start start" }
|
||||
)
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "runit-hup-init" do
|
||||
command "telinit q"
|
||||
only_if "grep ^SV /etc/inittab"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
if platform? "gentoo"
|
||||
template "/etc/init.d/runit-start" do
|
||||
source "runit-start.sh.erb"
|
||||
mode 0755
|
||||
end
|
||||
end
|
||||
|
||||
package "runit" do
|
||||
action :install
|
||||
if platform?("ubuntu", "debian")
|
||||
response_file "runit.seed"
|
||||
end
|
||||
notifies value_for_platform(
|
||||
"debian" => { "4.0" => :run, "default" => :nothing },
|
||||
"ubuntu" => {
|
||||
"default" => :nothing,
|
||||
"9.04" => :run,
|
||||
"8.10" => :run,
|
||||
"8.04" => :run },
|
||||
"gentoo" => { "default" => :run }
|
||||
), resources(:execute => "start-runsvdir"), :immediately
|
||||
notifies value_for_platform(
|
||||
"debian" => { "squeeze/sid" => :run, "default" => :nothing },
|
||||
"default" => :nothing
|
||||
), resources(:execute => "runit-hup-init"), :immediately
|
||||
end
|
||||
|
||||
if node[:platform] =~ /ubuntu/i && node[:platform_version].to_f <= 8.04
|
||||
cookbook_file "/etc/event.d/runsvdir" do
|
||||
source "runsvdir"
|
||||
mode 0644
|
||||
notifies :run, resources(:execute => "start-runsvdir"), :immediately
|
||||
only_if do ::File.directory?("/etc/event.d") end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
#!/sbin/runscript
|
||||
# Copyright 1999-2006 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
depend() {
|
||||
after net
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting runsvdir"
|
||||
start-stop-daemon --start --exec /usr/bin/runsvdir \
|
||||
--background --make-pidfile \
|
||||
--pidfile /var/run/runsvdir.pid -- <%= node.runit.sv_dir %>
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
local ret1 ret2
|
||||
ebegin "Stopping runsvdir"
|
||||
start-stop-daemon --stop --oknodo --pidfile /var/run/runsvdir.pid
|
||||
ret1=$?
|
||||
eend ${ret1}
|
||||
|
||||
ebegin "Stopping services and logging"
|
||||
sv shutdown -w 10 <%= node.runit.sv_dir %>/*
|
||||
ret2=$?
|
||||
eend ${ret2}
|
||||
|
||||
return $((ret1+ret2))
|
||||
}
|
||||
|
Loading…
Reference in New Issue