Andrew Bogott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/212914
Change subject: Resurect the old ceph module
......................................................................
Resurect the old ceph module
For hackathon experimentation
This reverts commit ed4d75eb4611e2b851cd699b6ff6845ce1e35de6.
Conflicts:
manifests/ganglia.pp
modules/ganglia_new/manifests/configuration.pp
modules/install-server/files/reprepro/distributions
Change-Id: I62f39ee0dfc1279d89002d01922fd0bfc215f11c
---
A files/ganglia/plugins/ceph.py
A modules/ceph/files/ceph-add-disk
A modules/ceph/files/logrotate-radosgw
A modules/ceph/manifests/bootstrap_key.pp
A modules/ceph/manifests/init.pp
A modules/ceph/manifests/key.pp
A modules/ceph/manifests/mds.pp
A modules/ceph/manifests/mon.pp
A modules/ceph/manifests/nagios.pp
A modules/ceph/manifests/osd.pp
A modules/ceph/manifests/radosgw.pp
A modules/ceph/templates/ceph.conf.erb
A modules/ceph/templates/check_ceph_health.erb
A modules/ceph/templates/radosgw/vhost.erb
A modules/install-server/files/autoinstall/partman/ceph-ssd.cfg
M modules/install-server/files/reprepro/updates
16 files changed, 800 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/14/212914/1
diff --git a/files/ganglia/plugins/ceph.py b/files/ganglia/plugins/ceph.py
new file mode 100644
index 0000000..f0bbd56
--- /dev/null
+++ b/files/ganglia/plugins/ceph.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+ceph.py
+Gather ceph OSD data for ganglia.
+Written by Mark Bergsma <[email protected]>
+"""
+
+from subprocess import Popen, PIPE
+import json, os, sys
+
+stats_cache = {}
+prev_values = {}
+metric_types = {}
+ceph_path = "/usr/bin/ceph"
+
+instances = ['']
+
+def metric_init(params):
+ global ceph_path, instances, stats_cache, metrics, metric_types
+
+ ceph_path = params.get('ceph', ceph_path)
+
+ instances = params.get('instances', "").split(',')
+
+ stats_cache = {}
+ metrics = []
+ metric_types = {}
+ for instance in instances:
+ metric_types[instance] = json.load(Popen([ceph_path,
"--admin-daemon", "/var/run/ceph/ceph-osd.%s.asok" % instance, "perf",
"schema"], stdout=PIPE).stdout)
+
+ for section in metric_types[instance]:
+ if section not in ("osd", "filestore"): continue
+ for metric, properties in
metric_types[instance][section].iteritems():
+ name = instance + "." + section.encode('ascii')
+ "." + metric.encode('ascii')
+ counter = bool(properties['type'] & 0b1000)
+ valtype = (properties['type'] & 0b10 == 0b10)
and 'uint' or 'float'
+ metric_properties = {
+ 'name': name,
+ 'call_back': get_value,
+ 'time_max': 15,
+ 'value_type': valtype,
+ 'units': ( counter and 'N/s' or 'N' ),
+ 'slope': ( counter and "positive" or
"both" ),
+ 'format': ( valtype == "uint" and r'%u'
or r'%f' ),
+ 'description': "%s %s" %
(section.encode('ascii'), metric.encode('ascii')),
+ 'groups': "ceph osd " + instance
+ }
+ metrics.append(metric_properties)
+
+ return metrics
+
+def get_value(metric):
+ global stats_cache, prev_values, metric_types
+
+ instance, section, metric_name = metric.split('.', 2)
+
+ t = metric_types[instance][section][metric_name]['type']
+ try:
+ v = stats_cache[instance][section].pop(metric_name)
+ except KeyError:
+ get_stats()
+ v = stats_cache[instance][section].pop(metric_name)
+
+ if t & 0b100 > 0:
+ # Average
+ try:
+ p = prev_values[instance][section][metric_name]
+ r = (v['sum'] - p['sum']) / (v['avgcount'] -
p['avgcount'])
+ except KeyError:
+ r = 0
+ finally:
+ prev_values.setdefault(instance,
{}).setdefault(section, {})[metric_name] = v
+ else:
+ r = v
+
+ if t & 1 == 1:
+ return float(r)
+ else:
+ return int(r)
+
+
+def get_stats():
+ global stats_cache, instances
+
+ for instance in instances:
+ stats_cache[instance] = json.load(Popen([ceph_path,
"--admin-daemon", "/var/run/ceph/ceph-osd.%s.asok" % instance, "perf", "dump"],
stdout=PIPE).stdout)
+
+ return stats_cache
+
+def metric_cleanup():
+ pass
+
+if __name__ == '__main__':
+ params = { 'instances': sys.argv[1] }
+
+ metrics = metric_init(params)
+
+ print "# Ceph plugin for Ganglia Monitor, automatically generated
config file\n"
+ print "modules {\n\tmodule {\n\t\tname = \"ceph\"\n\t\tlanguage =
\"python\"\n\t\tpath = \"ceph.py\"\n"
+ print "\t\tparam instances {\n\t\t\tvalue = \"%s\"\n\t\t}" %
",".join(instances)
+ print "\t}\n}\n"
+
+ print "collection_group {\n\tcollect_every = 15\n\ttime_threshold =
15\n"
+ for metric_properties in metrics:
+ print "\tmetric {\n\t\tname = '%(name)s'\n\t\ttitle =
'%(description)s'\n\t}" % metric_properties
+ print "}"
\ No newline at end of file
diff --git a/modules/ceph/files/ceph-add-disk b/modules/ceph/files/ceph-add-disk
new file mode 100644
index 0000000..a9fd903
--- /dev/null
+++ b/modules/ceph/files/ceph-add-disk
@@ -0,0 +1,112 @@
+#!/bin/bash
+
+# Wrapper around ceph-disk-prepare & ceph-disk-activate Workarounds a few bugs
+# & limitations of theirs (see bugs inline)
+#
+# Works with certain Wikimedia-specific assumptions (hostnames, RAID
+# controllers, number of disks) and would probably make little sense for
+# everyone else.
+
+#set -e
+
+## remove:
+# MegaCli -DiscardPreservedCache -L8 -a0
+# MegaCli -CfgLDDel -L8 -aALL
+
+usage() {
+ echo "I: Usage: $0 <target-id>"
+ echo "I: target-id is the SCSI target ID, as can be seen with
e.g."
+ echo "I: # MegaCli -LDInfo -Lall -aALL | grep ^Virtual"
+ echo "I: WARNING: It is NOT the Virtual Disk number."
+}
+if [ $# -eq 0 ]; then usage; exit 1; fi
+
+options=':hl:'
+while getopts $options option
+do
+ case $option in
+ h) usage; exit 1;;
+ l) LD=$OPTARG;;
+ \?) echo "Unknown option: -$OPTARG" >&2; exit 1;;
+ :) echo "Missing option argument for -$OPTARG" >&2; exit 1;;
+ esac
+done
+
+if ! [ "$LD" -eq "$LD" ] 2>/dev/null; then
+ echo "E: $LD is not a valid target ID"
+ exit 1
+fi
+
+if ! MegaCli -LDInfo -Lall -aALL |grep -q "(Target Id: $LD)"; then
+ echo "E: Unknown target ID $LD on MegaCli"
+ echo "I: You might want to run:"
+ echo "I: MegaCli -PDList -aALL | less # identify the
unconfigured disk"
+ echo "I: MegaCli -CfgLdAdd -r0[32:\$pd] -a0"
+ exit 2
+fi
+
+if [ ! -e /dev/disk/by-path/pci-*-scsi-0:2:$LD:0 ]; then
+ echo "I: Rescanning the SCSI bus"
+ echo "- $LD -" > /sys/class/scsi_host/host0/scan
+ sleep 2
+fi
+
+# H710 disks always appear as channel 2
+disk=$(readlink -e /dev/disk/by-path/pci-*-scsi-0\:2\:$LD:0)
+if [ "x$disk" = "x" ]; then
+ echo "E: Couldn't identify the device node for target ID $LD"
+ exit 2
+fi
+
+# this is per our convention and assumes 12 disks per box
+boxid=$(hostname |sed 's/^ms-be//')
+osdid=$(((${boxid} % 1000 - 1) * 12 + $LD - 1))
+
+echo -n "I: Setting up OSD $osdid using disk $LD, device node $disk. Confirm
(y/n)? "
+read answer
+if [ "x${answer}" != "xy" ]; then
+ echo "Aborting"
+ exit 2
+fi
+
+# sanity checks
+if grep -q $disk /proc/mounts; then
+ echo "E: $disk or a partition of it seems to be mounted:"
+ mount | grep $disk
+ exit 2
+fi
+
+if grep -q "/var/lib/ceph/osd/ceph-${osdid}" /proc/mounts; then
+ echo "E: OSD ${osdid} seems to be mounted already:"
+ mount | grep ceph-${osdid}
+ exit 2
+fi
+
+if pgrep -f -- "/usr/bin/ceph-osd --cluster=ceph -i ${osdid}" > /dev/null; then
+ echo "E: Ceph OSD daemon for ${osdid} seems to be running"
+ exit 2
+fi
+
+echo "I: Partioning and formatting the disk"
+journal=$(ceph-conf --cluster=ceph --name=osd.${osdid} --lookup 'osd journal')
+
+# cleanup possibly old journal
+rm -f ${journal}
+
+ceph-disk suppress-activate ${disk}
+ceph-disk prepare ${disk} ${journal}
+udevadm settle
+ceph-disk unsuppress-activate ${disk}
+
+# explicitly set whoami
+# WARNING: this can be dangerous if not previously cleaned up properly
+# http://tracker.ceph.com/issues/4032
+mkdir -p /var/lib/ceph/tmp
+mountpoint=$(mktemp -d --tmpdir=/var/lib/ceph/tmp/)
+mount ${disk}1 ${mountpoint}/
+echo ${osdid} > ${mountpoint}/whoami
+umount ${mountpoint}
+rmdir ${mountpoint}
+
+echo "I: activating the new OSD"
+ceph-disk activate --mount ${disk}1
diff --git a/modules/ceph/files/logrotate-radosgw
b/modules/ceph/files/logrotate-radosgw
new file mode 100644
index 0000000..7fb3391
--- /dev/null
+++ b/modules/ceph/files/logrotate-radosgw
@@ -0,0 +1,24 @@
+/var/log/radosgw/*.log {
+ rotate 7
+ daily
+ compress
+ sharedscripts
+ postrotate
+ if which invoke-rc.d > /dev/null 2>&1 && [ -x `which invoke-rc.d` ];
then
+ invoke-rc.d radosgw reload >/dev/null
+ elif which service > /dev/null 2>&1 && [ -x `which service` ]; then
+ service radosgw reload >/dev/null
+ fi
+ # Possibly reload twice, but depending on ceph.conf the reload above
may be a no-op
+ if which initctl > /dev/null 2>&1 && [ -x `which initctl` ]; then
+ # upstart reload isn't very helpful here:
+ # https://bugs.launchpad.net/upstart/+bug/1012938
+ initctl list \
+ | sed -n 's/^\(radosgw\+\)[ \t]\+(\([^ \/]\+\)\/\([^ \/]\+\))[
\t]\+start\/.*$/\1 cluster=\2 id=\3/p' \
+ | while read l; do
+ initctl reload -- $l 2>/dev/null || :
+ done
+ fi
+ endscript
+ missingok
+}
diff --git a/modules/ceph/manifests/bootstrap_key.pp
b/modules/ceph/manifests/bootstrap_key.pp
new file mode 100644
index 0000000..22e64a8
--- /dev/null
+++ b/modules/ceph/manifests/bootstrap_key.pp
@@ -0,0 +1,22 @@
+define ceph::bootstrap_key($type, $cluster='ceph') {
+ $keyring = "/var/lib/ceph/bootstrap-${type}/${cluster}.keyring"
+
+ $caps = $type ? {
+ 'osd' => 'mon "allow command osd create ...; allow command osd crush
set ...; allow command auth add * osd allow\ * mon allow\ rwx; allow command
mon getmap"',
+ 'mds' => 'mon "allow command auth get-or-create * osd allow\ * mds
allow mon allow\ rwx; allow command mon getmap"',
+ }
+
+ file { "/var/lib/ceph/bootstrap-${type}":
+ ensure => directory,
+ mode => '0644',
+ owner => 'root',
+ group => 'root',
+ }
+
+ ceph::key { "bootstrap-${type}":
+ cluster => $cluster,
+ keyring => $keyring,
+ caps => $caps,
+ require => File["/var/lib/ceph/bootstrap-${type}"],
+ }
+}
diff --git a/modules/ceph/manifests/init.pp b/modules/ceph/manifests/init.pp
new file mode 100644
index 0000000..7d6d3892
--- /dev/null
+++ b/modules/ceph/manifests/init.pp
@@ -0,0 +1,25 @@
+class ceph(
+ $admin_key,
+ $config={},
+) {
+ package { [ 'ceph', 'ceph-dbg' ]:
+ ensure => present,
+ }
+
+ file { '/etc/ceph/ceph.conf':
+ ensure => present,
+ mode => '0444',
+ owner => 'root',
+ group => 'root',
+ content => template('ceph/ceph.conf.erb'),
+ require => Package['ceph'],
+ }
+
+ exec { 'ceph client.admin':
+ command => "/usr/bin/ceph-authtool /etc/ceph/ceph.client.admin.keyring
\
+ --create-keyring --name=client.admin \
+ --add-key=${admin_key}",
+ creates => '/etc/ceph/ceph.client.admin.keyring',
+ require => Package['ceph'],
+ }
+}
diff --git a/modules/ceph/manifests/key.pp b/modules/ceph/manifests/key.pp
new file mode 100644
index 0000000..a360546
--- /dev/null
+++ b/modules/ceph/manifests/key.pp
@@ -0,0 +1,72 @@
+# Definition: ceph::key
+#
+# This class adds or removes a Ceph auth key and stores it in the filesystem.
+#
+# Parameters:
+# $keyring
+# Filename of the keyring file where the key will be stored.
+# $caps,
+# Capabilities that the auth key will have.
+# $cluster
+# Defaults to ceph. Name of the Ceph cluster.
+# $owner
+# Defaults to root. Owner username of the keyring file.
+# $group
+# Defaults to root. Owner groupname of the keyring file.
+# $mode
+# Defaults to 0600. File mode in octal.
+# $ensure
+# Defaults to present.
+#
+# Actions:
+# Creates or deletes the key with "ceph auth"
+# Creates a keyring file with that key on the filesystem
+#
+# Requires:
+# Class[ceph]
+#
+# Sample Usage:
+# ceph::key { 'test':
+# ensure => present,
+# cluster => 'ceph',
+# keyring => '/srv/myapp/ceph.key',
+# caps => 'mon "allow r" osd "allow rwx"',
+# }
+
+define ceph::key(
+ $keyring,
+ $caps,
+ $cluster='ceph',
+ $owner='root',
+ $group='root',
+ $mode='0600',
+ $ensure='present',
+) {
+ # ping-pong trickery to securely do permissions, puppet has no umask on
exec
+ file { $keyring:
+ ensure => $ensure,
+ owner => $owner,
+ group => $group,
+ mode => $mode,
+ backup => false,
+ }
+
+ if $ensure == 'present' {
+ exec { "ceph key ${name}":
+ command => "/usr/bin/ceph --cluster=${cluster} \
+ auth get-or-create client.${name} \
+ ${caps} \
+ > ${keyring}",
+ unless => "/usr/bin/test -s ${keyring}",
+ require => File[$keyring],
+ }
+ } elsif $ensure == 'absent' {
+ exec { "ceph key ${name}":
+ command => "/usr/bin/ceph --cluster=${cluster} \
+ auth del client.${name}",
+ onlyif => "/usr/bin/ceph auth print-key client.${name}",
+ }
+ } else {
+ fail('ceph::key ensure parameter must be absent or present')
+ }
+}
diff --git a/modules/ceph/manifests/mds.pp b/modules/ceph/manifests/mds.pp
new file mode 100644
index 0000000..0b6fd27
--- /dev/null
+++ b/modules/ceph/manifests/mds.pp
@@ -0,0 +1,7 @@
+class ceph::mds {
+ Class['ceph'] -> Class['ceph::mds']
+
+ ceph::bootstrap_key { 'ceph-mds':
+ type => 'mds',
+ }
+}
diff --git a/modules/ceph/manifests/mon.pp b/modules/ceph/manifests/mon.pp
new file mode 100644
index 0000000..da0f46f
--- /dev/null
+++ b/modules/ceph/manifests/mon.pp
@@ -0,0 +1,47 @@
+class ceph::mon(
+ $monitor_secret,
+) {
+ Class['ceph'] -> Class['ceph::mon']
+
+ $cluster = 'ceph'
+ $mon_data = "/var/lib/ceph/mon/ceph-${::hostname}"
+ $keyring = "/var/lib/ceph/tmp/${cluster}-${::hostname}.mon.keyring"
+
+ file { $mon_data:
+ ensure => directory,
+ mode => '0600',
+ owner => 'root',
+ group => 'root',
+ }
+
+ exec { 'ceph-mon-keyring':
+ command => "/usr/bin/ceph-authtool \
+ '${keyring}' \
+ --create-keyring \
+ --name=mon. \
+ --add-key='${monitor_secret}' \
+ --cap mon 'allow *'",
+ creates => $keyring,
+ unless => "/usr/bin/test -e ${mon_data}/keyring",
+ before => Exec['ceph-mon-mkfs'],
+ }
+
+ exec { 'ceph-mon-mkfs':
+ command => "/usr/bin/ceph-mon --mkfs \
+ -i ${::hostname} \
+ --keyring ${keyring}",
+ creates => "${mon_data}/keyring",
+ notify => Exec['ceph-create-keys'],
+ }
+
+ exec { 'ceph-create-keys':
+ command => "/usr/bin/ceph --name=mon.
--keyring=${mon_data}/keyring \
+ auth add client.admin \
+ --in-file=/etc/ceph/ceph.client.admin.keyring \
+ mon 'allow *' osd 'allow *' mds allow",
+ onlyif => "/usr/bin/ceph \
+ --admin-daemon
/var/run/ceph/ceph-mon.${::hostname}.asok \
+ mon_status | egrep -v '\"state\": \"(leader|peon)\"'",
+ refreshonly => true,
+ }
+}
diff --git a/modules/ceph/manifests/nagios.pp b/modules/ceph/manifests/nagios.pp
new file mode 100644
index 0000000..e2b4d5e
--- /dev/null
+++ b/modules/ceph/manifests/nagios.pp
@@ -0,0 +1,83 @@
+# Class: ceph::nagios
+#
+# This class sets up an NRPE service check for Ceph healthiness.
+#
+# Parameters:
+#
+# Actions:
+# Creates a separate Ceph admin key with minimum permissions
+# Installs a Nagios plugin to /usr/lib/nagios/plugins
+# Sets up the NRPE configuration for the check
+# Exports a Nagios monitor service check
+#
+# Requires:
+# Class[ceph]
+# Package['nagios-nrpe-server']
+# Package['nagios-plugins-basic']
+# Define['nrpe::monitor_service']
+#
+# Sample Usage:
+# include ceph::nagios
+
+class ceph::nagios(
+ $ensure='present',
+ $cluster='ceph',
+ $entity='nagios',
+) {
+ Class['ceph'] -> Class['ceph::nagios']
+
+ $keyring = "/var/lib/ceph/nagios/${cluster}.keyring"
+
+ case $ensure {
+ present: {
+ $ensure_dir = 'directory'
+ File['/var/lib/ceph/nagios'] -> Ceph::Key[$entity]
+ }
+ absent: {
+ $ensure_dir = 'absent'
+ # broken due to autorequire bug,
+ # http://projects.puppetlabs.com/issues/14518
+ #Ceph::Key[$entity] -> File['/var/lib/ceph/nagios']
+ }
+ default: {
+ fail("${name} ensure parameter must be absent or present")
+ }
+ }
+
+ file { '/var/lib/ceph/nagios':
+ ensure => $ensure_dir,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ backup => false,
+ force => true,
+ }
+
+ ceph::key { $entity:
+ ensure => $ensure,
+ keyring => $keyring,
+ caps => 'mon "allow r"',
+ owner => 'root',
+ group => 'nagios',
+ mode => '0440',
+ require => Package['nagios-nrpe-server'], # for the nagios group
+ }
+
+ $nagios_plugin_path = '/usr/lib/nagios/plugins/check_ceph_health'
+
+ file { $nagios_plugin_path:
+ ensure => $ensure,
+ owner => 'root',
+ group => 'root',
+ mode => '0555',
+ content => template('ceph/check_ceph_health.erb'),
+ # nagios-plugins-basic for the dir /usr/lib/nagios/plugins, ewww.
+ require => Package['nagios-plugins-basic'],
+ }
+
+ nrpe::monitor_service { 'ceph_health':
+ ensure => $ensure,
+ description => 'Ceph',
+ nrpe_command => $nagios_plugin_path,
+ }
+}
diff --git a/modules/ceph/manifests/osd.pp b/modules/ceph/manifests/osd.pp
new file mode 100644
index 0000000..2050c5c
--- /dev/null
+++ b/modules/ceph/manifests/osd.pp
@@ -0,0 +1,23 @@
+class ceph::osd {
+ Class['ceph'] -> Class['ceph::osd']
+
+ package { ['parted', 'gdisk' ]:
+ ensure => present,
+ }
+
+ ceph::bootstrap_key { 'ceph-osd':
+ type => 'osd',
+ }
+
+ file { '/usr/local/sbin/ceph-add-disk':
+ ensure => present,
+ owner => root,
+ group => root,
+ mode => '0555',
+ source => 'puppet:///modules/ceph/ceph-add-disk',
+ }
+
+ file { '/var/lib/ceph/journal':
+ ensure => directory,
+ }
+}
diff --git a/modules/ceph/manifests/radosgw.pp
b/modules/ceph/manifests/radosgw.pp
new file mode 100644
index 0000000..d707c26
--- /dev/null
+++ b/modules/ceph/manifests/radosgw.pp
@@ -0,0 +1,107 @@
+class ceph::radosgw(
+ $servername='localhost',
+ $serveradmin='webmaster@localhost',
+) {
+ Class['ceph'] -> Class['ceph::radosgw']
+
+ package { [ 'radosgw', 'radosgw-dbg' ]:
+ ensure => present,
+ }
+
+ file { '/var/lib/ceph/radosgw/ceph-radosgw':
+ ensure => directory,
+ owner => 'root' ,
+ group => 'root',
+ require => Package['radosgw'],
+ }
+ file { '/var/lib/ceph/radosgw/ceph-radosgw/done':
+ ensure => present,
+ owner => 'root',
+ group => 'root',
+ require => File['/var/lib/ceph/radosgw/ceph-radosgw'],
+ }
+
+ service { 'radosgw id=radosgw':
+ ensure => 'running',
+ status => '/sbin/status radosgw id=radosgw',
+ start => '/sbin/start radosgw id=radosgw',
+ stop => '/sbin/stop radosgw id=radosgw',
+ restart => '/sbin/start radosgw id=radosgw',
+ hasrestart => true,
+ provider => 'upstart',
+ require => File['/var/lib/ceph/radosgw/ceph-radosgw/done'],
+ }
+
+ $id = 'client.radosgw'
+ $keyfname = "/etc/ceph/ceph.${id}.keyring"
+ exec { "ceph auth ${id}":
+ command => "/usr/bin/ceph \
+ auth get-or-create \
+ ${id} \
+ mon 'allow r' osd 'allow rwx' > ${keyfname}",
+ creates => $keyfname,
+ }
+
+ # for <= bobtail, http://tracker.newdream.net/issues/3813
+ file { '/etc/logrotate.d/radosgw':
+ ensure => present,
+ source => 'puppet:///modules/ceph/logrotate-radosgw',
+ owner => 'root',
+ group => 'root',
+ }
+
+ # install apache + fastcgi + rewrite. fcgid doesn't stream
+ # the standard apache module is crap really, so this isn't great
+ class { 'apache':
+ default_mods => false,
+ serveradmin => $serveradmin,
+ }
+ package { 'libapache2-mod-fastcgi':
+ ensure => present,
+ require => Package['apache2'],
+ notify => Service['apache2'],
+ }
+ file { '/etc/apache2/mods-enabled/rewrite.load':
+ ensure => link,
+ target => '../mods-available/rewrite.load',
+ require => Package['apache2'],
+ notify => Service['apache2'],
+ }
+
+ # VirtualHost config
+ file { '/etc/apache2/sites-enabled/radosgw':
+ ensure => present,
+ owner => 'root',
+ group => 'root',
+ content => template('ceph/radosgw/vhost.erb'),
+ require => Package['apache2'],
+ notify => Service['apache2'],
+ }
+ file { '/etc/apache2/sites-enabled/radosgw':
+ ensure => link,
+ target => '../sites-available/radosgw',
+ require => File['/etc/apache2/sites-enabled/radosgw'],
+ notify => Service['apache2'],
+ }
+ file { '/etc/apache2/sites-enabled/000default':
+ ensure => absent,
+ require => Package['apache2'],
+ notify => Service['apache2'],
+ }
+
+ # just a simple file to be able to do health checks on Apache
+ # /monitoring/backend also exists but is routed over to radosgw
+ file { '/var/www/monitoring':
+ ensure => directory,
+ owner => 'root',
+ group => 'root',
+ require => Package['apache2'],
+ }
+ file { '/var/www/monitoring/frontend':
+ ensure => present,
+ owner => 'root',
+ group => 'root',
+ content => "OK\n",
+ require => File['/var/www/monitoring'],
+ }
+}
diff --git a/modules/ceph/templates/ceph.conf.erb
b/modules/ceph/templates/ceph.conf.erb
new file mode 100644
index 0000000..9fe7e95
--- /dev/null
+++ b/modules/ceph/templates/ceph.conf.erb
@@ -0,0 +1,54 @@
+[global]
+ auth cluster required = cephx
+ auth service required = cephx
+ auth client required = cephx
+ cephx require signatures = true
+
+ keyring = /etc/ceph/$cluster.$name.keyring
+
+ fsid = <%= @config['fsid'] %>
+ mon host = <%= @config['mon_addresses'].join(' ') %>
+ mon initial members = <%= @config['mon_initial_members'].join(' ') %>
+<% if (! @config['global'].nil?) -%>
+
+ <%- @config['global'].sort.each do |k, v| -%>
+ <%= k %> = <%= v %>
+ <%- end -%>
+<% end -%>
+
+[mon]
+ keyring = /var/lib/ceph/mon/$cluster-$id/keyring
+<% if (! @config['mon'].nil?) -%>
+
+ <%- @config['mon'].sort.each do |k, v| -%>
+ <%= k %> = <%= v %>
+ <%- end -%>
+<% end -%>
+
+[osd]
+ keyring = /var/lib/ceph/osd/$cluster-$id/keyring
+<% if (! @config['osd'].nil?) -%>
+
+ <%- @config['osd'].sort.each do |k, v| -%>
+ <%= k %> = <%= v %>
+ <%- end -%>
+<% end -%>
+
+[mds]
+ keyring = /var/lib/ceph/mds/$cluster-$id/keyring
+<% if (! @config['mds'].nil?) -%>
+
+ <%- @config['mds'].sort.each do |key, value| -%>
+ <%= key %> = <%= value %>
+ <%- end -%>
+<% end -%>
+
+[client.radosgw]
+ log file = /var/log/radosgw/radosgw.log
+ rgw socket path = /run/radosgw.sock
+<% if (! @config['radosgw'].nil?) -%>
+
+ <%- @config['radosgw'].sort.each do |key, value| -%>
+ <%= key %> = <%= value %>
+ <%- end -%>
+<% end -%>
diff --git a/modules/ceph/templates/check_ceph_health.erb
b/modules/ceph/templates/check_ceph_health.erb
new file mode 100755
index 0000000..65386ef
--- /dev/null
+++ b/modules/ceph/templates/check_ceph_health.erb
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+CLUSTER="<%= @cluster %>"
+ENTITY="<%= @entity %>"
+KEYRING="<%= @keyring %>"
+
+HEALTH=$(ceph --cluster "$CLUSTER" --id "$ENTITY" --keyring "$KEYRING" health)
+
+echo "Ceph $HEALTH"
+if echo $HEALTH | grep -q OK; then
+ exit 0
+elif echo $HEALTH | grep -q WARN; then
+ # make it CRITICAL as we currently don't track WARNINGs at all...
+ exit 2
+elif echo $HEALTH | grep -q ERR; then
+ exit 2
+else
+ exit 3
+fi
diff --git a/modules/ceph/templates/radosgw/vhost.erb
b/modules/ceph/templates/radosgw/vhost.erb
new file mode 100644
index 0000000..8f4b0e5
--- /dev/null
+++ b/modules/ceph/templates/radosgw/vhost.erb
@@ -0,0 +1,40 @@
+StartServers 5
+ServerLimit 50
+MaxClients 800
+
+FastCgiExternalServer /var/www/dummyradosgw.fcgi -socket /run/radosgw.sock
+
+LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %O \"%{Referer}i\"
\"%{User-Agent}i\"" proxy_combined
+LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %O \"%{Referer}i\"
\"%{User-Agent}i\"" proxy_debug
+
+<VirtualHost *:80>
+ ServerName <%= @servername %>
+ ServerAdmin <%= @serveradmin %>
+ ServerSignature Off
+ DocumentRoot /var/www/
+
+ RewriteEngine On
+ RewriteCond %{REQUEST_URI} !^/server-status
+ RewriteCond %{REQUEST_URI} !^/monitoring/frontend$
+ RewriteRule ^/(.*) /dummyradosgw.fcgi?params=$1&%{QUERY_STRING}
[E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
+
+ <Directory /var/www/>
+ Options +ExecCGI
+ AllowOverride All
+ Order allow,deny
+ Allow from all
+ AuthBasicAuthoritative Off
+ </Directory>
+
+ <Location /server-status>
+ SetHandler server-status
+ Order deny,allow
+ Deny from all
+ Allow from 127.0.0.1
+ </Location>
+
+ AllowEncodedSlashes On
+
+ ErrorLog /var/log/apache2/error.log
+ CustomLog /var/log/apache2/access.log proxy_debug
+</VirtualHost>
diff --git a/modules/install-server/files/autoinstall/partman/ceph-ssd.cfg
b/modules/install-server/files/autoinstall/partman/ceph-ssd.cfg
new file mode 100644
index 0000000..4352612
--- /dev/null
+++ b/modules/install-server/files/autoinstall/partman/ceph-ssd.cfg
@@ -0,0 +1,48 @@
+# Automatic software RAID partitioning
+#
+# * one virtual disk, sda (RAID0 over two SSDs)
+# * layout:
+# - swap: 1GB
+# - / : ext4, 160GB
+# - rest unallocated (a big spare partition)
+
+d-i partman-auto/method string regular
+
+d-i partman-md/device_remove_md boolean true
+d-i partman-lvm/device_remove_lvm boolean true
+
+d-i partman-auto/disk string /dev/sda
+
+# method{ keep } on a partition that has no known filesystem
+# produces a "No file system is specified for partition" prompt; silence it
+d-i partman-basicmethods/method_only boolean false
+
+# Define physical partitions
+d-i partman-auto/expert_recipe string \
+ ceph :: \
+ 1000 1000 1000 linux-swap \
+ $primary{ } \
+ method{ swap } \
+ format{ } \
+ . \
+ 160000 50000 160000 ext4 \
+ $primary{ } $bootable{ } \
+ method{ format } \
+ format{ } \
+ use_filesystem{ } \
+ filesystem{ ext4 } \
+ mountpoint{ / } \
+ options/noatime{ noatime } \
+ options/discard{ discard } \
+ . \
+ 1000 1000 -1 linux-swap \
+ $primary{ } \
+ method{ keep } \
+ .
+
+d-i partman-auto/choose_recipe ceph
+
+d-i partman/confirm_write_new_label boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+d-i partman/confirm_nooverwrite boolean true
diff --git a/modules/install-server/files/reprepro/updates
b/modules/install-server/files/reprepro/updates
index acc61a1..021eb97 100644
--- a/modules/install-server/files/reprepro/updates
+++ b/modules/install-server/files/reprepro/updates
@@ -1,3 +1,13 @@
+# Ceph
+Name: ceph
+Method: http://ceph.com/debian/
+Components: main>main
+UDebComponents:
+Suite: precise
+Architectures: amd64 source
+VerifyRelease: 7EBFDD5D17ED316D
+ListShellHook: grep-dctrl -X -S ceph || [ $? -eq 1 ]
+
Name: jenkins
Method: http://pkg.jenkins-ci.org/debian-stable/
Suite: binary
--
To view, visit https://gerrit.wikimedia.org/r/212914
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I62f39ee0dfc1279d89002d01922fd0bfc215f11c
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits