Exemplo n.º 1
0
def setup_ebs_volume(name=None,
                     availability_zone=None,
                     volume_id=None,
                     device=None,
                     linux_device=None,
                     snapshot_id=None,
                     size=None,
                     fstype=None,
                     mount_point=None,
                     fsoptions=None):
    env = Environment.get_instance()

    if linux_device is None:
        linux_device = device

    env.cookbooks.aws.EBSVolume(
        name or volume_id,
        volume_id=volume_id,
        availability_zone=availability_zone
        or env.config.aws.availability_zone,
        device=device,
        linux_device=linux_device,
        snapshot_id=snapshot_id,
        size=size,
        action="attach" if volume_id else ["create", "attach"])

    if fstype:
        if fstype == "xfs":
            Package("xfsprogs")
        Execute(
            "mkfs.%(fstype)s -f %(device)s" %
            dict(fstype=fstype, device=linux_device),
            not_if=
            """if [ "`file -s %(device)s`" = "%(device)s: data" ]; then exit 1; fi"""
            % dict(device=linux_device))

    if mount_point:
        Mount(mount_point,
              device=linux_device,
              fstype=fstype,
              options=fsoptions if fsoptions is not None else ["noatime"],
              action=["mount", "enable"])
Exemplo n.º 2
0
from kokki import Package, Directory, File, Template

Package("munin")

Directory(env.config.munin.dbdir, owner="munin", group="munin", mode=0755)

File("/etc/munin/munin.conf",
     owner="root",
     group="root",
     mode=0644,
     content=Template("munin/munin.conf.j2"))
Exemplo n.º 3
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"])])
Exemplo n.º 4
0
Execute("apt-update-mongo", command="apt-get update", action="nothing")

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)
Exemplo n.º 5
0
from kokki import Package, Directory, Service, File, StaticFile, Execute, Template

PLATFORM_CONFIGS = dict(
    centos="httpd",
    redhat="httpd",
    fedora="httpd",
    suse="httpd",
    debian="apache2",
    ubuntu="apache2",
)

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",
Exemplo n.º 6
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)
Exemplo n.º 7
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"])])
Exemplo n.º 8
0
import os
from kokki import Package, File, Template, Service

env.include_recipe("postgresql9")

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

Package("postgresql-" + env.config.postgresql9.version,
        notifies=[("stop", env.resources["Service"]["postgresql"], True)])

File("pg_hba.conf",
     owner="postgres",
     group="postgres",
     mode=0600,
     path=os.path.join(env.config.postgresql9.config_dir, "pg_hba.conf"),
     content=Template("postgresql9/pg_hba.conf.j2"),
     notifies=[("reload", env.resources["Service"]["postgresql"])])

File("postgresql.conf",
     owner="postgres",
     group="postgres",
     mode=0666,
     path=os.path.join(env.config.postgresql9.config_dir, "postgresql.conf"),
     content=Template("postgresql9/postgresql.conf.j2"),
     notifies=[("restart", env.resources["Service"]["postgresql"])])
Exemplo n.º 9
0
from kokki import Package

env.include_recipe("zookeeper")

Package("hadoop-zookeeper-server")
Exemplo n.º 10
0
Execute("apt-update-serverdensity",
    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"),
Exemplo n.º 11
0
from kokki import Package

env.include_recipe("apache2")

Package("apache2-mpm-prefork")
Exemplo n.º 12
0
import os
from kokki import Package, Execute, File, Script

Package("debconf-utils")

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

if env.system.lsb['codename'] == 'karmic':

    def enter_the_multiverse():
        with open("/etc/apt/sources.list", "r") as fp:
            source = fp.read().split(' ')[1]
        return (
            "deb {source} karmic multiverse\n"
            "deb-src {source} karmic multiverse\n"
            "deb {source} karmic-updates multiverse\n"
            "deb-src {source} karmic-updates multiverse\n"
            "deb http://security.ubuntu.com/ubuntu karmic-security multiverse\n"
        ).format(source=source)

    File("/etc/apt/sources.list.d/multiverse.list",
         owner="root",
         group="root",
         mode=0644,
         not_if=lambda: os.path.exists(
             "/etc/apt/sources.list.d/multiverse.list"),
         content=enter_the_multiverse,
         notifies=[("run", env.resources["Execute"]["apt-update-java"], True)])

if env.system.lsb['codename'] == 'lucid':
    Execute(
Exemplo n.º 13
0
import os
from kokki import Directory, Package, File, Template, Service


Package("python-rackspace-cloudfiles")
Package("duplicity")

Directory("{0}/dbdumps/".format(env.config.cloudfiles.deploy_home),
    owner = "postgres",
    group = "deploy",
    mode = 0750)

# /etc/crontab and the files in /etc/cron.d must be owned by root# and must *not* be group- or other-writable
File("/etc/cron.d/dbdumps",
    owner = "root",
    group = "root",
    mode = 0644,
    content = Template("postgresql-cloudfiles-backup/cronfile.j2"),
)

File("{0}/duplicity_uploader.sh".format(env.config.cloudfiles.deploy_home),
    owner = "postgres",
    group = "postgres",
    mode = 0740,
    content = Template("postgresql-cloudfiles-backup/duplicity_uploader.sh.j2"),
)

File("{0}/duplicity_downloader.sh".format(env.config.cloudfiles.deploy_home),
    owner = "postgres",
    group = "postgres",
    mode = 0740,
Exemplo n.º 14
0
from kokki import Package, Directory, File, Template, Service

Package("nginx")

Directory(env.config.nginx.log_dir,
          mode=0755,
          owner=env.config.nginx.user,
          action='create')

for nxscript in ('nxensite', 'nxdissite'):
    File("/usr/sbin/%s" % nxscript,
         content=Template("nginx/%s.j2" % nxscript),
         mode=0755,
         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,
Exemplo n.º 15
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",
Exemplo n.º 16
0
from kokki import Package, Directory, Link, File, Template

env.include_recipe("cloudera")

Package("flume")

Directory("/etc/flume/conf.kokki", owner="root", group="root", mode=0755)

Link("/etc/flume/conf", to="/etc/flume/conf.kokki")

File("flume-config",
     path="/etc/flume/conf.kokki/flume-conf.xml",
     owner="root",
     group="root",
     mode=0644,
     content=Template("flume/flume-conf.xml.j2"))

File("flume-site-config",
     path="/etc/flume/conf.kokki/flume-site.xml",
     owner="root",
     group="root",
     mode=0644,
     content=Template("flume/flume-site.xml.j2"))

File("flume-log-config",
     path="/etc/flume/conf.kokki/log4j.properties",
     owner="root",
     group="root",
     mode=0644,
     content=Template("flume/log4j.properties.j2"))
Exemplo n.º 17
0
from kokki import Package

Package("libmysqlclient-dev")
Package("mysql-client")
Exemplo n.º 18
0
from kokki import Package, Execute

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")
Exemplo n.º 19
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"])])
Exemplo n.º 20
0
from kokki import Package, Execute, Mount

if env.config.mdadm.arrays:
    Package("mdadm")

Execute("mdadm-update-conf",
        action="nothing",
        command=("("
                 "echo DEVICE partitions > /etc/mdadm/mdadm.conf"
                 "; mdadm --detail --scan >> /etc/mdadm/mdadm.conf"
                 ")"))

for arr in env.config.mdadm.arrays:
    array = arr.copy()
    fstype = array.pop('fstype', None)
    fsoptions = array.pop('fsoptions', None)
    mount_point = array.pop('mount_point', None)

    env.cookbooks.mdadm.Array(**array)

    if fstype:
        if fstype == "xfs":
            Package("xfsprogs")
        Execute(
            "mkfs.%(fstype)s -f %(device)s" %
            dict(fstype=fstype, device=array['name']),
            not_if=
            """if [ "`file -s %(device)s`" = "%(device)s: data" ]; then exit 1; fi"""
            % dict(device=array['name']))

    if mount_point:
Exemplo n.º 21
0
from kokki import Package, Directory, Script, Fail

Package("postgresql-server-dev", package_name="postgresql-server-dev-8.4")
Package("python-dev")
Package("python-psycopg2")


def install_package(name, url, creates):
    import os
    filename = url.rsplit('/', 1)[-1]
    dirname = filename
    while dirname.rsplit('.', 1)[-1] in ('gz', 'tar', 'tgz', 'bz2'):
        dirname = dirname.rsplit('.', 1)[0]

    if not dirname:
        raise Fail(
            "Unable to figure out directory name of project for URL %s" % url)

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


install_package(
    "skytools",
Exemplo n.º 22
0
import os
from kokki import Package, Directory, Execute, File, Template

env.include_recipe("mongodb")
env.include_recipe("supervisor")

env.cookbooks.supervisor.SupervisorService("avatartare")

Package("python-pycurl")
Package("python-imaging")

# Clone project
Directory(os.path.dirname(env.config.avatartare.path), mode=0755)
Execute(
    "git clone git://github.com/samuel/avatartare.git %s" %
    env.config.avatartare.path,
    creates=env.config.avatartare.path,
)

# Bootstrap the environment
Execute(
    "avatartare-bootstrap",
    command="python bin/bootstrap.py env",
    cwd=env.config.avatartare.path,
    creates="%s/env" % env.config.avatartare.path,
)

# Config
File("avatartare-local_settings.py",
     path="%s/local_settings.py" % env.config.avatartare.path,
     content=Template("avatartare/local_settings.py.j2"),
Exemplo n.º 23
0
from kokki import Package, File, Template

Package("sudo", action="upgrade")
File(
    "/etc/sudoers",
    owner="root",
    group="root",
    mode=0440,
    content=Template("sudo/sudoers.j2"),
)
Exemplo n.º 24
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"]),
        ])
Exemplo n.º 25
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",
Exemplo n.º 26
0
from kokki import Package

# Package("python-boto")

# Package("pip",
#     provider = "kokki.providers.package.easy_install.EasyInstallProvider")
# Execute("mv /usr/lib/pymodules/python2.6/boto /tmp/boto.orig",
#     only_if = lambda:os.path.exists("/usr/lib/pymodules/python2.6/boto"))
# Execute("pip install git+http://github.com/boto/boto.git#egg=boto",
#     not_if = 'python -c "import boto"')

Package("boto",
        action="upgrade",
        provider="kokki.providers.package.easy_install.EasyInstallProvider")
Exemplo n.º 27
0
from kokki import Package

Package("nagios-nrpe-server")
Package("nagios-plugins")
# Package("nagios-plugins-basic")
Exemplo n.º 28
0
    dirname = filename
    while dirname.rsplit('.', 1)[-1] in ('gz', 'tar', 'tgz', 'bz2'):
        dirname = dirname.rsplit('.', 1)[0]

    if not dirname:
        raise Fail(
            "Unable to figure out directory name of project for URL %s" % url)

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


Package("uuid-dev")
Package("libevent-dev")
Package("g++")
install_package(
    "gearmand",
    creates="/usr/local/sbin/gearmand",
    url=
    "http://launchpad.net/gearmand/trunk/0.14/+download/gearmand-0.14.tar.gz")

Directory("/var/run/gearmand", owner="nobody", mode=0755)
env.cookbooks.monit.rc("gearmand", content=Template("gearmand/monit.conf.j2"))
Exemplo n.º 29
0
    content = Template("redis/redis.conf.j2"),
    notifies = [("reload", env.resources["Service"]["redis"], True)])

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

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),
    # ])

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'])])
Exemplo n.º 30
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)