Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'master' into master-merge-srcpackage
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtiss committed Mar 13, 2011
2 parents 81d1cc3 + 6171b3f commit 1d80549
Show file tree
Hide file tree
Showing 24 changed files with 236 additions and 90 deletions.
6 changes: 0 additions & 6 deletions bin/kokki

This file was deleted.

9 changes: 9 additions & 0 deletions kokki/cookbooks/jenkins/metadata.py
@@ -0,0 +1,9 @@

__description__ = "Jenkins CI"
__config__ = {
"jenkins.http_port": dict(
description = "HTTP port to listen on",
default = 8080,
)
}

32 changes: 32 additions & 0 deletions kokki/cookbooks/jenkins/recipes/default.py
@@ -0,0 +1,32 @@

from kokki import *

if env.system.platform in ("ubuntu", "debian"):
Execute("wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -",
not_if = "(apt-key list | grep 'Kohsuke Kawaguchi' > /dev/null)")


apt = "deb http://pkg.jenkins-ci.org/debian binary/"
apt_list_path = '/etc/apt/sources.list.d/jenkins.list'

Execute("apt-update-jenkins",
command = "apt-get update",
action = "nothing")

File(apt_list_path,
owner = "root",
group ="root",
mode = 0644,
content = apt+"\n",
notifies = [("run", env.resources["Execute"]["apt-update-jenkins"], True)])

Package("jenkins")

Service("jenkins")

File("/etc/default/jenkins",
owner = "root",
group = "root",
mode = 0644,
content = Template("jenkins/default.j2"),
notifies = [("restart", env.resources["Service"]["jenkins"])])
53 changes: 53 additions & 0 deletions kokki/cookbooks/jenkins/templates/default.j2
@@ -0,0 +1,53 @@
# defaults for jenkins continuous integration server

# pulled in from the init script; makes things easier.
NAME=jenkins

# location of java
JAVA=/usr/bin/java

# arguments to pass to java
#JAVA_ARGS="-Xmx256m"

PIDFILE=/var/run/jenkins/jenkins.pid

# user id to be invoked as (otherwise will run as root; not wise!)
JENKINS_USER=jenkins

# location of the jenkins war file
JENKINS_WAR=/usr/share/jenkins/jenkins.war

# jenkins home location
JENKINS_HOME=/var/lib/jenkins

# set this to false if you don't want Hudson to run by itself
# in this set up, you are expected to provide a servlet containr
# to host jenkins.
RUN_STANDALONE=true

# log location. this may be a syslog facility.priority
JENKINS_LOG=/var/log/jenkins/$NAME.log
#HUDSON_LOG=daemon.info

# OS LIMITS SETUP
# comment this out to observe /etc/security/limits.conf
# this is on by default because http://github.com/feniix/hudson/commit/d13c08ea8f5a3fa730ba174305e6429b74853927
# reported that Ubuntu's PAM configuration doesn't include pam_limits.so, and as a result the # of file
# descriptors are forced to 1024 regardless of /etc/security/limits.conf
MAXOPENFILES=8192

# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT={{ env.config.jenkins.http_port }}

# port for AJP connector (disabled by default)
AJP_PORT=-1

# arguments to pass to jenkins.
# --javahome=$JAVA_HOME
# --httpPort=$HTTP_PORT (default 8080; disable with -1)
# --httpsPort=$HTTP_PORT
# --ajp13Port=$AJP_PORT
# --argumentsRealm.passwd.$ADMIN_USER=[password]
# --argumentsRealm.$ADMIN_USER=admin
# --webroot=~/.jenkins/war
JENKINS_ARGS="--webroot=/var/run/jenkins/war --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT"
40 changes: 24 additions & 16 deletions kokki/cookbooks/mongodb/libraries/server.py
Expand Up @@ -31,19 +31,27 @@ def setup(name, **kwargs):
content = Template("mongodb/mongodb.conf.j2", variables=dict(mongodb=config))) content = Template("mongodb/mongodb.conf.j2", variables=dict(mongodb=config)))
# notifies = [("restart", env.resources["MonitService"]["mongodb-%s" % name])]) # notifies = [("restart", env.resources["MonitService"]["mongodb-%s" % name])])


# env.include_recipe("monit") controller = kwargs.get("controller")
# env.cookbooks.monit.rc("mongodb-%s" % name, if controller == "monit":
# Template("mongodb/monit.conf.j2", variables=dict(name=name, mongodb=config))) env.include_recipe("monit")
# env.cookbooks.monit.MonitService("mongodb-%s" % name, env.cookbooks.monit.rc("mongodb-%s" % name,
# subscribes = [("restart", env.resources["File"][config.configpath])]) Template("mongodb/monit.conf.j2", variables=dict(name=name, mongodb=config)))

env.cookbooks.monit.MonitService("mongodb-%s" % name,
Service("mongodb-%s" % name, subscribes = [("restart", env.resources["File"][config.configpath])])
subscribes = [("restart", env.resources["File"][config.configpath])]) elif controller == "supervisord":
File("/etc/init/mongodb-%s.conf" % name, env.include_recipe("supervisor")
owner = "root", env.cookbooks.supervisor.configuration("mongodb-%s" % name,
group = "root", Template("mongodb/supervisord.conf.j2", variables=dict(name=name, mongodb=config)))
mode = 0644, env.cookbooks.supervisor.SupervisorService("mongodb-%s" % name,
content = Template("mongodb/upstart.conf.j2", variables=dict(mongodb=config)), subscribes = [("restart", env.resources["File"][config.configpath])])
notifies = [ else:
("reload", env.resources["Service"]["mongodb-%s" % name], True), Service("mongodb-%s" % name,
]) subscribes = [("restart", env.resources["File"][config.configpath])])
File("/etc/init/mongodb-%s.conf" % name,
owner = "root",
group = "root",
mode = 0644,
content = Template("mongodb/upstart.conf.j2", variables=dict(mongodb=config)),
notifies = [
("reload", env.resources["Service"]["mongodb-%s" % name], True),
])
2 changes: 1 addition & 1 deletion kokki/cookbooks/mongodb/recipes/default.py
Expand Up @@ -58,7 +58,7 @@
mode = 0644, mode = 0644,
content = Template("mongodb/upstart.conf.j2", variables=dict(mongodb=env.config.mongodb)), content = Template("mongodb/upstart.conf.j2", variables=dict(mongodb=env.config.mongodb)),
notifies = [ notifies = [
("reload", env.resources["Service"]["mongodb"], True), ("restart", env.resources["Service"]["mongodb"], True),
]) ])


File(env.config.mongodb.configpath, File(env.config.mongodb.configpath,
Expand Down
4 changes: 4 additions & 0 deletions kokki/cookbooks/mongodb/templates/supervisord.conf.j2
@@ -0,0 +1,4 @@
[program:mongodb_{{ name }}]
command=/usr/bin/mongod --config {{ mongodb.configpath }} {{ " ".join(mongodb.options) }}
# autostart=true
stopwaitsecs=300
13 changes: 2 additions & 11 deletions kokki/cookbooks/monit/libraries/providers.py
@@ -1,18 +1,9 @@


import subprocess import subprocess
from kokki import * from kokki import *
from kokki.providers.service import ServiceProvider


class MonitServiceProvider(Provider): class MonitServiceProvider(ServiceProvider):
def action_start(self):
if not self.status():
self._init_cmd("start", 0)
self.resource.updated()

def action_stop(self):
if self.status():
self._init_cmd("stop", 0)
self.resource.updated()

def action_restart(self): def action_restart(self):
self._init_cmd("restart", 0) self._init_cmd("restart", 0)
self.resource.updated() self.resource.updated()
Expand Down
3 changes: 2 additions & 1 deletion kokki/cookbooks/pip/libraries/resources.py
Expand Up @@ -10,5 +10,6 @@ class PipPackage(Resource):


action = ForcedListArgument(default="install") action = ForcedListArgument(default="install")
package_name = ResourceArgument(default=lambda obj:obj.name) package_name = ResourceArgument(default=lambda obj:obj.name)
location = ResourceArgument(default=lambda obj:obj.package_name)
version = ResourceArgument(required = True) version = ResourceArgument(required = True)
actions = ["install", "upgrade", "remove", "purge"] actions = ["install", "upgrade", "remove", "purge"]
8 changes: 8 additions & 0 deletions kokki/cookbooks/powerdns/metadata.py
Expand Up @@ -9,4 +9,12 @@
description = "Pipe command", description = "Pipe command",
default = None, default = None,
), ),
"powerdns.allow_recursion": dict(
description = "List of addresses from which to allow recursion",
default = "127.0.0.1",
),
"powerdns.recursor": dict(
description = "IP address of recursing nameserver if desired",
default = None,
),
} }
6 changes: 4 additions & 2 deletions kokki/cookbooks/powerdns/templates/pdns.conf
Expand Up @@ -8,7 +8,7 @@
################################# #################################
# allow-recursion List of netmasks that are allowed to recurse # allow-recursion List of netmasks that are allowed to recurse
# #
allow-recursion=127.0.0.1 allow-recursion={{ env.config.powerdns.allow_recursion }}


################################# #################################
# allow-recursion-override Local data even about hosts that don't exist will # allow-recursion-override Local data even about hosts that don't exist will
Expand Down Expand Up @@ -197,7 +197,9 @@ module-dir=/usr/lib/powerdns
################################# #################################
# recursor If recursion is desired, IP address of a recursing nameserver # recursor If recursion is desired, IP address of a recursing nameserver
# #
# recursor= {% if env.config.powerdns.recursor %}
recursor={{ env.config.powerdns.recursor }}
{% endif %}


################################# #################################
# setgid If set, change group id to this gid for more security # setgid If set, change group id to this gid for more security
Expand Down
8 changes: 8 additions & 0 deletions kokki/cookbooks/rabbitmq/metadata.py
@@ -0,0 +1,8 @@

__description__ = "RabbitMQ Messaging Server"
__config__ = {
"rabbitmq.path": dict(
description = "Install path for rabbitmq",
default = "/usr/local/rabbitmq",
)
}
10 changes: 10 additions & 0 deletions kokki/cookbooks/rabbitmq/recipes/default.py
@@ -0,0 +1,10 @@

from kokki import *

Package("erlang")

if env.system.platform in ("ubuntu", "debian"):
pkg_url = "http://www.rabbitmq.com/releases/rabbitmq-server/v2.3.1/rabbitmq-server_2.3.1-1_all.deb"
Execute("cd /tmp ; wget %s ; dpkg -i %s ; rm rabbitmq*deb" % (pkg_url, pkg_url.rsplit('/', 1)[-1]),
not_if = "dpkg-query -c rabbitmq-server > /dev/null")

7 changes: 4 additions & 3 deletions kokki/cookbooks/supervisor/libraries/config.py
@@ -1,12 +1,13 @@


import os
from kokki import * from kokki import *


def config(name, content): def configuration(name, content):
env = Environment.get_instance() env = Environment.get_instance()
return File("supervisor-%s" % name, return File("supervisor-%s" % name,
content = content, content = content,
owner = "root", owner = "root",
group = "root", group = "root",
mode = 0644, mode = 0644,
path = "%s/supervisor.d/%s" % (env.config.supervisor.config_path, name), path = os.path.join(env.config.supervisor.custom_config_path, name) + ".conf",
notifies = [("restart", env.resources["Service"]["supervisor"])]) notifies = [("reload", env.resources["Service"]["supervisor"])])
2 changes: 1 addition & 1 deletion kokki/cookbooks/supervisor/libraries/providers.py
Expand Up @@ -22,7 +22,7 @@ def action_restart(self):
self.resource.updated() self.resource.updated()


def action_reload(self): def action_reload(self):
self._init_cmd("reload", 0) self._init_cmd("update", 0)
self.resource.updated() self.resource.updated()


def status(self): def status(self):
Expand Down
16 changes: 10 additions & 6 deletions kokki/cookbooks/supervisor/metadata.py
Expand Up @@ -2,22 +2,26 @@
__description__ = "Process monitoring" __description__ = "Process monitoring"
__config__ = { __config__ = {
"supervisor.config_path": dict( "supervisor.config_path": dict(
display_name = "Supervisor config path",
description = "Config file path for supervisor", description = "Config file path for supervisor",
default = "/etc", default = "/etc/supervisor/supervisord.conf",
),
"supervisor.socket_path": dict(
description = "Unix socket path",
default = "/var/run/supervisor.sock",
),
"supervisor.custom_config_path": dict(
description = "Path to custom supervisor config files",
default = "/etc/supervisor/conf.d",
), ),
"supervisor.binary_path": dict( "supervisor.binary_path": dict(
display_name = "Supervisor binary path",
description = "Path to the supervisor binaries", description = "Path to the supervisor binaries",
default = "/usr/local/bin", default = "/usr/bin",
), ),
"supervisor.pidfile": dict( "supervisor.pidfile": dict(
display_name = "Supervisor pid file path",
description = "Path to the supervisor pid file", description = "Path to the supervisor pid file",
default = "/var/run/supervisord.pid", default = "/var/run/supervisord.pid",
), ),
"supervisor.logfile": dict( "supervisor.logfile": dict(
display_name = "Supervisor log file path",
description = "Path to the supervisor log file", description = "Path to the supervisor log file",
default = "/var/log/supervisord.log", default = "/var/log/supervisord.log",
), ),
Expand Down
25 changes: 16 additions & 9 deletions kokki/cookbooks/supervisor/recipes/default.py
@@ -1,20 +1,27 @@


import os
from kokki import * from kokki import *


env.include_recipe("monit") # env.include_recipe("monit")


Package("supervisor", Package("supervisor")
provider = "kokki.providers.package.easy_install.EasyInstallProvider") # provider = "kokki.providers.package.easy_install.EasyInstallProvider")


File("supervisord.conf", File("supervisord.conf",
path = "%s/supervisord.conf" % env.config.supervisor.config_path, path = env.config.supervisor.config_path,
content = Template("supervisor/supervisord.conf.j2")) content = Template("supervisor/supervisord.conf.j2"))


Directory("supervisor.d", Directory("supervisor.d",
path = "%s/supervisor.d" % env.config.supervisor.config_path) path = env.config.supervisor.custom_config_path)


env.cookbooks.monit.rc("supervisord", supervisorctl = os.path.join(env.config.supervisor.binary_path, "supervisorctl")
content = Template("supervisor/monit.conf.j2")) Service("supervisor",
restart_command = "%s reload" % supervisorctl,
reload_command = "%s update" % supervisorctl,
subscribes = [("reload", env.resources["File"]["supervisord.conf"])])


env.cookbooks.monit.MonitService("supervisord", #env.cookbooks.monit.rc("supervisord",
subscribes = [("restart", env.resources["File"]["supervisord.conf"])]) # content = Template("supervisor/monit.conf.j2"))

#env.cookbooks.monit.MonitService("supervisord",
# subscribes = [("restart", env.resources["File"]["supervisord.conf"])])
8 changes: 5 additions & 3 deletions kokki/cookbooks/supervisor/templates/supervisord.conf.j2
@@ -1,5 +1,6 @@
[unix_http_server] [unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file) file={{ env.config.supervisor.socket_path }} ; (the path to the socket file)
chmod=0700


[supervisord] [supervisord]
logfile={{ env.config.supervisor.logfile }} ; (main log file;default $CWD/supervisord.log) logfile={{ env.config.supervisor.logfile }} ; (main log file;default $CWD/supervisord.log)
Expand All @@ -10,12 +11,13 @@ pidfile={{ env.config.supervisor.pidfile }} ; (supervisord pidfile;default super
nodaemon=false ; (start in foreground if true;default false) nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024) minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200) minprocs=200 ; (min. avail process descriptors;default 200)
childlogdir=/var/log/supervisor


[rpcinterface:supervisor] [rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface


[supervisorctl] [supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket serverurl=unix://{{ env.config.supervisor.socket_path }} ; use a unix:// URL for a unix socket


[include] [include]
files = supervisor.d/* files = {{ env.config.supervisor.custom_config_path }}/*.conf
6 changes: 3 additions & 3 deletions kokki/cookbooks/users/metadata.py
@@ -1,8 +1,8 @@


__description__ = "Manage user accounts and sysadmins" __description__ = "Manage user accounts and sysadmins"
__config__ = { __config__ = {
"sysadmins": dict( "users": dict(
description = "List of sysadmins (id,username,sshkey_id,sshkey_type,sshkey)", description = "Disctionary of sysadmins with username as the key and value as a dictionary of (id,sshkey_id,sshkey_type,sshkey)",
default = [], default = {},
) )
} }

0 comments on commit 1d80549

Please sign in to comment.