Exemple #1
0
def setup(name, **kwargs):
    env = Environment.get_instance()
    config = env.config.mongodb.copy()
    config.update(kwargs)

    config['configpath'] = "/etc/mongodb/%s.conf" % name
    if 'dbpath' not in kwargs:
        config['dbpath'] = os.path.join(config.dbpath, name)
    if 'logfilename' not in kwargs:
        config['logfilename'] = "%s.log" % name

    Directory("/etc/mongodb", owner="root", group="root", mode=0755)

    Directory(config.dbpath,
              owner="mongodb",
              group="mongodb",
              mode=0755,
              recursive=True)

    File(config.configpath,
         owner="root",
         group="root",
         mode=0644,
         content=Template("mongodb/mongodb.conf.j2",
                          variables=dict(mongodb=config)))
    # notifies = [("restart", env.resources["MonitService"]["mongodb-%s" % name])])

    controller = kwargs.get("controller")
    if controller == "monit":
        env.include_recipe("monit")
        env.cookbooks.monit.rc(
            "mongodb-%s" % name,
            Template("mongodb/monit.conf.j2",
                     variables=dict(name=name, mongodb=config)))
        env.cookbooks.monit.MonitService(
            "mongodb-%s" % name,
            subscribes=[("restart", env.resources["File"][config.configpath])])
    elif controller == "supervisord":
        env.include_recipe("supervisor")
        env.cookbooks.supervisor.configuration(
            "mongodb-%s" % name,
            Template("mongodb/supervisord.conf.j2",
                     variables=dict(name=name, mongodb=config)))
        env.cookbooks.supervisor.SupervisorService(
            "mongodb-%s" % name,
            subscribes=[("restart", env.resources["File"][config.configpath])])
    else:
        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),
             ])
Exemple #2
0
import os
from kokki import Package, File, Service, Script

Package("erlang")
# ubuntu's erlang is a bit messed up.. remove the man link
File("/usr/lib/erlang/man",
    action = "delete")

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

command = os.path.join(env.config.busket.path, "bin", "busket")

Service("busket",
    start_command = "%s start" % command,
    stop_command = "%s stop" % command,
    restart_command = "{0} start || {0} restart".format(command),
    status_command = "%s ping" % command,
    action = "nothing")

Script("install-busket",
    not_if = lambda:os.path.exists(env.config.busket.path),
    cwd = "/usr/local/src",
    code = (
        "git clone git://github.com/samuel/busket.git busket\n"
        "cd busket\n"
        "mkdir /tmp/erlhome\n"
        "export HOME=/tmp/erlhome\n"
        "make release\n"
        "mv rel/busket {install_path}\n"
    ).format(install_path=env.config.busket.path),
    notifies = [("start", env.resources["Service"]["busket"])],
Exemple #3
0
    command = "apt-get update",
    action = "nothing")

Execute("curl http://www.serverdensity.com/downloads/boxedice-public.key | apt-key add -",
    not_if = "(apt-key list | grep 'Server Density' > /dev/null)")

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

Package("sd-agent")

Directory(env.config.serverdensity.plugin_directory,
    owner = "sd-agent",
    group = "sd-agent",
    mode = 0770,
    recursive = True)

Service("sd-agent",
    supports_restart = True)

File("/etc/sd-agent/config.cfg",
    owner = "sd-agent",
    group = "sd-agent",
    mode = 0660,
    content = Template("serverdensity/config.cfg.j2"),
    notifies = [("restart", env.resources["Service"]["sd-agent"])])
Exemple #4
0
import os
from kokki import Directory, Package, File, Template, Service

env.include_recipe("postgresql9")

Service("postgresql",
        supports_restart=True,
        supports_reload=True,
        supports_status=True,
        action="nothing")

Package("postgresql-9.1",
        notifies=[("stop", env.resources["Service"]["postgresql"], True)])
Package("postgresql-server-dev-9.1")
Package("postgresql-contrib-9.1")
Package("postgis")
Package("gdal-bin")
Package("binutils")
Package("libgeos-3.2.2")
Package("libgeos-c1")
Package("libgeos-dev")
Package("libgdal1-1.8.0")
Package("libgdal1-dev")
Package("libxml2")
Package("libxml2-dev")
Package("checkinstall")
Package("proj")

File("pg_hba.conf",
     owner="postgres",
     group="postgres",
Exemple #5
0
import os
from kokki import Execute, File, Package, Service, Template


Service("sendmail",
    supports_restart=True,
    supports_reload=True,
    supports_status=True,
    action="nothing")

Package("sasl2-bin")
Package("sendmail")

Execute("sendmailconfig", command="sendmailconfig --no-reload", action="nothing")
Execute("newaliases", command="newaliases", action="nothing")

File("/etc/mail/sendmail.mc",
    owner="root",
    group="smmsp",
    mode=0644,
    content=Template("sendmail/sendmail.mc.j2"),
    notifies=[("run", env.resources["Execute"]["sendmailconfig"], True),
              ("restart", env.resources["Service"]["sendmail"])])

File("/etc/mail/submit.mc",
    owner="root",
    group="smmsp",
    mode=0644,
    content=Template("sendmail/submit.mc.j2"),
    notifies=[("run", env.resources["Execute"]["sendmailconfig"], True),
              ("restart", env.resources["Service"]["sendmail"])])
Exemple #6
0
from kokki import Package, Service, File, Template

Package("exim4", action="upgrade")
Service("exim4", supports_restart=True)

File("/etc/exim4/update-exim4.conf.conf",
     owner="root",
     group="root",
     mode=0644,
     content=Template("exim4/update-exim4.conf.conf.j2"),
     notifies=[("restart", env.resources["Service"]["exim4"])])

File("/etc/exim4/exim4.conf.localmacros",
     owner="root",
     group="root",
     mode=0644,
     content="AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS = 1\nMAIN_TLS_ENABLE = 1\n",
     notifies=[("restart", env.resources["Service"]["exim4"])])

File("/etc/exim4/passwd.client",
     mode=0640,
     content=Template("exim4/passwd.client.j2"),
     notifies=[("restart", env.resources["Service"]["exim4"])])
Exemple #7
0
from kokki import Package, File, Template, Directory, Service


Package("monit")


Service("monit",
    supports_status=False,
    supports_restart=True,
    action="nothing")


File("%s/monitrc" % env.config.monit.config_path,
    owner="root",
    group="root",
    mode=0700,
    content=Template("monit/monitrc.j2"),
    notifies=[("restart", env.resources["Service"]["monit"])])


if env.system.platform == "ubuntu":
    File("/etc/default/monit",
        content=Template("monit/default.j2"),
        notifies=[("restart", env.resources["Service"]["monit"])])


Directory("%s/monit.d" % env.config.monit.config_path,
    owner="root",
    group="root",
    mode=0700)
Exemple #8
0
from kokki import Package, File, Template, Directory, Service

Package("monit")

File("%s/monitrc" % env.config.monit.config_path,
    owner = "root",
    group = "root",
    mode = 0700,
    content = Template("monit/monitrc.j2"))

if env.system.platform == "ubuntu":
    File("/etc/default/monit",
        content = Template("monit/default.j2"))

Directory("%s/monit.d" % env.config.monit.config_path,
    owner = "root",
    group = "root",
    mode = 0700)

Directory("/var/monit",
    owner = "root",
    group = "root",
    mode = 0700)

Service("monit",
    supports_restart = True,
    supports_status = False,
    subscribes = [('restart', env.resources['File']["%s/monitrc" % env.config.monit.config_path])])
Exemple #9
0
from kokki import Service, Package, File, Template

if env.system.os == "linux":
    Package("openssh-server", action="upgrade")
    Package("openssh-client", action="upgrade")

    Service("ssh")

    File("sshd_config",
         path="/etc/ssh/sshd_config",
         content=Template("ssh/sshd_config.j2"),
         mode=0644,
         owner="root",
         group="root",
         notifies=[("restart", env.resources["Service"]["ssh"], True)])
Exemple #10
0
    File("/var/cache/local/preseeding/mysql-server.seed",
         owner="root",
         group="root",
         mode=0600,
         content=Template("mysql/mysql-server.seed.j2"),
         notifies=[("run", env.resources["Execute"]["preseed mysql-server"],
                    True)])

    File("/etc/mysql/debian.cnf",
         owner="root",
         group="root",
         mode=0600,
         content=Template("mysql/debian.cnf.j2"))

Package("mysql-server")
Service("mysql", supports_status=True, supports_restart=True)

Execute("mysql_install_db --user=mysql --datadir=%s" %
        env.config.mysql.datadir,
        creates=env.config.mysql.datadir)

File("/etc/mysql/conf.d/kokki.cnf",
     owner="root",
     group="root",
     mode=0644,
     content=Template("mysql/kokki.cnf.j2"),
     notifies=[("restart", env.resources["Service"]["mysql"], True)])

File("/etc/mysql/grants.sql",
     owner="root",
     group="root",
Exemple #11
0
from kokki import Package, Service, Execute, File, Template

env.include_recipe("librato")

Package("librato-silverline")

Service("silverline", action="start")

Execute("reload-silverline",
    command = "killall lmd",
    action = "nothing")

File("/etc/load_manager/lmd.conf",
    owner = "root",
    group = "root",
    mode = 0600,
    content = Template("librato/lmd.conf.j2"),
    notifies = [("run", env.resources["Execute"]["reload-silverline"])])

File("/etc/load_manager/lmc.conf",
    owner = "root",
    group = "root",
    mode = 0600,
    content = Template("librato/lmc.conf.j2"))
Exemple #12
0
env.include_recipe("java.jre")

Package("screen")

Directory(env.config.minecraft.path, owner=env.config.minecraft.user)

Script(
    "install-minecraft-server",
    not_if=lambda: os.path.exists(
        os.path.join(env.config.minecraft.path, "minecraft_server.jar")),
    code=("cd {config.minecraft.path}\n"
          "wget {config.minecraft.package_url}\n").format(config=env.config))

File(
    "%s/server.sh",
    mode=0755,
    content=("#!/bin/sh\n"
             "cd {0}\n"
             "java -Xmx1024M -Xms1024M -jar {0}/minecraft_server.jar nogui\n"
             ).format(env.config.minecraft.path),
)

Service(
    "minecraft-server",
    start_command="screen -dmS minecraft -- %s/server.sh" %
    env.config.minecraft.path,
    stop_command='screen -S minecraft -X stuff "stop\n"',
    status_command="nc -z localhost 25565",
    action="start",
)
Exemple #13
0
import os
from kokki import Package, File, Directory, Service, Template

# env.include_recipe("monit")

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

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

Directory("supervisor.d", path=env.config.supervisor.custom_config_path)

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

#env.cookbooks.monit.rc("supervisord",
#    content = Template("supervisor/monit.conf.j2"))

#env.cookbooks.monit.MonitService("supervisord",
#    subscribes = [("restart", env.resources["File"]["supervisord.conf"])])
Exemple #14
0
File("/etc/init.d/redis",
     owner="root",
     group="root",
     mode=0755,
     content=Template("redis/init.conf.j2",
                      variables=dict(redis=dict(
                          logpath=os.path.dirname(env.config.redis.logfile),
                          dbdir=env.config.redis.dbdir,
                          configfile=env.config.redis.configfile,
                          pidfile=env.config.redis.pidfile,
                          options=[],
                      ))))
# notifies = [
#     ("reload", env.resources["Service"]["redis"], True),
# ])

Service("redis",
        subscribes=[
            ("restart", env.resources["Script"]["install-redis"]),
        ])

if "munin.node" in env.included_recipes:
    Package(
        "redis",
        provider="kokki.providers.package.easy_install.EasyInstallProvider")
    for n in ('active_connections', 'commands', 'connects', 'used_memory'):
        Link("/etc/munin/plugins/redis_%s" % n,
             to="/etc/munin/python-munin/plugins/redis_%s" % n,
             notifies=[("restart", env.resources['Service']['munin-node'])])
Exemple #15
0
from kokki import Package, Service

env.include_recipe("flume")

Package("flume-master")

import os


def flume_master_status():
    pid_path = "/var/run/flume/flume-flume-master.pid"
    try:
        with open(pid_path, "rb") as fp:
            pid = int(fp.read().strip())
        os.getpgid(pid)  # Throws OSError if processes doesn't exist
    except (IOError, OSError, ValueError):
        return False
    return True


Service("flume-master",
        supports_restart=True,
        supports_reload=False,
        status_command=flume_master_status,
        subscribes=[
            ("restart", env.resources["File"]["flume-config"]),
            ("restart", env.resources["File"]["flume-site-config"]),
            ("restart", env.resources["File"]["flume-log-config"]),
            ("restart", env.resources["File"]["flume-daemon-sh"]),
        ])
Exemple #16
0
from kokki import Service, Package, File, Template

if env.system.os == "linux":
    Package("openssh-server", action="upgrade")
    Package("openssh-client", action="upgrade")

    if not env.config.sshd.service_name:
        if env.system.platform in ("redhat", "fedora", "centos", "amazon"):
            env.config.sshd.service_name = "sshd"
        else:
            env.config.sshd.service_name = "ssh"

    Service("ssh", service_name=env.config.sshd.service_name)

    File("sshd_config",
         path="/etc/ssh/sshd_config",
         content=Template("ssh/sshd_config.j2"),
         mode=0644,
         owner="root",
         group="root",
         notifies=[("restart", env.resources["Service"]["ssh"], True)])
Exemple #17
0
from kokki import Package, Service, File, Template

Package("pdns-server")
Service("pdns")

File("/etc/powerdns/pdns.conf",
     owner="root",
     group="root",
     mode=0644,
     content=Template("powerdns/pdns.conf"),
     notifies=[("reload", env.resources["Service"]["pdns"])])

for be in env.config.powerdns.backends:
    Package("pdns-backend-%s" % be)
Exemple #18
0
from kokki import Package, Service, File, Template

env.include_recipe("apache2")

Package("nagios3")
Service("nagios3",
        supports_status=True,
        supports_restart=True,
        supports_reload=True)

# NRPE plugin

Package("nagios-nrpe-plugin")

##

File("/etc/nagios3/cgi.cfg",
     owner="root",
     group="root",
     mode=0644,
     content=Template("nagios3/cgi.cfg.j2"),
     notifies=[("restart", env.resources["Service"]["nagios3"])])

if env.system.ec2:
    File("/etc/nagios3/conf.d/host-gateway_nagios3.cfg",
         action="delete",
         notifies=[("restart", env.resources["Service"]["nagios3"])])

File("/etc/nagios3/conf.d/extinfo_nagios2.cfg",
     action="delete",
     notifies=[("restart", env.resources["Service"]["nagios3"])])
Exemple #19
0
    #     apt = "deb http://apt.librato.com/debian/ lenny non-free"

if not apt:
    raise Fail("Can't find a cloudkick package for your platform/version")

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

Execute(
    "curl http://packages.cloudkick.com/cloudkick.packages.key | apt-key add -",
    not_if="(apt-key list | grep 'Cloudkick' > /dev/null)")

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

File("/etc/cloudkick.conf",
     owner="root",
     group="root",
     mode=0644,
     content=Template("cloudkick/cloudkick.conf.j2"))

Package("cloudkick-agent", action="upgrade")

Service("cloudkick-agent",
        supports_restart=True,
        subscribes=[("restart", env.resources["File"]["/etc/cloudkick.conf"])])
Exemple #20
0
from kokki import Package, Service, File, Template, Link

Package("memcached", action="upgrade")
Package("libmemcache-dev", action="upgrade")
Service("memcached")

File("/etc/memcached.conf",
     content=Template("memcached/memcached.conf.j2"),
     owner="root",
     group="root",
     mode=0644,
     notifies=[("restart", env.resources["Service"]["memcached"], True)])

if "librato.silverline" in env.included_recipes:
    File("/etc/default/memcached",
         owner="root",
         group="root",
         mode=0644,
         content=("ENABLE_MEMCACHED=yes\n"
                  "export SL_NAME=memcached\n"),
         notifies=[("restart", env.resources["Service"]["memcached"])])

if "munin.node" in env.included_recipes:
    for n in ('bytes', 'connections', 'curr_items', 'items', 'queries'):
        Link("/etc/munin/plugins/memcached_%s" % n,
             to="/etc/munin/python-munin/plugins/memcached_%s" % n,
             notifies=[("restart", env.resources['Service']['munin-node'])])
Exemple #21
0
Package("apache2",
        package_name="httpd" if env.system.platform in ("centos", "redhat",
                                                        "fedora",
                                                        "suse") else "apache2")

Directory(env.config.apache.log_dir,
          mode=0700,
          owner=env.config.apache.user,
          group=env.config.apache.user)

if env.system.platform in ("centos", "redhat", "fedora", "suse"):
    Service("apache2",
            service_name="httpd",
            restart_command="/sbin/service httpd restart && sleep 1",
            reload_command="/sbin/service httpd reload && sleep 1",
            supports_restart=True,
            supports_reload=True,
            supports_status=True)

    File("/usr/local/bin/apache2_module_conf_generate.pl",
         mode=0755,
         owner="root",
         group="root",
         content=StaticFile("apache2/files/apache2_module_conf_generate.pl"))

    for d in ('sites-available', 'sites-enabled', 'mods-available',
              'mods-enabled'):
        Directory("%s/%s" % (env.config.apache.dir, d),
                  mode=0755,
                  owner="root",
Exemple #22
0
from kokki import Package, File, Template, Service

if env.system.platform == "amazon":
    Package("perl-NetAddr-IP")

Package("munin-node")

File("munin-node.conf",
    path = "/etc/munin/munin-node.conf",
    owner = "root",
    group = "root",
    mode = 0644,
    content = Template("munin/munin-node.conf.j2"))

Service("munin-node",
    subscribes = [("restart", env.resources["File"]["munin-node.conf"])])

File("/etc/munin/plugin-conf.d/python",
    owner = "root",
    group = "root",
    mode = 0644,
    content = (
        "[*]\n"
        "env.PYTHON_EGG_CACHE /tmp/munin-egg-cache\n"
    ),
    notifies = [("restart", env.resources["Service"]["munin-node"])])

if env.system.ec2:
    File("/etc/munin/plugins/if_err_eth0",
        action = "delete",
        notifies = [("restart", env.resources["Service"]["munin-node"])])
Exemple #23
0
Execute("apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10",
        not_if="(apt-key list | grep 10gen.com > /dev/null)")

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

###

Package("mongodb-stable")

if env.config.mongodb.nodefault:
    Service("mongodb")
    File(env.config.mongodb.configpath,
         action="delete",
         notifies=[("stop", env.resources["Service"]["mongodb"], True)])
    File("/etc/init/mongodb.conf", action="delete")
    File("/etc/init.d/mongodb", action="delete")
else:
    Directory(env.config.mongodb.dbpath,
              owner="mongodb",
              group="mongodb",
              mode=0755,
              recursive=True)

    Service("mongodb")

    File("/etc/init/mongodb.conf",
Exemple #24
0
         owner="root",
         group="root")

File("nginx.conf",
     path="%s/nginx.conf" % env.config.nginx.dir,
     content=Template("nginx/nginx.conf.j2"),
     owner="root",
     group="root",
     mode=0644)

File("%s/sites-available/default" % env.config.nginx.dir,
     content=Template("nginx/default-site.j2"),
     owner="root",
     group="root",
     mode=0644)

Service("nginx",
        supports_status=True,
        supports_restart=True,
        supports_reload=True,
        action="start",
        subscribes=[("reload", env.resources["File"]["nginx.conf"])])

if "librato.silverline" in env.included_recipes:
    File("/etc/default/nginx",
         owner="root",
         group="root",
         mode=0644,
         content=("export SL_NAME=nginx\n"),
         notifies=[("restart", env.resources["Service"]["nginx"])])
Exemple #25
0
dirname = "redis-%s" % version
filename = "%s.tar.gz" % dirname
url = "http://redis.googlecode.com/files/%s" % filename

Script("install-redis",
    not_if = lambda:os.path.exists("/usr/local/bin/redis-server"),
    cwd = "/usr/local/src",
    code = (
        "wget %(url)s\n"
        "tar -zxvf %(filename)s\n"
        "cd %(dirname)s\n"
        "make install\n") % dict(url=url, dirname=dirname, filename=filename))

Service("redis",
    supports_restart=True,
    supports_reload=True,
    supports_status=True,
    action="nothing")


Directory(env.config.redis.dbdir,
    owner = "root",
    group = "root",
    mode = 0700,
    recursive = True)

File("redis.conf",
    path = env.config.redis.configfile,
    owner = "root",
    group = "root",
    mode = 0644,
Exemple #26
0
from kokki import Execute, File, Package, Service, Template

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"])])