From 34138ea0eaaba86f93d4988fff3807d5b5ac1949 Mon Sep 17 00:00:00 2001 From: Miquel Torres Date: Tue, 26 Oct 2010 16:38:07 +0200 Subject: [PATCH] Add setup.py for distribution Remove chef-solo.rb and create it on the fly --- MANIFEST.in | 4 + README.textile | 54 ++-- chef-solo.rb | 3 - cook | 17 +- cookbooks/apt/README.md | 55 ---- cookbooks/apt/files/default/apt-cacher | 9 - cookbooks/apt/files/default/apt-cacher.conf | 144 ---------- cookbooks/apt/files/default/apt-proxy-v2.conf | 50 ---- cookbooks/apt/metadata.json | 38 --- cookbooks/apt/metadata.rb | 12 - cookbooks/apt/recipes/cacher.rb | 42 --- cookbooks/apt/recipes/default.rb | 33 --- cookbooks/apt/recipes/proxy.rb | 34 --- cookbooks/haproxy/attributes/default.rb | 4 +- cookbooks/nginx/README.rdoc | 61 ----- cookbooks/nginx/attributes/default.rb | 44 --- cookbooks/nginx/definitions/nginx_site.rb | 35 --- cookbooks/nginx/files/default/mime.types | 73 ----- cookbooks/nginx/metadata.json | 255 ------------------ cookbooks/nginx/metadata.rb | 86 ------ cookbooks/nginx/recipes/backports.rb | 66 ----- cookbooks/nginx/recipes/default.rb | 56 ---- cookbooks/nginx/recipes/source.rb | 133 --------- .../templates/default/backports.list.erb | 1 - .../nginx/templates/default/default-site.erb | 11 - .../nginx/templates/default/nginx.conf.erb | 40 --- .../nginx/templates/default/nginx.init.erb | 92 ------- .../templates/default/nginx.sysconfig.erb | 1 - .../nginx/templates/default/nxdissite.erb | 29 -- .../nginx/templates/default/nxensite.erb | 38 --- .../templates/default/sv-nginx-log-run.erb | 2 - .../nginx/templates/default/sv-nginx-run.erb | 3 - littlechef.py | 12 +- setup.py | 44 +++ 34 files changed, 99 insertions(+), 1482 deletions(-) create mode 100644 MANIFEST.in delete mode 100644 chef-solo.rb delete mode 100644 cookbooks/apt/README.md delete mode 100644 cookbooks/apt/files/default/apt-cacher delete mode 100644 cookbooks/apt/files/default/apt-cacher.conf delete mode 100644 cookbooks/apt/files/default/apt-proxy-v2.conf delete mode 100644 cookbooks/apt/metadata.json delete mode 100644 cookbooks/apt/metadata.rb delete mode 100644 cookbooks/apt/recipes/cacher.rb delete mode 100644 cookbooks/apt/recipes/default.rb delete mode 100644 cookbooks/apt/recipes/proxy.rb delete mode 100644 cookbooks/nginx/README.rdoc delete mode 100644 cookbooks/nginx/attributes/default.rb delete mode 100644 cookbooks/nginx/definitions/nginx_site.rb delete mode 100644 cookbooks/nginx/files/default/mime.types delete mode 100644 cookbooks/nginx/metadata.json delete mode 100644 cookbooks/nginx/metadata.rb delete mode 100644 cookbooks/nginx/recipes/backports.rb delete mode 100644 cookbooks/nginx/recipes/default.rb delete mode 100644 cookbooks/nginx/recipes/source.rb delete mode 100644 cookbooks/nginx/templates/default/backports.list.erb delete mode 100644 cookbooks/nginx/templates/default/default-site.erb delete mode 100644 cookbooks/nginx/templates/default/nginx.conf.erb delete mode 100644 cookbooks/nginx/templates/default/nginx.init.erb delete mode 100644 cookbooks/nginx/templates/default/nginx.sysconfig.erb delete mode 100644 cookbooks/nginx/templates/default/nxdissite.erb delete mode 100644 cookbooks/nginx/templates/default/nxensite.erb delete mode 100644 cookbooks/nginx/templates/default/sv-nginx-log-run.erb delete mode 100644 cookbooks/nginx/templates/default/sv-nginx-run.erb create mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..9a0378f --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include README.textile +include LICENSE +graft cookbooks +graft roles diff --git a/README.textile b/README.textile index 55719c4..a93348b 100644 --- a/README.textile +++ b/README.textile @@ -6,11 +6,9 @@ h2. Overview You can think of this like a pocket Chef. You don't need to worry about installation, repository syncing, nor Chef Server authentication. You also won't have to remotely edit cookbooks, or commit little changes just to test things. -Downloading LittleChef is all you need to get you started. +Installing or downloading LittleChef is all you need to get you started. -in the @littlechef@ directory there is: -@cook@: Bash script that calls fabric so that you can type 'cook' instead of 'fab' -@fabfile.py@: this is where the actual code is +in your working @littlechef@ directory there is: @nodes/@: after recipes are run on nodes, their configuration is stored here @cookbooks/@: This will be your cookbooks repository. You should put this under version control. Note that it is not recommended to clone the whole opscode cookbooks repository because its 7 MB compressed would make syncing cookbooks at the nodes a bit slow @roles/@: Where roles are defined @@ -24,22 +22,22 @@ The result is that you can play as often with your recipes and nodes as you want h2. Requirements * Python 2.6+ +* Setuptools * Fabric 0.9.2 All needed packages should get installed by typing -@sudo apt-get install python-fabric@ for Debian and Ubuntu +@sudo apt-get install python-setuptools python-fabric@ for Debian and Ubuntu or -@yum install fabric@ for RHEL and CentOS +@yum install python-setuptools fabric@ for RHEL and CentOS h2. Installation -There is none. You just need to install the required packages and download and uncompress LittleChef. +You can install LittleChef directly from the PyPI: +@easy_install littlechef@ -To start cooking change to the @littlechef@ dir and always issue commands from there, calling @./cook@ +A directory called @littlechef@ will be created in your home directory with a sample recipe and role. You can however copy or remove it and use any other directory to keep your deployment "projects". -For convenience, you can copy the file @cook@ to your PATH. For example: -@sudo cp cook /user/bin/@ -You will then be able to type @cook@ instead of @./cook@. +Note: there is a package that also provides a cook executable. To avoid it colliding with LittleChef's executable, you need to remove the "cook" package. h2. Usage @@ -61,7 +59,7 @@ password = yourpassword h3. Deploy There is a command that allows you to deploy chef-client/-solo to a node using the packages from the "Opscode repository":http://wiki.opscode.com/display/chef/Installation#Installation-InstallingChefClientandChefSolo: -@./cook node:MYNODE deploy_chef:MYDISTRO@ +@cook node:MYNODE deploy_chef:MYDISTRO@ MYDISTRO can have one of the following values for debian based distributions: 'lucid', 'karmic', 'jaunty', 'hardy', 'sid', 'squeeze', 'lenny' @@ -74,32 +72,30 @@ Also, the CentOS and RHEL installation method has not been tested. Feedback is w h3. Cook -Note: Allways cook inside your local @littlechef/@ directory. +Note: Always cook inside your working directory, where you should have a roles, a nodes, and a recipes directory. -* @./cook -l@: Show a list of all available commands. -* @./cook node:MYNODE recipe:MYRECIPE@: Cook a recipe on a particular node by giving its hostname or IP. +* @cook -l@: Show a list of all available commands. +* @cook node:MYNODE recipe:MYRECIPE@: Cook a recipe on a particular node by giving its hostname or IP. Note that the first time this is run for a node, a configuration file will be created at @nodes/hostname.json@. You can then edit this file to override recipe attributes for example. Further runs of this command will not overwrite this configuration file. -You can force the saving of the run with @./cook node:MYNODE recipe:MYRECIPE,save=True@. -* @./cook node:MYNODE role:MYROLE@: The same as above but role-based -* @./cook configure@: It will apply all roles, recipes and attributes defined in @nodes/MYNODE.json@ to ALL nodes present in @littlechef/nodes/@. -* @./cook node:MYNODE configure@: Configures a particular pre-configured node -* @./cook debug configure@: You can start all your commands with @./cook debug@ to see all Chef Solo debbuging information +You can force the saving of the run with @cook node:MYNODE recipe:MYRECIPE,save=True@. +* @cook node:MYNODE role:MYROLE@: The same as above but role-based +* @cook configure@: It will apply all roles, recipes and attributes defined in @nodes/MYNODE.json@ to ALL nodes present in @littlechef/nodes/@. +* @cook node:MYNODE configure@: Configures a particular pre-configured node +* @cook debug configure@: You can start all your commands with @cook debug@ to see all Chef Solo debbuging information h3. Consulting the inventory -* @./cook list_nodes@: Lists all nodes showing its associated recipes, roles and attributes -* @./cook list_nodes_with_recipe:MYRECIPE@: The same as above but it only lists nodes which have associated the recipe @MYRECIPE@ -* @./cook list_nodes_with_role:MYROLE@: The same as above but it only lists nodes which have associated the role @MYROLE@ +* @cook list_nodes@: Lists all nodes showing its associated recipes, roles and attributes +* @cook list_nodes_with_recipe:MYRECIPE@: The same as above but it only lists nodes which have associated the recipe @MYRECIPE@ +* @cook list_nodes_with_role:MYROLE@: The same as above but it only lists nodes which have associated the role @MYROLE@ h2. Getting started -There are some sample cookbooks and a sample role to get you started. +There is a sample cookbook and a sample role to get you started. try: -@./cook node:MYNODE1 recipe:nginx@ -and -@./cook node:MYNODE2 recipe:haproxy@ +@cook node:MYNODE recipe:haproxy@ -The haproxy is a modified opscode recipe so that it accepts an array of load balanced servers. You can edit the new configuration file at @nodes/MYNODE2.json@ and add some attributes. Make it look like this (ignore the littlechef custom fields): +The haproxy is a modified opscode recipe so that it accepts an array of load balanced servers. You can edit the new configuration file at @nodes/MYNODE.json@ and add some attributes. Make it look like this (ignore the littlechef custom fields): bc. { "littlechef": {"nodename": "myhostname", "nodeid": "myhostnameorip"}, @@ -113,6 +109,6 @@ bc. { } Next, reapply configuration to all nodes: -@./cook configure@ +@cook configure@ Happy cooking! diff --git a/chef-solo.rb b/chef-solo.rb deleted file mode 100644 index 438300e..0000000 --- a/chef-solo.rb +++ /dev/null @@ -1,3 +0,0 @@ -file_cache_path "/tmp/chef-solo" -cookbook_path "/tmp/chef-solo/cookbooks" -role_path "/tmp/chef-solo/roles" diff --git a/cook b/cook index 9cb507a..b1bcf6a 100755 --- a/cook +++ b/cook @@ -1,2 +1,15 @@ -#!/bin/bash -fab -f littlechef.py $@ +#!/usr/bin/env python +import sys +from subprocess import call +from distutils.sysconfig import get_python_lib + +args = ['fab', '-f', '%s/littlechef.py' % get_python_lib()] + +if len(sys.argv) > 1: + # Pass on arguments to fabric + args.extend(sys.argv[1:]) +else: + sys.exit("No command given. Type '%s -l' for a list of commands" % sys.argv[0]) + +# Call fabric with the given arguments +call(args) diff --git a/cookbooks/apt/README.md b/cookbooks/apt/README.md deleted file mode 100644 index 0f6eb28..0000000 --- a/cookbooks/apt/README.md +++ /dev/null @@ -1,55 +0,0 @@ -DESCRIPTION -=========== - -Configures various APT components on Debian-like systems. - -RECIPES -======= - -default -------- - -The default recipe runs apt-get update during the Compile Phase of the Chef run to ensure that the system's package cache is updated with the latest. It is recommended that this recipe appear first in a node's run list (directly or through a role) to ensure that when installing packages, Chef will be able to download the latest version available on the remote APT repository. - -This recipe also sets up a local cache directory for preseeding packages. - -cacher ------- - -Installs the apt-cacher package and service so the system can be an APT cache. - -proxy ------ - -Installs the apt-proxy package and service so the system can be an APT proxy. - -USAGE -===== - -Put `recipe[apt]` first in the run list. If you have other recipes that you want to use to configure how apt behaves, like new sources, notify the execute resource to run, e.g.: - - template "/etc/apt/sources.list.d/my_apt_sources.list" do - notifies :run, resources(:execute => "apt-get update"), :immediately - end - -The above will run during execution phase since it is a normal template resource, and should appear before other package resources that need the sources in the template. - -LICENSE AND AUTHOR -================== - -Author:: Joshua Timberman () - -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. - diff --git a/cookbooks/apt/files/default/apt-cacher b/cookbooks/apt/files/default/apt-cacher deleted file mode 100644 index dab9488..0000000 --- a/cookbooks/apt/files/default/apt-cacher +++ /dev/null @@ -1,9 +0,0 @@ -# apt-cacher startup configuration file - -# IMPORTANT: check the apt-cacher.conf file before using apt-cacher as daemon. - -# set to 1 to start the daemon at boot time -AUTOSTART=1 - -# extra settings to override the ones in apt-cacher.conf -# EXTRAOPT=" daemon_port=3142 limit=30 " diff --git a/cookbooks/apt/files/default/apt-cacher.conf b/cookbooks/apt/files/default/apt-cacher.conf deleted file mode 100644 index 32ca3c3..0000000 --- a/cookbooks/apt/files/default/apt-cacher.conf +++ /dev/null @@ -1,144 +0,0 @@ -# This file has been modified by ./apt-proxy-to-apt-cacher -# Some lines may have been appended at the bottom of this file -# This file has been modified by /usr/share/apt-cacher/apt-proxy-to-apt-cacher -# Some lines may have been appended at the bottom of this file -################################################################# -# This is the config file for apt-cacher. On most Debian systems -# you can safely leave the defaults alone. -################################################################# - -# cache_dir is used to set the location of the local cache. This can -# become quite large, so make sure it is somewhere with plenty of space. -cache_dir=/var/cache/apt-cacher - -# The email address of the administrator is displayed in the info page -# and traffic reports. -admin_email=root@localhost - -# For the daemon startup settings please edit the file /etc/default/apt-cacher. - -# Daemon port setting, only useful in stand-alone mode. You need to run the -# daemon as root to use privileged ports (<1024). -daemon_port = 3142 - -# optional settings, user and group to run the daemon as. Make sure they have -# sufficient permissions on the cache and log directories. Comment the settings -# to run apt-cacher as the native user. -group=www-data -user=www-data - -# optional setting, binds the listening daemon to one specified IP. Use IP -# ranges for more advanced configuration, see below. -# daemon_addr=localhost - -# If your apt-cacher machine is directly exposed to the Internet and you are -# worried about unauthorised machines fetching packages through it, you can -# specify a list of IPv4 addresses which are allowed to use it and another -# list of IPv4 addresses which aren't. -# Localhost (127.0.0.1) is always allowed. Other addresses must be matched -# by allowed_hosts and not by denied_hosts to be permitted to use the cache. -# Setting allowed_hosts to "*" means "allow all". -# Otherwise the format is a comma-separated list containing addresses, -# optionally with masks (like 10.0.0.0/22), or ranges of addresses (two -# addresses separated by a hyphen, no masks, like '192.168.0.3-192.168.0.56'). -allowed_hosts=* -denied_hosts= - -# And similiarly for IPv6 with allowed_hosts_6 and denied_hosts_6. -# Note that IPv4-mapped IPv6 addresses (::ffff:w.x.y.z) are truncated to -# w.x.y.z and are handled as IPv4. -allowed_hosts_6=fec0::/16 -denied_hosts_6= - -# This thing can be done by Apache but is much simplier here - limit access to -# Debian mirrors based on server names in the URLs -#allowed_locations=ftp.uni-kl.de,ftp.nerim.net,debian.tu-bs.de - -# Apt-cacher can generate usage reports every 24 hours if you set this -# directive to 1. You can view the reports in a web browser by pointing -# to your cache machine with '/apt-cacher/report' on the end, like this: -# http://yourcache.example.com/apt-cacher/report -# Generating reports is very fast even with many thousands of logfile -# lines, so you can safely turn this on without creating much -# additional system load. -generate_reports=1 - -# Apt-cacher can clean up its cache directory every 24 hours if you set -# this directive to 1. Cleaning the cache can take some time to run -# (generally in the order of a few minutes) and removes all package -# files that are not mentioned in any existing 'Packages' lists. This -# has the effect of deleting packages that have been superseded by an -# updated 'Packages' list. -clean_cache=1 - -# The directory to use for apt-cacher access and error logs. -# The access log records every request in the format: -# date-time|client ip address|HIT/MISS/EXPIRED|object size|object name -# The error log is slightly more free-form, and is also used for debug -# messages if debug mode is turned on. -# Note that the old 'logfile' and 'errorfile' directives are -# deprecated: if you set them explicitly they will be honoured, but it's -# better to just get rid of them from old config files. -logdir=/var/log/apt-cacher - -# apt-cacher can use different methods to decide whether package lists need to -# be updated, -# A) looking at the age of the cached files -# B) getting HTTP header from server and comparing that with cached data. This -# method is more reliable and avoids desynchronisation of data and index files -# but needs to transfer few bytes from the server every time somebody requests -# the files ("apt-get update") -# Set the following value to the maximum age (in hours) for method A or to 0 -# for method B -expire_hours=0 - -# Apt-cacher can pass all its requests to an external http proxy like -# Squid, which could be very useful if you are using an ISP that blocks -# port 80 and requires all web traffic to go through its proxy. The -# format is 'hostname:port', eg: 'proxy.example.com:8080'. -http_proxy=proxy.example.com:8080 - -# Use of an external proxy can be turned on or off with this flag. -# Value should be either 0 (off) or 1 (on). -use_proxy=0 - -# External http proxy sometimes need authentication to get full access. The -# format is 'username:password'. -http_proxy_auth=proxyuser:proxypass - -# Use of external proxy authentication can be turned on or off with this flag. -# Value should be either 0 (off) or 1 (on). -use_proxy_auth=0 - -# Rate limiting sets the maximum bandwidth in bytes per second to use -# for fetching packages. Syntax is fully defined in 'man wget'. -# Use 'k' or 'm' to use kilobits or megabits / second: eg, 'limit=25k'. -# Use 0 or a negative value for no rate limiting. -limit=0 - -# Debug mode makes apt-cacher spew a lot of extra debug junk to the -# error log (whose location is defined with the 'logdir' directive). -# Leave this off unless you need it, or your error log will get very -# big. Acceptable values are 0 or 1. -debug=0 - -# Adapt the line in the usage info web page to match your server configuration -# example_sources_line=deb http://my.cacher.server:3142/ftp.au.debian.org/debian unstable main contrib non-free - -# Print a 410 (Gone) HTTP message with the specified text when accessed via -# CGI. Useful to tell users to adapt their sources.list files when the -# apt-cacher server is beeing relocated (via apt-get's error messages while -# running "update") -#cgi_advise_to_use = Please use http://cacheserver:3142/ as apt-cacher access URL -#cgi_advise_to_use = Server relocated. To change sources.list, run perl -pe "s,/apt-cacher\??,:3142," -i /etc/apt/sources.list - -# Server mapping - this allows to hide real server names behind virtual paths -# that appear in the access URL. This method is known from apt-proxy. This is -# also the only method to use FTP access to the target hosts. The syntax is simple, the part of the beginning to replace, followed by a list of mirror urls, all space separated. Multiple profile are separated by semicolons -# path_map = debian ftp.uni-kl.de/pub/linux/debian ftp2.de.debian.org/debian ; ubuntu archive.ubuntu.com/ubuntu ; security security.debian.org/debian-security ftp2.de.debian.org/debian-security -# Note that you need to specify all target servers in the allowed_locations -# options if you make use of it. Also note that the paths should not overlap -# each other. FTP access method not supported yet, maybe in the future. - -# extra setting from apt-proxy configuration -path_map = ubuntu us.archive.ubuntu.com/ubuntu ; ubuntu-security security.ubuntu.com/ubuntu ; debian debian.osuosl.org/debian/ ; security security.debian.org/debian-security diff --git a/cookbooks/apt/files/default/apt-proxy-v2.conf b/cookbooks/apt/files/default/apt-proxy-v2.conf deleted file mode 100644 index 6541f25..0000000 --- a/cookbooks/apt/files/default/apt-proxy-v2.conf +++ /dev/null @@ -1,50 +0,0 @@ -[DEFAULT] -;; All times are in seconds, but you can add a suffix -;; for minutes(m), hours(h) or days(d) - -;; commented out address so apt-proxy will listen on all IPs -;; address = 127.0.0.1 -port = 9999 -cache_dir = /var/cache/apt-proxy - -;; Control files (Packages/Sources/Contents) refresh rate -min_refresh_delay = 1s -complete_clientless_downloads = 1 - -;; Debugging settings. -debug = all:4 db:0 - -time = 30 -passive_ftp = on - -;;-------------------------------------------------------------- -;; Cache housekeeping - -cleanup_freq = 1d -max_age = 120d -max_versions = 3 - -;;--------------------------------------------------------------- -;; Backend servers -;; -;; Place each server in its own [section] - -[ubuntu] -; Ubuntu archive -backends = - http://us.archive.ubuntu.com/ubuntu - -[ubuntu-security] -; Ubuntu security updates -backends = http://security.ubuntu.com/ubuntu - -[debian] -;; Backend servers, in order of preference -backends = - http://debian.osuosl.org/debian/ - -[security] -;; Debian security archive -backends = - http://security.debian.org/debian-security - http://ftp2.de.debian.org/debian-security diff --git a/cookbooks/apt/metadata.json b/cookbooks/apt/metadata.json deleted file mode 100644 index 8ac0d15..0000000 --- a/cookbooks/apt/metadata.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "recommendations": { - }, - "attributes": { - }, - "maintainer": "Opscode, Inc.", - "suggestions": { - }, - "dependencies": { - }, - "maintainer_email": "cookbooks@opscode.com", - "conflicting": { - }, - "platforms": { - "debian": [ - - ], - "ubuntu": [ - - ] - }, - "license": "Apache 2.0", - "version": "0.9.1", - "providing": { - }, - "recipes": { - "apt::proxy": "Set up an APT proxy", - "apt": "Runs apt-get update during compile phase and sets up preseed directories", - "apt::cacher": "Set up an APT cache" - }, - "replacing": { - }, - "name": "apt", - "description": "Configures apt and apt services", - "groupings": { - }, - "long_description": "" - } \ No newline at end of file diff --git a/cookbooks/apt/metadata.rb b/cookbooks/apt/metadata.rb deleted file mode 100644 index 068a92b..0000000 --- a/cookbooks/apt/metadata.rb +++ /dev/null @@ -1,12 +0,0 @@ -maintainer "Opscode, Inc." -maintainer_email "cookbooks@opscode.com" -license "Apache 2.0" -description "Configures apt and apt services" -version "0.9.1" -recipe "apt", "Runs apt-get update during compile phase and sets up preseed directories" -recipe "apt::cacher", "Set up an APT cache" -recipe "apt::proxy", "Set up an APT proxy" - -%w{ ubuntu debian }.each do |os| - supports os -end diff --git a/cookbooks/apt/recipes/cacher.rb b/cookbooks/apt/recipes/cacher.rb deleted file mode 100644 index f6fed58..0000000 --- a/cookbooks/apt/recipes/cacher.rb +++ /dev/null @@ -1,42 +0,0 @@ -# -# Cookbook Name:: apt -# Recipe:: cacher -# -# 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. -# -package "apt-cacher" do - action :install -end - -service "apt-cacher" do - supports :restart => true, :status => false - action [ :enable, :start ] -end - -cookbook_file "/etc/apt-cacher/apt-cacher.conf" do - source "apt-cacher.conf" - owner "root" - group "root" - mode 0644 - notifies :restart, resources(:service => "apt-cacher") -end - -cookbook_file "/etc/default/apt-cacher" do - source "apt-cacher" - owner "root" - group "root" - mode 0644 - notifies :restart, resources(:service => "apt-cacher") -end diff --git a/cookbooks/apt/recipes/default.rb b/cookbooks/apt/recipes/default.rb deleted file mode 100644 index d1117a7..0000000 --- a/cookbooks/apt/recipes/default.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# Cookbook Name:: apt -# Recipe:: default -# -# 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. -# - -e = execute "apt-get update" do - action :nothing -end - -e.run_action(:run) - -%w{/var/cache/local /var/cache/local/preseeding}.each do |dirname| - directory dirname do - owner "root" - group "root" - mode 0755 - action :create - end -end diff --git a/cookbooks/apt/recipes/proxy.rb b/cookbooks/apt/recipes/proxy.rb deleted file mode 100644 index b843fa1..0000000 --- a/cookbooks/apt/recipes/proxy.rb +++ /dev/null @@ -1,34 +0,0 @@ -# -# Cookbook Name:: apt -# Recipe:: proxy -# -# 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. -# -package "apt-proxy" do - action :install -end - -service "apt-proxy" do - supports :restart => true, :status => false - action [ :enable, :start ] -end - -cookbook_file "/etc/apt-proxy/apt-proxy-v2.conf" do - source "apt-proxy-v2.conf" - owner "root" - group "root" - mode 0644 - notifies :restart, resources(:service => "apt-proxy") -end diff --git a/cookbooks/haproxy/attributes/default.rb b/cookbooks/haproxy/attributes/default.rb index f17e125..612fe37 100644 --- a/cookbooks/haproxy/attributes/default.rb +++ b/cookbooks/haproxy/attributes/default.rb @@ -1,4 +1,4 @@ default[:haproxy][:servers] = [ - { :name => "kuku1", :ip => "1.1.1" }, - { :name => "kuku2", :ip => "1.1.2" }, + { :name => "S1", :ip => "1.1.1" }, + { :name => "S2", :ip => "1.1.2" }, ] diff --git a/cookbooks/nginx/README.rdoc b/cookbooks/nginx/README.rdoc deleted file mode 100644 index dee86a5..0000000 --- a/cookbooks/nginx/README.rdoc +++ /dev/null @@ -1,61 +0,0 @@ -= DESCRIPTION: - -Installs nginx from package OR source code and sets up configuration handling similar to Debian's Apache2 scripts. - -= REQUIREMENTS: - -== Cookbooks: - -* build-essential (for nginx::source) - -== Platform: - -Debian or Ubuntu though may work where 'build-essential' works, but other platforms are untested. - -= ATTRIBUTES: - -* version - sets the version to install. -* install_path - for nginx::source, sets the --prefix installation. -* src_binary - for nginx::source, sets the binary location. -* dir - configuration dir. -* log_dir - where logs go. -* user - user to run as. -* binary - path to nginx binary. -* configure_flags - for nginx::source, the flags to use for compilation. -* gzip* - configure the gzip module. -* keepalive - whether to use keepalive. -* keepalive_timeout -* worker_processes - number of workers to spawn. -* worker_connections - number of connections per worker. -* server_names_hash_bucket_size - -= USAGE: - -Provides two ways to install and configure nginx. - -* Install via native package (nginx::default) -* Install via compiled source (nginx::source) - -Both recipes implement configuration handling similar to the Debian Apache2 site enable/disable. - -There's some redundancy in that the config handling hasn't been separated from the installation method (yet), so use only one of the recipes. - -= LICENSE and AUTHOR: - -Author:: Joshua Timberman () -Author:: Adam Jacob () -Author:: AJ Christensen () - -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. diff --git a/cookbooks/nginx/attributes/default.rb b/cookbooks/nginx/attributes/default.rb deleted file mode 100644 index e7a1813..0000000 --- a/cookbooks/nginx/attributes/default.rb +++ /dev/null @@ -1,44 +0,0 @@ -default[:nginx][:version] = "0.7.67" -default[:nginx][:install_path] = "/opt/nginx-#{nginx[:version]}" -default[:nginx][:src_binary] = "#{nginx[:install_path]}/sbin/nginx" - -case platform -when "debian","ubuntu" - set[:nginx][:dir] = "/etc/nginx" - set[:nginx][:log_dir] = "/var/log/nginx" - set[:nginx][:user] = "www-data" - set[:nginx][:binary] = "/usr/sbin/nginx" -else - set[:nginx][:dir] = "/etc/nginx" - set[:nginx][:log_dir] = "/var/log/nginx" - set[:nginx][:user] = "www-data" - set[:nginx][:binary] = "/usr/sbin/nginx" -end - -default[:nginx][:configure_flags] = [ - "--prefix=#{nginx[:install_path]}", - "--conf-path=#{nginx[:dir]}/nginx.conf", - "--with-http_ssl_module", - "--with-http_gzip_static_module" -] - -default[:nginx][:gzip] = "on" -default[:nginx][:gzip_http_version] = "1.0" -default[:nginx][:gzip_comp_level] = "2" -default[:nginx][:gzip_proxied] = "any" -default[:nginx][:gzip_types] = [ - "text/plain", - "text/html", - "text/css", - "application/x-javascript", - "text/xml", - "application/xml", - "application/xml+rss", - "text/javascript" -] - -default[:nginx][:keepalive] = "on" -default[:nginx][:keepalive_timeout] = 65 -default[:nginx][:worker_processes] = cpu[:total] -default[:nginx][:worker_connections] = 2048 -default[:nginx][:server_names_hash_bucket_size] = 64 diff --git a/cookbooks/nginx/definitions/nginx_site.rb b/cookbooks/nginx/definitions/nginx_site.rb deleted file mode 100644 index cdc5d27..0000000 --- a/cookbooks/nginx/definitions/nginx_site.rb +++ /dev/null @@ -1,35 +0,0 @@ -# -# Cookbook Name:: nginx -# Definition:: nginx_site -# Author:: AJ Christensen -# -# 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 :nginx_site, :enable => true do - if params[:enable] - execute "nxensite #{params[:name]}" do - command "/usr/sbin/nxensite #{params[:name]}" - notifies :restart, resources(:service => "nginx") - not_if do File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end - end - else - execute "nxdissite #{params[:name]}" do - command "/usr/sbin/nxdissite #{params[:name]}" - notifies :restart, resources(:service => "nginx") - only_if do File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end - end - end -end diff --git a/cookbooks/nginx/files/default/mime.types b/cookbooks/nginx/files/default/mime.types deleted file mode 100644 index 0ba964e..0000000 --- a/cookbooks/nginx/files/default/mime.types +++ /dev/null @@ -1,73 +0,0 @@ -types { - text/html html htm shtml; - text/css css; - text/xml xml; - image/gif gif; - image/jpeg jpeg jpg; - application/x-javascript js; - application/json json; - application/atom+xml atom; - application/rss+xml rss; - - text/mathml mml; - text/plain txt; - text/vnd.sun.j2me.app-descriptor jad; - text/vnd.wap.wml wml; - text/x-component htc; - - image/png png; - image/tiff tif tiff; - image/vnd.wap.wbmp wbmp; - image/x-icon ico; - image/x-jng jng; - image/x-ms-bmp bmp; - image/svg+xml svg; - - application/java-archive jar war ear; - application/mac-binhex40 hqx; - application/msword doc; - application/pdf pdf; - application/postscript ps eps ai; - application/rtf rtf; - application/vnd.ms-excel xls; - application/vnd.ms-powerpoint ppt; - application/vnd.wap.wmlc wmlc; - application/vnd.wap.xhtml+xml xhtml; - application/vnd.google-earth.kml+xml kml; - application/vnd.google-earth.kmz kmz; - application/x-cocoa cco; - application/x-java-archive-diff jardiff; - application/x-java-jnlp-file jnlp; - application/x-makeself run; - application/x-perl pl pm; - application/x-pilot prc pdb; - application/x-rar-compressed rar; - application/x-redhat-package-manager rpm; - application/x-sea sea; - application/x-shockwave-flash swf; - application/x-stuffit sit; - application/x-tcl tcl tk; - application/x-x509-ca-cert der pem crt; - application/x-xpinstall xpi; - application/zip zip; - - application/octet-stream bin exe dll; - application/octet-stream deb; - application/octet-stream dmg; - application/octet-stream eot; - application/octet-stream iso img; - application/octet-stream msi msp msm; - - audio/midi mid midi kar; - audio/mpeg mp3; - audio/x-realaudio ra; - - video/3gpp 3gpp 3gp; - video/mpeg mpeg mpg; - video/quicktime mov; - video/x-flv flv; - video/x-mng mng; - video/x-ms-asf asx asf; - video/x-ms-wmv wmv; - video/x-msvideo avi; -} diff --git a/cookbooks/nginx/metadata.json b/cookbooks/nginx/metadata.json deleted file mode 100644 index 7bc47cc..0000000 --- a/cookbooks/nginx/metadata.json +++ /dev/null @@ -1,255 +0,0 @@ -{ - "providing": { - }, - "platforms": { - "debian": [ - - ], - "fedora": [ - - ], - "centos": [ - - ], - "ubuntu": [ - - ], - "redhat": [ - - ] - }, - "description": "Installs and configures nginx", - "attributes": { - "nginx/worker_connections": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "1024", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Worker Connections", - "description": "Number of connections per worker" - }, - "nginx/gzip_types": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": [ - "text/plain", - "text/html", - "text/css", - "application/x-javascript", - "text/xml", - "application/xml", - "application/xml+rss", - "text/javascript" - ], - "type": "array", - "recipes": [ - - ], - "display_name": "Nginx Gzip Types", - "description": "Supported MIME-types for gzip" - }, - "nginx/binary": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "/usr/sbin/nginx", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Binary", - "description": "Location of the nginx server binary" - }, - "nginx/user": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "www-data", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx User", - "description": "User nginx will run as" - }, - "nginx/keepalive_timeout": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "65", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Keepalive Timeout" - }, - "nginx/gzip_proxied": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "any", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Gzip Proxied", - "description": "Whether gzip is proxied" - }, - "nginx/gzip_comp_level": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "2", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Gzip Compression Level", - "description": "Amount of compression to use" - }, - "nginx/dir": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "/etc/nginx", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Directory", - "description": "Location of nginx configuration files" - }, - "nginx/server_names_hash_bucket_size": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "64", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Server Names Hash Bucket Size" - }, - "nginx/worker_processes": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "1", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Worker Processes", - "description": "Number of worker processes" - }, - "nginx/gzip_http_version": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "1.0", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Gzip HTTP Version", - "description": "Version of HTTP Gzip" - }, - "nginx/log_dir": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "/var/log/nginx", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Log Directory", - "description": "Location for nginx logs" - }, - "nginx/gzip": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "on", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Gzip", - "description": "Whether gzip is enabled" - }, - "nginx/keepalive": { - "required": "optional", - "calculated": false, - "choice": [ - - ], - "default": "on", - "type": "string", - "recipes": [ - - ], - "display_name": "Nginx Keepalive", - "description": "Whether to enable keepalive" - } - }, - "replacing": { - }, - "dependencies": { - "runit": [ - - ], - "build-essential": [ - - ] - }, - "version": "0.14.3", - "groupings": { - }, - "long_description": "", - "recommendations": { - }, - "maintainer": "Opscode, Inc.", - "suggestions": { - }, - "license": "Apache 2.0", - "name": "nginx", - "maintainer_email": "cookbooks@opscode.com", - "recipes": { - "nginx::source": "Installs nginx from source and sets up configuration with Debian apache style with sites-enabled/sites-available", - "nginx": "Installs nginx package and sets up configuration with Debian apache style with sites-enabled/sites-available" - }, - "conflicting": { - } - } \ No newline at end of file diff --git a/cookbooks/nginx/metadata.rb b/cookbooks/nginx/metadata.rb deleted file mode 100644 index 1f1360f..0000000 --- a/cookbooks/nginx/metadata.rb +++ /dev/null @@ -1,86 +0,0 @@ -maintainer "Opscode, Inc." -maintainer_email "cookbooks@opscode.com" -license "Apache 2.0" -description "Installs and configures nginx" -version "0.14.3" - -recipe "nginx", "Installs nginx package and sets up configuration with Debian apache style with sites-enabled/sites-available" -recipe "nginx::source", "Installs nginx from source and sets up configuration with Debian apache style with sites-enabled/sites-available" - -%w{ ubuntu debian centos redhat fedora }.each do |os| - supports os -end - -%w{ build-essential runit }.each do |cb| - depends cb -end - -attribute "nginx/dir", - :display_name => "Nginx Directory", - :description => "Location of nginx configuration files", - :default => "/etc/nginx" - -attribute "nginx/log_dir", - :display_name => "Nginx Log Directory", - :description => "Location for nginx logs", - :default => "/var/log/nginx" - -attribute "nginx/user", - :display_name => "Nginx User", - :description => "User nginx will run as", - :default => "www-data" - -attribute "nginx/binary", - :display_name => "Nginx Binary", - :description => "Location of the nginx server binary", - :default => "/usr/sbin/nginx" - -attribute "nginx/gzip", - :display_name => "Nginx Gzip", - :description => "Whether gzip is enabled", - :default => "on" - -attribute "nginx/gzip_http_version", - :display_name => "Nginx Gzip HTTP Version", - :description => "Version of HTTP Gzip", - :default => "1.0" - -attribute "nginx/gzip_comp_level", - :display_name => "Nginx Gzip Compression Level", - :description => "Amount of compression to use", - :default => "2" - -attribute "nginx/gzip_proxied", - :display_name => "Nginx Gzip Proxied", - :description => "Whether gzip is proxied", - :default => "any" - -attribute "nginx/gzip_types", - :display_name => "Nginx Gzip Types", - :description => "Supported MIME-types for gzip", - :type => "array", - :default => [ "text/plain", "text/html", "text/css", "application/x-javascript", "text/xml", "application/xml", "application/xml+rss", "text/javascript" ] - -attribute "nginx/keepalive", - :display_name => "Nginx Keepalive", - :description => "Whether to enable keepalive", - :default => "on" - -attribute "nginx/keepalive_timeout", - :display_name => "Nginx Keepalive Timeout", - :default => "65" - -attribute "nginx/worker_processes", - :display_name => "Nginx Worker Processes", - :description => "Number of worker processes", - :default => "1" - -attribute "nginx/worker_connections", - :display_name => "Nginx Worker Connections", - :description => "Number of connections per worker", - :default => "1024" - -attribute "nginx/server_names_hash_bucket_size", - :display_name => "Nginx Server Names Hash Bucket Size", - :default => "64" - diff --git a/cookbooks/nginx/recipes/backports.rb b/cookbooks/nginx/recipes/backports.rb deleted file mode 100644 index 8cad1e3..0000000 --- a/cookbooks/nginx/recipes/backports.rb +++ /dev/null @@ -1,66 +0,0 @@ -# -# Cookbook Name:: nginx -# Recipe:: default -# Author:: AJ Christensen -# -# 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. -# - -include_recipe "apt" - -template "/etc/apt/sources.list.d/backports.list" do - mode "0644" - source "backports.list.erb" - notifies :run, resources(:execute => "apt-get update"), :immediately -end - -bash "install-nginx-from-backports" do - code "apt-get -t lenny-backports install --yes nginx" -end - -directory node[:nginx][:log_dir] do - mode 0755 - owner node[:nginx][:user] - action :create -end - -%w{nxensite nxdissite}.each do |nxscript| - template "/usr/sbin/#{nxscript}" do - source "#{nxscript}.erb" - mode 0755 - owner "root" - group "root" - end -end - -template "nginx.conf" do - path "#{node[:nginx][:dir]}/nginx.conf" - source "nginx.conf.erb" - owner "root" - group "root" - mode 0644 -end - -template "#{node[:nginx][:dir]}/sites-available/default" do - source "default-site.erb" - owner "root" - group "root" - mode 0644 -end - -service "nginx" do - supports :status => true, :restart => true, :reload => true - action [ :enable, :start ] -end diff --git a/cookbooks/nginx/recipes/default.rb b/cookbooks/nginx/recipes/default.rb deleted file mode 100644 index 4c0c3b0..0000000 --- a/cookbooks/nginx/recipes/default.rb +++ /dev/null @@ -1,56 +0,0 @@ -# -# Cookbook Name:: nginx -# Recipe:: default -# Author:: AJ Christensen -# -# 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. -# - -package "nginx" - -directory node[:nginx][:log_dir] do - mode 0755 - owner node[:nginx][:user] - action :create -end - -%w{nxensite nxdissite}.each do |nxscript| - template "/usr/sbin/#{nxscript}" do - source "#{nxscript}.erb" - mode 0755 - owner "root" - group "root" - end -end - -template "nginx.conf" do - path "#{node[:nginx][:dir]}/nginx.conf" - source "nginx.conf.erb" - owner "root" - group "root" - mode 0644 -end - -template "#{node[:nginx][:dir]}/sites-available/default" do - source "default-site.erb" - owner "root" - group "root" - mode 0644 -end - -service "nginx" do - supports :status => true, :restart => true, :reload => true - action [ :enable, :start ] -end diff --git a/cookbooks/nginx/recipes/source.rb b/cookbooks/nginx/recipes/source.rb deleted file mode 100644 index 1880c51..0000000 --- a/cookbooks/nginx/recipes/source.rb +++ /dev/null @@ -1,133 +0,0 @@ -# -# Cookbook Name:: nginx -# Recipe:: source -# -# Author:: Adam Jacob () -# Author:: Joshua Timberman () -# -# 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 "build-essential" - -unless platform?("centos","redhat","fedora") - include_recipe "runit" -end - -packages = value_for_platform( - ["centos","redhat","fedora"] => {'default' => ['pcre-devel', 'openssl-devel']}, - "default" => ['libpcre3', 'libpcre3-dev', 'libssl-dev'] - ) - -packages.each do |devpkg| - package devpkg -end - -nginx_version = node[:nginx][:version] -configure_flags = node[:nginx][:configure_flags].join(" ") -node.set[:nginx][:daemon_disable] = true - -remote_file "/tmp/nginx-#{nginx_version}.tar.gz" do - source "http://sysoev.ru/nginx/nginx-#{nginx_version}.tar.gz" - action :create_if_missing -end - -bash "compile_nginx_source" do - cwd "/tmp" - code <<-EOH - tar zxf nginx-#{nginx_version}.tar.gz - cd nginx-#{nginx_version} && ./configure #{configure_flags} - make && make install - EOH - creates node[:nginx][:src_binary] -end - -directory node[:nginx][:log_dir] do - mode 0755 - owner node[:nginx][:user] - action :create -end - -directory node[:nginx][:dir] do - owner "root" - group "root" - mode "0755" -end - -unless platform?("centos","redhat","fedora") - runit_service "nginx" - - service "nginx" do - subscribes :restart, resources(:bash => "compile_nginx_source") - end -else - #install init db script - template "/etc/init.d/nginx" do - source "nginx.init.erb" - owner "root" - group "root" - mode "0755" - end - - #install sysconfig file (not really needed but standard) - template "/etc/sysconfig/nginx" do - source "nginx.sysconfig.erb" - owner "root" - group "root" - mode "0644" - end - - #register service - service "nginx" do - supports :status => true, :restart => true, :reload => true - action :enable - subscribes :restart, resources(:bash => "compile_nginx_source") - end -end - - -%w{ sites-available sites-enabled conf.d }.each do |dir| - directory "#{node[:nginx][:dir]}/#{dir}" do - owner "root" - group "root" - mode "0755" - end -end - -%w{nxensite nxdissite}.each do |nxscript| - template "/usr/sbin/#{nxscript}" do - source "#{nxscript}.erb" - mode "0755" - owner "root" - group "root" - end -end - -template "nginx.conf" do - path "#{node[:nginx][:dir]}/nginx.conf" - source "nginx.conf.erb" - owner "root" - group "root" - mode "0644" - notifies :restart, resources(:service => "nginx"), :immediately -end - -cookbook_file "#{node[:nginx][:dir]}/mime.types" do - source "mime.types" - owner "root" - group "root" - mode "0644" - notifies :restart, resources(:service => "nginx"), :immediately -end diff --git a/cookbooks/nginx/templates/default/backports.list.erb b/cookbooks/nginx/templates/default/backports.list.erb deleted file mode 100644 index 8ddfd45..0000000 --- a/cookbooks/nginx/templates/default/backports.list.erb +++ /dev/null @@ -1 +0,0 @@ -deb http://backports.debian.org/debian-backports lenny-backports main diff --git a/cookbooks/nginx/templates/default/default-site.erb b/cookbooks/nginx/templates/default/default-site.erb deleted file mode 100644 index 5177e48..0000000 --- a/cookbooks/nginx/templates/default/default-site.erb +++ /dev/null @@ -1,11 +0,0 @@ -server { - listen 80; - server_name <%= node[:hostname] %>; - - access_log <%= node[:nginx][:log_dir] %>/localhost.access.log; - - location / { - root /var/www/nginx-default; - index index.html index.htm; - } -} diff --git a/cookbooks/nginx/templates/default/nginx.conf.erb b/cookbooks/nginx/templates/default/nginx.conf.erb deleted file mode 100644 index 369841e..0000000 --- a/cookbooks/nginx/templates/default/nginx.conf.erb +++ /dev/null @@ -1,40 +0,0 @@ -user <%= node[:nginx][:user] %>; -worker_processes <%= node[:nginx][:worker_processes] %>; -<% if node[:nginx][:daemon_disable] -%> -daemon off; -<% end -%> - -error_log <%= node[:nginx][:log_dir] %>/error.log; -pid /var/run/nginx.pid; - -events { - worker_connections <%= node[:nginx][:worker_connections] %>; -} - -http { - include <%= node[:nginx][:dir] %>/mime.types; - default_type application/octet-stream; - - access_log <%= node[:nginx][:log_dir] %>/access.log; - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - - <% if node[:nginx][:keepalive] == "on" %> - keepalive_timeout <%= node[:nginx][:keepalive_timeout] %>; - <% end %> - - gzip <%= node[:nginx][:gzip] %>; - <% if node[:nginx][:gzip] == "on" %> - gzip_http_version <%= node[:nginx][:gzip_http_version] %>; - gzip_comp_level <%= node[:nginx][:gzip_comp_level] %>; - gzip_proxied <%= node[:nginx][:gzip_proxied] %>; - gzip_types <%= node[:nginx][:gzip_types].join(' ') %>; - <% end %> - - server_names_hash_bucket_size <%= node[:nginx][:server_names_hash_bucket_size] %>; - - include <%= node[:nginx][:dir] %>/conf.d/*.conf; - include <%= node[:nginx][:dir] %>/sites-enabled/*; -} diff --git a/cookbooks/nginx/templates/default/nginx.init.erb b/cookbooks/nginx/templates/default/nginx.init.erb deleted file mode 100644 index 20db455..0000000 --- a/cookbooks/nginx/templates/default/nginx.init.erb +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -# -# nginx -# -# chkconfig: - 57 47 -# description: nginx -# processname: nginx -# config: /etc/sysconfig/nginx -# - -# Source function library. -. /etc/rc.d/init.d/functions - -# Source networking configuration. -. /etc/sysconfig/network - -# Check that networking is up. -[ "$NETWORKING" = "no" ] && exit -exec=<%= node[:nginx][:src_binary] %> -prog=$(basename $exec) - -# default options, overruled by items in sysconfig -NGINX_GLOBAL="" - -[ -e /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx - -lockfile=/var/lock/subsys/nginx - -start() { - [ -x $exec ] || exit 5 - echo -n $"Starting $prog: " - # if not running, start it up here, usually something like "daemon $exec" - options="" - if [ "${NGINX_GLOBAL}" != "" ]; then - options="-g ${NGINX_GLOBAL}" - fi - $exec $options - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval -} - -stop() { - echo -n $"Stopping $prog: " - $exec -s stop - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - echo -n $"Reloading $prog: " - $exec -s reload - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - status nginx - ;; - restart) - restart - ;; - reload|force-reload) - reload - ;; - condrestart) - [ -f $lockfile ] && restart || : - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}" - exit 1 -esac - -exit $? \ No newline at end of file diff --git a/cookbooks/nginx/templates/default/nginx.sysconfig.erb b/cookbooks/nginx/templates/default/nginx.sysconfig.erb deleted file mode 100644 index 55438c6..0000000 --- a/cookbooks/nginx/templates/default/nginx.sysconfig.erb +++ /dev/null @@ -1 +0,0 @@ -NGINX_GLOBAL=<%= node[:nginx][:global] %> \ No newline at end of file diff --git a/cookbooks/nginx/templates/default/nxdissite.erb b/cookbooks/nginx/templates/default/nxdissite.erb deleted file mode 100644 index c8ad090..0000000 --- a/cookbooks/nginx/templates/default/nxdissite.erb +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -e - -SYSCONFDIR='<%= node[:nginx][:dir] %>' - -if [ -z $1 ]; then - echo "Which site would you like to disable?" - echo -n "Your choices are: " - ls $SYSCONFDIR/sites-enabled/* | \ - sed -e "s,$SYSCONFDIR/sites-enabled/,,g" | xargs echo - echo -n "Site name? " - read SITENAME -else - SITENAME=$1 -fi - -if [ $SITENAME = "default" ]; then - PRIORITY="000" -fi - -if ! [ -e $SYSCONFDIR/sites-enabled/$SITENAME -o \ - -e $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" ]; then - echo "This site is already disabled, or does not exist!" - exit 1 -fi - -if ! rm $SYSCONFDIR/sites-enabled/$SITENAME 2>/dev/null; then - rm -f $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" -fi -echo "Site $SITENAME disabled; reload nginx to disable." diff --git a/cookbooks/nginx/templates/default/nxensite.erb b/cookbooks/nginx/templates/default/nxensite.erb deleted file mode 100644 index e684d21..0000000 --- a/cookbooks/nginx/templates/default/nxensite.erb +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -e - -SYSCONFDIR='<%= node[:nginx][:dir] %>' - -if [ -z $1 ]; then - echo "Which site would you like to enable?" - echo -n "Your choices are: " - ls $SYSCONFDIR/sites-available/* | \ - sed -e "s,$SYSCONFDIR/sites-available/,,g" | xargs echo - echo -n "Site name? " - read SITENAME -else - SITENAME=$1 -fi - -if [ $SITENAME = "default" ]; then - PRIORITY="000" -fi - -if [ -e $SYSCONFDIR/sites-enabled/$SITENAME -o \ - -e $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" ]; then - echo "This site is already enabled!" - exit 0 -fi - -if ! [ -e $SYSCONFDIR/sites-available/$SITENAME ]; then - echo "This site does not exist!" - exit 1 -fi - -if [ $SITENAME = "default" ]; then - ln -sf $SYSCONFDIR/sites-available/$SITENAME \ - $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" -else - ln -sf $SYSCONFDIR/sites-available/$SITENAME $SYSCONFDIR/sites-enabled/$SITENAME -fi - -echo "Site $SITENAME installed; reload nginx to enable." diff --git a/cookbooks/nginx/templates/default/sv-nginx-log-run.erb b/cookbooks/nginx/templates/default/sv-nginx-log-run.erb deleted file mode 100644 index a79a518..0000000 --- a/cookbooks/nginx/templates/default/sv-nginx-log-run.erb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec svlogd -tt ./main diff --git a/cookbooks/nginx/templates/default/sv-nginx-run.erb b/cookbooks/nginx/templates/default/sv-nginx-run.erb deleted file mode 100644 index c7a3ee2..0000000 --- a/cookbooks/nginx/templates/default/sv-nginx-run.erb +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -exec 2>&1 -exec <%= node[:nginx][:install_path] %>/sbin/nginx -c <%= node[:nginx][:dir] %>/nginx.conf diff --git a/littlechef.py b/littlechef.py index 19efa85..6416f67 100644 --- a/littlechef.py +++ b/littlechef.py @@ -37,7 +37,7 @@ def _readconfig(): abort('You need to define a valid user in auth.cfg') env.password = config.get('userinfo', 'password') except ConfigParser.NoSectionError: - abort('You need to define user and password in the "userinfo" section of auth.cfg. Refer to the README for help') + abort('You need to define user and password in the "userinfo" section of auth.cfg. Refer to the README for help (http://github.com/tobami/littlechef)') env.loglevel = "info" if not os.path.exists('nodes'): os.mkdir('nodes') @@ -142,8 +142,14 @@ def deploy_chef(distro): else: abort('wrong distro type: %s' % distro_type) # Setup - put('chef-solo.rb', 'solo.rb') - sudo('mv solo.rb /etc/chef/') + sudo('touch /etc/chef/solo.rb') + sudo('rm /etc/chef/solo.rb') + append('file_cache_path "/tmp/chef-solo"', + '/etc/chef/solo.rb', use_sudo=True) + append('cookbook_path "/tmp/chef-solo/cookbooks"', + '/etc/chef/solo.rb', use_sudo=True) + append('role_path "/tmp/chef-solo/roles"', + '/etc/chef/solo.rb', use_sudo=True) sudo('mkdir -p /tmp/chef-solo/roles') # Copy cookbooks diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..a1a878c --- /dev/null +++ b/setup.py @@ -0,0 +1,44 @@ +# LittleChef's setup.py +from distutils.core import setup +setup( + name = "littlechef", + version = "0.1", + description = "Cook with Chef without Chef Server", + author = "Miquel Torres", + author_email = "tobami@googlemail.com", + url = "http://github.com/tobami/littlechef", + download_url = "http://github.com/tobami/littlechef/archives/master", + keywords = ["chef", "devops"], + install_requires=['fabric>=0.9.2'], + data_files=[ + ('littlechef/roles', ['roles/loadbalancer.json']), + ('littlechef/cookbooks/haproxy', [ + 'cookbooks/haproxy/README.rdoc', 'cookbooks/haproxy/metadata.json', + 'cookbooks/haproxy/metadata.rb']), + ('littlechef/cookbooks/haproxy/attributes', [ + 'cookbooks/haproxy/attributes/default.rb']), + ('littlechef/cookbooks/haproxy/recipes', [ + 'cookbooks/haproxy/recipes/default.rb']), + ('littlechef/cookbooks/haproxy/templates/default', [ + 'cookbooks/haproxy/templates/default/haproxy-default.erb', + 'cookbooks/haproxy/templates/default/haproxy.cfg.erb']), + ], + py_modules = ['littlechef'], + scripts = ['cook'], + classifiers = [ + "Programming Language :: Python", + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + 'Topic :: System :: Systems Administration', + ], + long_description = """\ +Cook with Chef without Chef Server +------------------------------------- +It works as follows: Whenever you apply a recipe to a node, your cookbook dir is gzipped and uploaded to that node. A node.json file gets created on the fly and uploaded, and Chef Solo gets executed at the remote node, using node.json as the node configuration and the pre-installed solo.rb for Chef Solo configuration. Cookbooks and roles are configured to be found at (/tmp/chef-solo/). + +The result is that you can play as often with your recipes and nodes as you want, without having to worry about repositories, central servers nor anything else. Once you are satisfied with a new feature in a cookbook, you can commit the littlechef/cookbook/ directory to your repository. LittleChef brings back sanity to cookbook development. +""" +)