Add support for civetweb

This configure radosgw to use the built-in civetweb server instead of
an external apache server.

ceph::rgw { 'radosgw.gateway':
  user              => $user, #userid to run radosgw as
  rgw_frontend_type => 'civetweb', #enable the civetweb server
  rgw_frontends     => 'civetweb port=10.10.2.20:80', #optional parameters to change the listening ipaddress:port
}

Change-Id: I828b6afa8bceb79973ee452edabcebcb4f097910
This commit is contained in:
Keith Schincke 2015-12-08 00:26:26 -05:00 committed by Oleksiy Molchanov
parent 59fc06026d
commit 2fb8707458
9 changed files with 537 additions and 35 deletions

View File

@ -94,6 +94,23 @@
# the repo by yourself.
# Optional. Defaults to true
#
# [*enable_rgw*] boolean to enable the installation and configuration of
# radosgw on the controller
# Optional. Default to false
#
# [*rgw_user*] the user ID radosgw should run as.
# Optional. Default to root
#
# [*rgw_print_continue*] should http 100 continue be used
# Optional. Default to false
#
# [*frontend_type*] What type of frontend to use
# Optional. Default is apache-fastcgi. Other options are apache-proxy-fcgi or civetweb
#
# [*rgw_frontends*] Arguments to the rgw frontend
# Optional. Default is 'fastcgi socket_port=9000 socket_host=127.0.0.1'. Example: "civetweb port=7480"
#
class ceph::profile::params (
$fsid = undef,
$release = undef,
@ -113,6 +130,11 @@ class ceph::profile::params (
$client_keys = {},
$osds = undef,
$manage_repo = true,
$enable_rgw = false,
$rgw_user = 'root',
$rgw_print_continue = false,
$frontend_type = 'apache-fastcgi',
$rgw_frontends = 'fastcgi socket_port=9000 socket_host=127.0.0.1',
) {
validate_hash($client_keys)

42
manifests/profile/rgw.pp Normal file
View File

@ -0,0 +1,42 @@
#
# Copyright (C) 2016 Keith Schincke
#
# 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.
#
# Author: Keith Schincke <keith.schincke@gmail.com.>
#
# == Class: ceph::profile::rgw
#
# Profile for Ceph rgw
#
class ceph::profile::rgw {
require ::ceph::profile::base
if $ceph::profile::params::enable_rgw
{
ceph::rgw { 'radosgw.gateway':
pkg_radosgw => $::ceph::params::pkg_radosgw,
rgw_data => "/var/lib/ceph/radosgw/ceph-${name}",
user => $ceph::profile::params::rgw_user,
keyring_path => "/etc/ceph/ceph.client.${name}.keyring",
log_file => '/var/log/ceph/radosgw.log',
rgw_dns_name => $::fqdn,
rgw_socket_path => $::ceph::params::rgw_socket_path,
rgw_print_continue => $::ceph::params::rgw_print_continue,
rgw_port => undef,
syslog => true,
frontend_type => $ceph::profile::params::frontend_type,
rgw_frontends => $ceph::profile::params::rgw_frontends,
}
}
}

View File

@ -67,47 +67,62 @@
# [*syslog*] Whether or not to log to syslog.
# Optional. Default is true.
#
# [*frontend_type*] What type of frontend to use
# Optional. Default is apache-fastcgi. Other options are apache-proxy-fcgi or civetweb
#
# [*rgw_frontends*] Arguments to the rgw frontend
# Optional. Default is 'fastcgi socket_port=9000 socket_host=127.0.0.1'. Example: "civetweb port=7480"
#
define ceph::rgw (
$pkg_radosgw = $::ceph::params::pkg_radosgw,
$rgw_ensure = 'running',
$rgw_enable = true,
$rgw_data = "/var/lib/ceph/radosgw/ceph-${name}",
$user = $::ceph::params::user_radosgw,
$keyring_path = "/etc/ceph/ceph.client.${name}.keyring",
$log_file = '/var/log/ceph/radosgw.log',
$rgw_dns_name = $::fqdn,
$rgw_socket_path = $::ceph::params::rgw_socket_path,
$rgw_print_continue = false,
$rgw_port = undef,
$frontend_type = 'apache-fastcgi',
$rgw_frontends = 'fastcgi socket_port=9000 socket_host=127.0.0.1',
$syslog = true,
$pkg_radosgw = $::ceph::params::pkg_radosgw,
$rgw_ensure = 'running',
$rgw_enable = true,
$rgw_data = "/var/lib/ceph/radosgw/ceph-${name}",
$user = $::ceph::params::user_radosgw,
$keyring_path = "/etc/ceph/ceph.client.${name}.keyring",
$log_file = '/var/log/ceph/radosgw.log',
$rgw_dns_name = $::fqdn,
$rgw_socket_path = $::ceph::params::rgw_socket_path,
$rgw_print_continue = false,
$rgw_port = undef,
$frontend_type = 'apache-fastcgi',
$rgw_frontends = 'fastcgi socket_port=9000 socket_host=127.0.0.1',
$syslog = true,
) {
if $frontend_type {
validate_re(downcase($frontend_type), '^(apache-fastcgi|apache-proxy-fcgi)$',
"${frontend_type} is not supported for frontend_type.
Allowed values are 'apache-fastcgi' and 'apache-proxy-fcgi'.")
}
ceph_config {
"client.${name}/host": value => $::hostname;
"client.${name}/keyring": value => $keyring_path;
"client.${name}/log_file": value => $log_file;
"client.${name}/rgw_dns_name": value => $rgw_dns_name;
"client.${name}/rgw_print_continue": value => $rgw_print_continue;
"client.${name}/rgw_socket_path": value => $rgw_socket_path;
"client.${name}/user": value => $user;
}
if $frontend_type == 'apache-fastcgi' {
ceph_config {
"client.${name}/rgw_port": value => $rgw_port;
if ($frontend_type == 'civetweb')
{
ceph::rgw::civetweb { 'radosgw.gateway':
rgw_frontends => $rgw_frontends,
}
} elsif $frontend_type == 'apache-proxy-fcgi' {
}
elsif ( ( $frontend_type == 'apache-fastcgi' ) or ( $frontend_type == 'apache-proxy-fcgi' ) )
{
ceph_config {
"client.${name}/rgw_frontends": value => $rgw_frontends;
"client.${name}/rgw_dns_name": value => $rgw_dns_name;
"client.${name}/rgw_print_continue": value => $rgw_print_continue;
"client.${name}/rgw_socket_path": value => $rgw_socket_path;
}
if $frontend_type == 'apache-fastcgi' {
ceph_config {
"client.${name}/rgw_port": value => $rgw_port;
}
} elsif $frontend_type == 'apache-proxy-fcgi' {
ceph_config {
"client.${name}/rgw_frontends": value => $rgw_frontends;
}
}
}
else
{
fail("Unsupported frontend_type: ${frontend_type}")
}
package { $pkg_radosgw:
@ -169,12 +184,20 @@ define ceph::rgw (
fail("operatingsystem = ${::operatingsystem} is not supported")
}
#for RHEL/CentOS7, systemctl needs to reload to pickup the ceph-radosgw init file
if (($::operatingsystem == 'RedHat' or $::operatingsystem == 'CentOS') and (versioncmp($::operatingsystemmajrelease, '7') >= 0))
{
exec { 'systemctl-reload-from-rgw': #needed for the new init file
command => '/usr/bin/systemctl daemon-reload',
}
}
service { "radosgw-${name}":
ensure => $rgw_ensure,
}
Ceph_config<||> -> Service["radosgw-${name}"]
Package<| tag == 'ceph' |> -> File['/var/lib/ceph/radosgw']
Package<| tag == 'ceph' |> -> File[$log_file]
File['/var/lib/ceph/radosgw']
-> File[$rgw_data]
-> Service["radosgw-${name}"]

32
manifests/rgw/civetweb.pp Normal file
View File

@ -0,0 +1,32 @@
#
# Copyright (C) 2016 Keith Schincke
#
# 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.
#
# Author: Keith Schincke <keith.schincke@gmail.com.>
#
# Configures a ceph radosgw using civetweb.
#
# == Define: ceph::rgw::civetweb
# [*rgw_frontends*] Arguments to the rgw frontend
# Optional. Default is undef. Example: "civetweb port=7480"
#
define ceph::rgw::civetweb (
$rgw_frontends = undef,
) {
ceph_config {
"client.${name}/rgw_frontends": value => $rgw_frontends;
}
}

View File

@ -0,0 +1,240 @@
#
# Copyright (C) 2016 Keith Schincke
#
# Author: Keith Schincke <kschinck@redhat.com>
# forked from:
# Author: David Gurtner <aldavud@crimson.ch>
#
# 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.
#
require 'spec_helper_acceptance'
describe 'ceph rgw/civetweb' do
release = 'hammer'
fsid = 'a4807c9a-e76f-4666-a297-6d6cbc922e3a'
mon_key ='AQCztJdSyNb0NBAASA2yPZPuwXeIQnDJ9O8gVw=='
admin_key = 'AQA0TVRTsP/aHxAAFBvntu1dSEJHxtJeFFrRsg=='
radosgw_key = 'AQA0TVRTsP/aHxAAFBvntu1dSEJHxtJeFFrRwg=='
# passing it directly as unqoted array is not supported everywhere
packages = "[ 'python-ceph', 'ceph-common', 'librados2', 'librbd1', 'libcephfs1' ]"
test_user = 'testuser'
test_password = '123456'
test_email = 'testuser@example.com'
describe 'ceph::rgw::civetweb' do
it 'should install one monitor/osd with a rgw/civetweb' do
pp = <<-EOS
$user = 'root'
case $::osfamily {
'Debian': {
include ::apt
apt::source { 'cloudarchive-juno':
location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
release => 'trusty-updates/juno',
repos => 'main',
include_src => false,
required_packages => 'ubuntu-cloud-keyring',
}
}
'RedHat': {
# ceph-radosgw expects open file limit of 32768
file { '/etc/security/limits.d/80-nofile.conf':
content => '* hard nofile 32768',
}
yumrepo { 'openstack-juno':
descr => 'OpenStack Juno Repository',
#baseurl => 'http://repos.fedorapeople.org/repos/openstack/openstack-juno/epel-7/',
baseurl => 'http://repos.fedorapeople.org/repos/openstack/openstack-kilo/el7/',
enabled => '1',
gpgcheck => '0',
#gpgkey => 'https://raw.githubusercontent.com/redhat-openstack/rdo-release/juno/RPM-GPG-KEY-RDO-Juno',
gpgkey => 'https://raw.githubusercontent.com/redhat-openstack/rdo-release/kilo/RPM-GPG-KEY-RDO-Kilo',
priority => '15', # prefer over EPEL, but below ceph
}
Yumrepo<||> -> Package['python-swiftclient']
}
default: {
fail ("Unsupported OS family ${::osfamily}")
}
}
# ceph setup
class { 'ceph::repo':
ensure => present,
release => '#{release}',
}
->
class { 'ceph':
fsid => '#{fsid}',
mon_host => $::ipaddress,
mon_initial_members => 'a',
osd_pool_default_size => '1',
osd_pool_default_min_size => '1',
}
ceph::mon { 'a':
public_addr => $::ipaddress,
key => '#{mon_key}',
}
ceph::key { 'client.admin':
secret => '#{admin_key}',
cap_mon => 'allow *',
cap_osd => 'allow *',
cap_mds => 'allow *',
inject => true,
inject_as_id => 'mon.',
inject_keyring => '/var/lib/ceph/mon/ceph-a/keyring',
}
->
ceph::key { 'client.radosgw.gateway':
user => $apache_user,
secret => '#{radosgw_key}',
cap_mon => 'allow rwx',
cap_osd => 'allow rwx',
inject => true,
}
->
exec { 'bootstrap-key':
command => '/usr/sbin/ceph-create-keys --id a',
}
->
ceph::osd { '/srv/data': }
# setup ceph radosgw
host { $::fqdn: # workaround for bad 'hostname -f' in vagrant box
ip => $ipaddress,
host_aliases => [$::hostname],
}
->
file { '/var/run/ceph': # workaround for bad sysvinit script (ignores socket)
ensure => directory,
owner => $user,
}
->
ceph::rgw { 'radosgw.gateway':
user => $user,
frontend_type => 'civetweb',
rgw_frontends => 'civetweb port=80',
}
Ceph::Osd['/srv/data'] -> Service['radosgw-radosgw.gateway']
package { 'python-swiftclient': # required for tests below
ensure => present,
}
ceph_config {
'global/mon_data_avail_warn': value => 10; # workaround for health warn in mon
'global/osd_journal_size': value => 100;
}
EOS
osfamily = fact 'osfamily'
servicequery = {
'Debian' => 'status radosgw id=radosgw.gateway',
'RedHat' => 'service ceph-radosgw status id=radosgw.gateway',
}
apply_manifest(pp, :catch_failures => true)
# Enable as soon as remaining changes are fixed
#apply_manifest(pp, :catch_changes => true)
shell servicequery[osfamily] do |r|
expect(r.exit_code).to be_zero
end
shell "/usr/bin/radosgw-admin user create --uid=#{test_user} --email=#{test_email} --secret=#{test_password} --display-name=\"Test User\"" do |r|
expect(r.exit_code).to be_zero
end
shell "/usr/bin/radosgw-admin subuser create --uid=#{test_user} --subuser=#{test_user}:swift --access=full" do |r|
expect(r.exit_code).to be_zero
end
shell "/usr/bin/radosgw-admin key create --subuser=#{test_user}:swift --key-type=swift --secret=#{test_password}" do |r|
expect(r.exit_code).to be_zero
end
#shell "swift -A http://127.0.0.1:7480/auth/1.0 -U #{test_user}:swift -K #{test_password} stat" do |r|
shell "swift -A http://127.0.0.1:80/auth/1.0 -U #{test_user}:swift -K #{test_password} stat" do |r|
expect(r.exit_code).to be_zero
expect(r.stdout).to match(/Content-Type: text\/plain; charset=utf-8/)
expect(r.stdout).not_to match(/401 Unauthorized/)
end
end
it 'should purge everything' do
purge = <<-EOS
$radosgw = $::osfamily ? {
'RedHat' => 'ceph-radosgw',
default => 'radosgw',
}
ceph::osd { '/srv/data':
ensure => absent,
}
->
ceph::mon { 'a': ensure => absent }
->
file { [
'/var/lib/ceph/bootstrap-osd/ceph.keyring',
'/var/lib/ceph/bootstrap-mds/ceph.keyring',
'/var/lib/ceph/nss/cert8.db',
'/var/lib/ceph/nss/key3.db',
'/var/lib/ceph/nss/secmod.db',
'/var/lib/ceph/radosgw/ceph-radosgw.gateway',
'/var/lib/ceph/radosgw',
'/var/lib/ceph/nss',
'/etc/ceph/ceph.client.admin.keyring',
'/etc/ceph/ceph.client.radosgw.gateway',
'/var/lib/ceph',
'/var/run/ceph',
'/srv/data',
]:
ensure => absent,
recurse => true,
purge => true,
force => true,
}
->
package { $radosgw: ensure => purged }
->
package { #{packages}:
ensure => purged
}
class { 'ceph::repo':
ensure => absent,
release => '#{release}',
fastcgi => false,
}
EOS
osfamily = fact 'osfamily'
# RGW on CentOS is currently broken, so lets disable tests for now.
#if osfamily != 'RedHat'
apply_manifest(purge, :catch_failures => true)
#end
end
end
end
# Local Variables:
# compile-command: "cd ../..
# BUNDLE_PATH=/tmp/vendor bundle install
# BEAKER_set=ubuntu-server-1404-x64 \
# BUNDLE_PATH=/tmp/vendor \
# bundle exec rspec spec/acceptance/ceph_usecases_spec.rb
# "
# End:

View File

@ -39,6 +39,19 @@ describe 'ceph rgw' do
it 'should install one monitor/osd with cephx keys for rgw-fcgi' do
pp = <<-EOS
if $::osfamily == 'Debian' {
#trusty ships with pbr 0.7
#openstackclient.shell raises an requiring pbr!=0.7,<1.0,>=0.6'
#the latest is 0.10
package { 'python-pbr':
ensure => 'latest',
}
}
$apache_user = $::osfamily ? {
'RedHat' => 'apache',
default => 'www-data',
}
class { 'ceph::repo':
release => '#{release}',
fastcgi => true,
@ -340,8 +353,14 @@ describe 'ceph rgw' do
'/var/lib/ceph/nss',
'/etc/ceph/ceph.client.admin.keyring',
'/etc/ceph/ceph.client.radosgw.gateway',
'/var/lib/ceph',
'/var/run/ceph',
'/srv/data',
]:
ensure => absent
ensure => absent,
recurse => true,
purge => true,
force => true,
}
->
package { $radosgw: ensure => purged }

View File

@ -112,6 +112,17 @@ describe 'ceph usecases' do
class { 'ceph::repo':
ensure => absent,
}
file { [
'/var/lib/ceph',
'/var/run/ceph',
'/srv/data',
]:
ensure => absent,
recurse => true,
purge => true,
force => true,
}
EOS
apply_manifest(pp, :catch_failures => true)

View File

@ -0,0 +1,112 @@
#
# Copyright (C) 2016 Keith Schincke
#
# 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.
#
# Author: Keith Schincke <keith.schincke@gmail.com>
#
require 'spec_helper'
describe 'ceph::rgw' do
let :pre_condition do
'include ceph::params'
end
shared_examples_for 'ceph rgw civetweb' do
describe "activated with civetweb params" do
let :title do
'radosgw.civetweb'
end
let :params do
{
:frontend_type => 'civetweb',
}
end
it { is_expected.to contain_ceph_config('client.radosgw.civetweb/user').with_value("#{default_params[:user]}") }
it { is_expected.to contain_ceph_config('client.radosgw.civetweb/host').with_value('myhost') }
it { is_expected.to contain_ceph_config('client.radosgw.civetweb/keyring').with_value('/etc/ceph/ceph.client.radosgw.civetweb.keyring') }
it { is_expected.to contain_ceph_config('client.radosgw.civetweb/log_file').with_value('/var/log/ceph/radosgw.log') }
it { is_expected.to_not contain_ceph_config('client.radosgw.civetweb/rgw_frontends') }
end
describe "activated with custom civetweb params" do
let :title do
'custom.civetweb'
end
let :params do
{
:frontend_type => 'civetweb',
:rgw_frontends => 'civetweb port=7481',
:user => 'root',
}
end
#it { is_expected.to contain_ceph_config('client.custom.civetweb/rgw_frontends').with_value('civetweb port=7481') }
#it { is_expected.to contain_ceph_config('client.custom.civetweb/rgw_frontends') }
it { is_expected.to contain_ceph_config('client.custom.civetweb/user').with_value('root') }
it { is_expected.to contain_ceph_config('client.custom.civetweb/host').with_value('myhost') }
it { is_expected.to contain_ceph_config('client.custom.civetweb/keyring').with_value('/etc/ceph/ceph.client.custom.civetweb.keyring') }
it { is_expected.to contain_ceph_config('client.custom.civetweb/log_file').with_value('/var/log/ceph/radosgw.log') }
end
end
describe 'Debian Family' do
let :facts do
{
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'myhost.domain',
:hostname => 'myhost',
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '14.04',
}
end
let :default_params do
{
:pkg_radosgw => 'radosgw',
:user => 'www-data',
}
end
it_configures 'ceph rgw civetweb'
end
describe 'RedHat Family' do
let :facts do
{
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'myhost.domain',
:hostname => 'myhost',
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.2',
:operatingsystemmajrelease => '7',
}
end
let :default_params do
{
:pkg_radosgw => 'ceph-radosgw',
:user => 'apache',
}
end
it_configures 'ceph rgw civetweb'
end
end

View File

@ -121,12 +121,13 @@ describe 'ceph::rgw' do
let :facts do
{
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'myhost.domain',
:hostname => 'myhost',
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.2',
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'myhost.domain',
:hostname => 'myhost',
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.2',
:operatingsystemmajrelease => '7',
}
end