diff --git a/manifests/rgw.pp b/manifests/rgw.pp index e703e01..d8b22b1 100644 --- a/manifests/rgw.pp +++ b/manifests/rgw.pp @@ -1,205 +1,210 @@ # # Copyright (C) 2014 Catalyst IT Limited. # # 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: Ricardo Rocha # Author: Oleksiy Molchanov # # Configures a ceph radosgw. # # == Define: ceph::rgw # # The RGW id. An alphanumeric string uniquely identifying the RGW. # ( example: radosgw.gateway ) # # === Parameters: # # [*pkg_radosgw*] Package name for the ceph radosgw. # Optional. Default is osfamily dependent (check ceph::params). # # [*rgw_ensure*] Whether to start radosgw service. # Optional. Default is running. # # [*rgw_enable*] Whether to enable radosgw service on boot. # Optional. Default is true. # # [*rgw_data*] The path where the radosgw data should be stored. # Optional. Default is '/var/lib/ceph/radosgw/${cluster}-${name}. # # [*user*] User running the web frontend. # Optional. Default is 'www-data'. # # [*keyring_path*] Location of keyring. # Optional. Default is '/etc/ceph/${name}.keyring'. # # [*log_file*] Log file to write to. # Optional. Default is '/var/log/ceph/radosgw.log'. # # [*rgw_dns_name*] Hostname to use for the service. # Optional. Default is $fqdn. # # [*rgw_socket_path*] Path to socket file. # Optional. Default is '/tmp/radosgw.sock'. # # [*rgw_print_continue*] True to send 100 codes to the client. # Optional. Default is false. # # [*rgw_port*] Port the rados gateway listens. # Optional. Default is undef. # # [*frontend_type*] What type of frontend to use # Optional. Default is civetweb, Other options are apache-proxy-fcgi or apache-fastcgi. # # [*rgw_frontends*] Arguments to the rgw frontend # Optional. Default is 'civetweb port=7480'. # +# [*rgw_swift_url*] The URL for the Ceph Object Gateway Swift API. +# Optional. Default is http://$fqdn:7480. +# # Deprecated Parameters: # # [*syslog*] Whether or not to log to syslog. # Optional. Default is true. # 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 = 'civetweb', $rgw_frontends = 'civetweb port=7480', + $rgw_swift_url = "http://${::fqdn}:7480", $syslog = undef, ) { include ::stdlib if $syslog { warning( 'The syslog parameter is unused and deprecated. It will be removed in a future release.' ) } unless $name =~ /^radosgw\..+/ { fail("Define name must be started with 'radosgw.'") } ceph_config { "client.${name}/host": value => $::hostname; "client.${name}/keyring": value => $keyring_path; "client.${name}/log_file": value => $log_file; "client.${name}/user": value => $user; + "client.${name}/rgw_dns_name": value => $rgw_dns_name; + "client.${name}/rgw_swift_url": value => $rgw_swift_url; } if($frontend_type == 'civetweb') { ceph::rgw::civetweb { $name: rgw_frontends => $rgw_frontends, } } elsif ( ( $frontend_type == 'apache-fastcgi' ) or ( $frontend_type == 'apache-proxy-fcgi' ) ) { ceph_config { - "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: ensure => installed, tag => 'ceph', } # Data directory for radosgw file { '/var/lib/ceph/radosgw': # missing in redhat pkg ensure => directory, mode => '0755', selinux_ignore_defaults => true, } file { $rgw_data: ensure => directory, owner => 'root', group => 'root', mode => '0750', selinux_ignore_defaults => true, } # Log file for radosgw (ownership) file { $log_file: ensure => present, owner => $user, mode => '0640', selinux_ignore_defaults => true, } # NOTE(aschultz): this is the radowsgw service title, it may be different # than the actual service name $rgw_service = "radosgw-${name}" # service definition # if Ubuntu does not use systemd if $::service_provider == 'upstart' { if $rgw_enable { file { "${rgw_data}/done": ensure => present, before => Service[$rgw_service], } } Service { name => 'radosgw', start => "start radosgw id=${name}", stop => "stop radosgw id=${name}", status => "status radosgw id=${name}", provider => $::service_provider, } # Everything else that is supported by puppet-ceph should run systemd. } else { Service { name => "ceph-radosgw@${name}", enable => $rgw_enable, } } service { $rgw_service: ensure => $rgw_ensure, tag => ['ceph-radosgw'] } Ceph_config<||> ~> Service<| tag == 'ceph-radosgw' |> Package<| tag == 'ceph' |> -> File['/var/lib/ceph/radosgw'] Package<| tag == 'ceph' |> -> File[$log_file] File['/var/lib/ceph/radosgw'] -> File[$rgw_data] -> Service<| tag == 'ceph-radosgw' |> File[$log_file] -> Service<| tag == 'ceph-radosgw' |> Ceph::Pool<||> -> Service<| tag == 'ceph-radosgw' |> } diff --git a/spec/defines/ceph_rgw_civetweb_spec.rb b/spec/defines/ceph_rgw_civetweb_spec.rb index 27ca081..b4f413f 100644 --- a/spec/defines/ceph_rgw_civetweb_spec.rb +++ b/spec/defines/ceph_rgw_civetweb_spec.rb @@ -1,95 +1,101 @@ # # 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 # require 'spec_helper' describe 'ceph::rgw' do let :pre_condition do 'include ceph::params' end shared_examples 'ceph rgw civetweb' do describe "activated with civetweb params" do let :title do 'radosgw.civetweb' end let :params do { :frontend_type => 'civetweb', } end it { should contain_ceph_config('client.radosgw.civetweb/user').with_value("#{platform_params[:user]}") } it { should contain_ceph_config('client.radosgw.civetweb/host').with_value('myhost') } it { should contain_ceph_config('client.radosgw.civetweb/keyring').with_value('/etc/ceph/ceph.client.radosgw.civetweb.keyring') } it { should contain_ceph_config('client.radosgw.civetweb/log_file').with_value('/var/log/ceph/radosgw.log') } it { should contain_ceph_config('client.radosgw.civetweb/rgw_frontends').with_value('civetweb port=7480') } + it { should contain_ceph_config('client.radosgw.civetweb/rgw_dns_name').with_value('myhost.domain') } + it { should contain_ceph_config('client.radosgw.civetweb/rgw_swift_url').with_value('http://myhost.domain:7480') } end describe "activated with custom civetweb params" do let :title do 'radosgw.custom' end let :params do { :frontend_type => 'civetweb', :rgw_frontends => 'civetweb port=7481', :user => 'root', + :rgw_dns_name => 'mydns.hostname', + :rgw_swift_url => 'https://mydns.hostname:443' } end it { should contain_ceph_config('client.radosgw.custom/rgw_frontends').with_value('civetweb port=7481') } it { should contain_ceph_config('client.radosgw.custom/user').with_value('root') } it { should contain_ceph_config('client.radosgw.custom/host').with_value('myhost') } it { should contain_ceph_config('client.radosgw.custom/keyring').with_value('/etc/ceph/ceph.client.radosgw.custom.keyring') } it { should contain_ceph_config('client.radosgw.custom/log_file').with_value('/var/log/ceph/radosgw.log') } + it { should contain_ceph_config('client.radosgw.custom/rgw_dns_name').with_value('mydns.hostname') } + it { should contain_ceph_config('client.radosgw.custom/rgw_swift_url').with_value('https://mydns.hostname:443') } end end on_supported_os({ :supported_os => OSDefaults.get_supported_os }).each do |os,facts| context "on #{os}" do let (:facts) do facts.merge!(OSDefaults.get_facts({ :concat_basedir => '/var/lib/puppet/concat', :fqdn => 'myhost.domain', :hostname => 'myhost', })) end let :platform_params do case facts[:osfamily] when 'Debian' { :pkg_radosgw => 'radosgw', :user => 'www-data', } when 'RedHat' { :pkg_radosgw => 'ceph-radosgw', :user => 'apache', } end end it_behaves_like 'ceph rgw civetweb' end end end diff --git a/spec/defines/ceph_rgw_spec.rb b/spec/defines/ceph_rgw_spec.rb index 98daaba..06ac9b0 100644 --- a/spec/defines/ceph_rgw_spec.rb +++ b/spec/defines/ceph_rgw_spec.rb @@ -1,261 +1,267 @@ # # Copyright (C) 2014 Catalyst IT Limited. # # 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: Ricardo Rocha # require 'spec_helper' describe 'ceph::rgw' do let :pre_condition do 'include ceph::params' end shared_examples 'ceph::rgw on Ubuntu 14.04' do before do facts.merge!( :operatingsystem => 'Ubuntu', :operatingsystemrelease => '14.04', :service_provider => 'upstart' ) end context 'activated with default params' do let :title do 'radosgw.gateway' end it { should contain_package('radosgw').with('ensure' => 'installed') } it { should contain_ceph_config('client.radosgw.gateway/user').with_value('www-data') } it { should contain_ceph_config('client.radosgw.gateway/host').with_value('myhost') } it { should contain_ceph_config('client.radosgw.gateway/keyring').with_value('/etc/ceph/ceph.client.radosgw.gateway.keyring') } it { should contain_ceph_config('client.radosgw.gateway/log_file').with_value('/var/log/ceph/radosgw.log') } + it { should contain_ceph_config('client.radosgw.gateway/rgw_dns_name').with_value('myhost.domain') } + it { should contain_ceph_config('client.radosgw.gateway/rgw_swift_url').with_value('http://myhost.domain:7480') } it { should contain_file('/var/lib/ceph/radosgw').with( :ensure => 'directory', :mode => '0755', :selinux_ignore_defaults => true, )} it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway').with( :ensure => 'directory', :owner => 'root', :group => 'root', :mode => '0750', :selinux_ignore_defaults => true, )} it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/done') } it { should contain_service('radosgw-radosgw.gateway') } end context 'activated with custom params' do let :title do 'radosgw.custom' end let :params do { - :pkg_radosgw => 'pkgradosgw', - :rgw_ensure => 'stopped', - :rgw_enable => false, - :rgw_data => "/var/lib/ceph/radosgw/ceph-radosgw.custom", - :user => 'wwwuser', - :keyring_path => "/etc/ceph/ceph.radosgw.custom.keyring", - :log_file => '/var/log/ceph/mylogfile.log', + :pkg_radosgw => 'pkgradosgw', + :rgw_ensure => 'stopped', + :rgw_enable => false, + :rgw_data => "/var/lib/ceph/radosgw/ceph-radosgw.custom", + :user => 'wwwuser', + :keyring_path => "/etc/ceph/ceph.radosgw.custom.keyring", + :log_file => '/var/log/ceph/mylogfile.log', + :rgw_dns_name => 'mydns.hostname', + :rgw_swift_url => 'https://mydns.hostname:443' } end it { should contain_package('pkgradosgw').with('ensure' => 'installed') } it { should contain_ceph_config('client.radosgw.custom/host').with_value('myhost') } it { should contain_ceph_config('client.radosgw.custom/keyring').with_value('/etc/ceph/ceph.radosgw.custom.keyring') } it { should contain_ceph_config('client.radosgw.custom/log_file').with_value('/var/log/ceph/mylogfile.log') } it { should contain_ceph_config('client.radosgw.custom/user').with_value('wwwuser') } + it { should contain_ceph_config('client.radosgw.custom/rgw_dns_name').with_value('mydns.hostname') } + it { should contain_ceph_config('client.radosgw.custom/rgw_swift_url').with_value('https://mydns.hostname:443') } it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.custom').with( :ensure => 'directory', :owner => 'root', :group => 'root', :mode => '0750', :selinux_ignore_defaults => true, )} it { should_not contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/done') } it { should contain_service('radosgw-radosgw.custom').with('ensure' => 'stopped' ) } end end shared_examples 'ceph::rgw on Ubuntu 16.04' do before do facts.merge!( :operatingsystem => 'Ubuntu', :operatingsystemrelease => '16.04', :service_provider => 'systemd' ) end context 'activated with default params' do let :title do 'radosgw.gateway' end it { should contain_package('radosgw').with('ensure' => 'installed') } it { should contain_ceph_config('client.radosgw.gateway/user').with_value('www-data') } it { should contain_ceph_config('client.radosgw.gateway/host').with_value('myhost') } it { should contain_ceph_config('client.radosgw.gateway/keyring').with_value('/etc/ceph/ceph.client.radosgw.gateway.keyring') } it { should contain_ceph_config('client.radosgw.gateway/log_file').with_value('/var/log/ceph/radosgw.log') } it { should contain_file('/var/lib/ceph/radosgw').with( :ensure => 'directory', :mode => '0755', :selinux_ignore_defaults => true, )} it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway').with( :ensure => 'directory', :owner => 'root', :group => 'root', :mode => '0750', :selinux_ignore_defaults => true, )} it { should contain_service('radosgw-radosgw.gateway') } end context 'activated with custom params' do let :title do 'radosgw.custom' end let :params do { :pkg_radosgw => 'pkgradosgw', :rgw_ensure => 'stopped', :rgw_enable => false, :rgw_data => '/var/lib/ceph/radosgw/ceph-radosgw.custom', :user => 'wwwuser', :keyring_path => '/etc/ceph/ceph.radosgw.custom.keyring', :log_file => '/var/log/ceph/mylogfile.log', } end it { should contain_package('pkgradosgw').with('ensure' => 'installed') } it { should contain_ceph_config('client.radosgw.custom/host').with_value('myhost') } it { should contain_ceph_config('client.radosgw.custom/keyring').with_value('/etc/ceph/ceph.radosgw.custom.keyring') } it { should contain_ceph_config('client.radosgw.custom/log_file').with_value('/var/log/ceph/mylogfile.log') } it { should contain_ceph_config('client.radosgw.custom/user').with_value('wwwuser') } it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.custom').with( :ensure => 'directory', :owner => 'root', :group => 'root', :mode => '0750', :selinux_ignore_defaults => true, )} it { should_not contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/done') } it { should contain_service('radosgw-radosgw.custom').with('ensure' => 'stopped' ) } end end shared_examples 'ceph::rgw on RedHat' do before do facts.merge!( :operatingsystem => 'RedHat', :operatingsystemrelease => '7.2', :operatingsystemmajrelease => '7' ) end context 'activated with default params' do let :title do 'radosgw.gateway' end it { should contain_package('ceph-radosgw').with('ensure' => 'installed') } it { should contain_ceph_config('client.radosgw.gateway/user').with_value('apache') } it { should contain_ceph_config('client.radosgw.gateway/host').with_value('myhost') } it { should contain_ceph_config('client.radosgw.gateway/keyring').with_value('/etc/ceph/ceph.client.radosgw.gateway.keyring') } it { should contain_ceph_config('client.radosgw.gateway/log_file').with_value('/var/log/ceph/radosgw.log') } it { should contain_file('/var/lib/ceph/radosgw').with( :ensure => 'directory', :mode => '0755', :selinux_ignore_defaults => true, )} it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway').with( :ensure => 'directory', :owner => 'root', :group => 'root', :mode => '0750', :selinux_ignore_defaults => true, )} it { should contain_service('radosgw-radosgw.gateway') } end context 'activated with custom params' do let :title do 'radosgw.custom' end let :params do { :pkg_radosgw => 'pkgradosgw', :rgw_ensure => 'stopped', :rgw_enable => false, :rgw_data => "/var/lib/ceph/radosgw/ceph-radosgw.custom", :user => 'wwwuser', :keyring_path => "/etc/ceph/ceph.radosgw.custom.keyring", :log_file => '/var/log/ceph/mylogfile.log', } end it { should contain_package('pkgradosgw').with('ensure' => 'installed') } it { should contain_ceph_config('client.radosgw.custom/host').with_value('myhost') } it { should contain_ceph_config('client.radosgw.custom/keyring').with_value('/etc/ceph/ceph.radosgw.custom.keyring') } it { should contain_ceph_config('client.radosgw.custom/log_file').with_value('/var/log/ceph/mylogfile.log') } it { should contain_ceph_config('client.radosgw.custom/user').with_value('wwwuser') } it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.custom').with( :ensure => 'directory', :owner => 'root', :group => 'root', :mode => '0750', :selinux_ignore_defaults => true, )} it { should contain_service('radosgw-radosgw.custom').with('ensure' => 'stopped' ) } end end on_supported_os({ :supported_os => OSDefaults.get_supported_os }).each do |os,facts| context "on #{os}" do let (:facts) do facts.merge!(OSDefaults.get_facts( :concat_basedir => '/var/lib/puppet/concat', :fqdn => 'myhost.domain', :hostname => 'myhost' )) end if facts[:operatingsystem] == 'Ubuntu' it_behaves_like 'ceph::rgw on Ubuntu 14.04' it_behaves_like 'ceph::rgw on Ubuntu 16.04' end if facts[:osfamily] == 'RedHat' it_behaves_like 'ceph::rgw on RedHat' end end end end