Update recipes to be rubocop compliant
- Update rubocop config to include recipes/** - Update recipes to comply with rubocop Change-Id: Ic47cfe17dc3c4f6d0a28a2c412593a3e81731da2
This commit is contained in:
parent
8e2cd14fe4
commit
438f6af671
@ -3,10 +3,10 @@ AllCops:
|
||||
- metadata.rb
|
||||
- Gemfile
|
||||
- attributes/**
|
||||
- recipes/**
|
||||
Excludes:
|
||||
- libraries/**
|
||||
- providers/**
|
||||
- recipes/**
|
||||
- resources/**
|
||||
- spec/**
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: account-server
|
||||
@ -17,16 +18,16 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "openstack-object-storage::common"
|
||||
include_recipe "openstack-object-storage::storage-common"
|
||||
include_recipe "openstack-object-storage::disks"
|
||||
include_recipe 'openstack-object-storage::common'
|
||||
include_recipe 'openstack-object-storage::storage-common'
|
||||
include_recipe 'openstack-object-storage::disks'
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
platform_options = node['swift']['platform']
|
||||
|
||||
platform_options["account_packages"].each.each do |pkg|
|
||||
platform_options['account_packages'].each.each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"] # retain configs
|
||||
options platform_options['override_options'] # retain configs
|
||||
end
|
||||
end
|
||||
|
||||
@ -34,17 +35,18 @@ end
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=807170
|
||||
%w{auditor reaper replicator}.each do |svc|
|
||||
template "/etc/systemd/system/openstack-swift-account-#{svc}.service" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
source "simple-systemd-config.erb"
|
||||
variables({ :description => "OpenStack Object Storage (swift) - " +
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
source 'simple-systemd-config.erb'
|
||||
variables(
|
||||
description: 'OpenStack Object Storage (swift) - ' +
|
||||
"Account #{svc.capitalize}",
|
||||
:user => "swift",
|
||||
:exec => "/usr/bin/swift-account-#{svc} " +
|
||||
"/etc/swift/account-server.conf"
|
||||
})
|
||||
only_if { platform?(%w{fedora}) }
|
||||
user: 'swift',
|
||||
exec: "/usr/bin/swift-account-#{svc} " +
|
||||
'/etc/swift/account-server.conf'
|
||||
)
|
||||
only_if { platform?('fedora') }
|
||||
end
|
||||
end
|
||||
|
||||
@ -53,44 +55,43 @@ end
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=807170
|
||||
%w{auditor reaper replicator}.each do |svc|
|
||||
template "/etc/init.d/openstack-swift-account-#{svc}" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0755"
|
||||
source "simple-redhat-init-config.erb"
|
||||
variables({ :description => "OpenStack Object Storage (swift) - " +
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
source 'simple-redhat-init-config.erb'
|
||||
variables(
|
||||
description: 'OpenStack Object Storage (swift) - ' +
|
||||
"Account #{svc.capitalize}",
|
||||
:exec => "account-#{svc}"
|
||||
})
|
||||
exec: "account-#{svc}"
|
||||
)
|
||||
only_if { platform?(%w{redhat centos}) }
|
||||
end
|
||||
end
|
||||
|
||||
%w{swift-account swift-account-auditor swift-account-reaper swift-account-replicator}.each do |svc|
|
||||
service_name = platform_options["service_prefix"] + svc + platform_options["service_suffix"]
|
||||
service_name = platform_options['service_prefix'] + svc + platform_options['service_suffix']
|
||||
service svc do
|
||||
service_name service_name
|
||||
provider platform_options["service_provider"]
|
||||
supports :status => true, :restart => true
|
||||
provider platform_options['service_provider']
|
||||
supports status: true, restart: true
|
||||
action [:enable, :start]
|
||||
only_if "[ -e /etc/swift/account-server.conf ] && [ -e /etc/swift/account.ring.gz ]"
|
||||
only_if '[ -e /etc/swift/account-server.conf ] && [ -e /etc/swift/account.ring.gz ]'
|
||||
end
|
||||
end
|
||||
|
||||
# retrieve bind information from node
|
||||
bind_ip = node["swift"]["network"]["bind_ip"]
|
||||
bind_port = node["swift"]["network"]["bind_port"]
|
||||
|
||||
# create account server template
|
||||
template "/etc/swift/account-server.conf" do
|
||||
source "account-server.conf.erb"
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0600"
|
||||
variables("bind_ip" => node["swift"]["network"]["account-bind-ip"],
|
||||
"bind_port" => node["swift"]["network"]["account-bind-port"])
|
||||
template '/etc/swift/account-server.conf' do
|
||||
source 'account-server.conf.erb'
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0600'
|
||||
variables(
|
||||
'bind_ip' => node['swift']['network']['account-bind-ip'],
|
||||
'bind_port' => node['swift']['network']['account-bind-port']
|
||||
)
|
||||
|
||||
notifies :restart, "service[swift-account]", :immediately
|
||||
notifies :restart, "service[swift-account-auditor]", :immediately
|
||||
notifies :restart, "service[swift-account-reaper]", :immediately
|
||||
notifies :restart, "service[swift-account-replicator]", :immediately
|
||||
notifies :restart, 'service[swift-account]', :immediately
|
||||
notifies :restart, 'service[swift-account-auditor]', :immediately
|
||||
notifies :restart, 'service[swift-account-reaper]', :immediately
|
||||
notifies :restart, 'service[swift-account-replicator]', :immediately
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: swift-common
|
||||
@ -23,25 +24,24 @@ end
|
||||
|
||||
include_recipe 'sysctl::default'
|
||||
|
||||
|
||||
#-------------
|
||||
# stats
|
||||
#-------------
|
||||
|
||||
# optionally statsd daemon for stats collection
|
||||
if node["swift"]["statistics"]["enabled"]
|
||||
if node['swift']['statistics']['enabled']
|
||||
node.set['statsd']['relay_server'] = true
|
||||
include_recipe 'statsd::server'
|
||||
end
|
||||
|
||||
# find graphing server address
|
||||
if Chef::Config[:solo] and not node['recipes'].include?("chef-solo-search")
|
||||
Chef::Log.warn("This recipe uses search. Chef Solo does not support search.")
|
||||
if Chef::Config[:solo] && !node['recipes'].include?('chef-solo-search')
|
||||
Chef::Log.warn('This recipe uses search. Chef Solo does not support search.')
|
||||
graphite_servers = []
|
||||
else
|
||||
graphite_servers = search(:node, "roles:#{node['swift']['statistics']['graphing_role']} AND chef_environment:#{node.chef_environment}")
|
||||
end
|
||||
graphite_host = "127.0.0.1"
|
||||
graphite_host = '127.0.0.1'
|
||||
unless graphite_servers.empty?
|
||||
graphite_host = graphite_servers[0]['network']["ipaddress_#{node['swift']['statistics']['graphing_interface']}"]
|
||||
end
|
||||
@ -56,83 +56,81 @@ end
|
||||
# swift common
|
||||
#--------------
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
platform_options = node['swift']['platform']
|
||||
|
||||
# update repository if requested with the ubuntu cloud
|
||||
case node["platform"]
|
||||
when "ubuntu"
|
||||
case node['platform']
|
||||
when 'ubuntu'
|
||||
|
||||
Chef::Log.info("Creating apt repository for http://ubuntu-cloud.archive.canonical.com/ubuntu")
|
||||
Chef::Log.info('Creating apt repository for http://ubuntu-cloud.archive.canonical.com/ubuntu')
|
||||
Chef::Log.info("chefspec: #{node['lsb']['codename']}-updates/#{node['swift']['release']}")
|
||||
apt_repository "ubuntu_cloud" do
|
||||
uri "http://ubuntu-cloud.archive.canonical.com/ubuntu"
|
||||
apt_repository 'ubuntu_cloud' do
|
||||
uri 'http://ubuntu-cloud.archive.canonical.com/ubuntu'
|
||||
distribution "#{node['lsb']['codename']}-updates/#{node['swift']['release']}"
|
||||
components ["main"]
|
||||
key "5EDB1B62EC4926EA"
|
||||
components ['main']
|
||||
key '5EDB1B62EC4926EA'
|
||||
action :add
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
platform_options["swift_packages"].each do |pkg|
|
||||
platform_options['swift_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
end
|
||||
end
|
||||
|
||||
directory "/etc/swift" do
|
||||
directory '/etc/swift' do
|
||||
action :create
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0700"
|
||||
only_if "/usr/bin/id swift"
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0700'
|
||||
only_if '/usr/bin/id swift'
|
||||
end
|
||||
|
||||
# determine hash
|
||||
if node['swift']['swift_secret_databag_name'].nil?
|
||||
swifthash = node['swift']['swift_hash']
|
||||
else
|
||||
swift_secrets = Chef::EncryptedDataBagItem.load "secrets", node['swift']['swift_secret_databag_name']
|
||||
swift_secrets = Chef::EncryptedDataBagItem.load 'secrets', node['swift']['swift_secret_databag_name']
|
||||
swifthash = swift_secrets['swift_hash']
|
||||
end
|
||||
|
||||
|
||||
file "/etc/swift/swift.conf" do
|
||||
file '/etc/swift/swift.conf' do
|
||||
action :create
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0700"
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0700'
|
||||
content "[swift-hash]\nswift_hash_path_suffix=#{swifthash}\n"
|
||||
only_if "/usr/bin/id swift"
|
||||
only_if '/usr/bin/id swift'
|
||||
end
|
||||
|
||||
# need a swift user
|
||||
user "swift" do
|
||||
shell "/bin/bash"
|
||||
user 'swift' do
|
||||
shell '/bin/bash'
|
||||
action :modify
|
||||
only_if "/usr/bin/id swift"
|
||||
only_if '/usr/bin/id swift'
|
||||
end
|
||||
|
||||
package "git" do
|
||||
package 'git' do
|
||||
action :install
|
||||
end
|
||||
|
||||
# drop a ring puller script
|
||||
# TODO: make this smarter
|
||||
git_builder_ip = node["swift"]["git_builder_ip"]
|
||||
template "/etc/swift/pull-rings.sh" do
|
||||
source "pull-rings.sh.erb"
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0700"
|
||||
variables({
|
||||
:builder_ip => git_builder_ip,
|
||||
:service_prefix => platform_options["service_prefix"]
|
||||
})
|
||||
only_if "/usr/bin/id swift"
|
||||
git_builder_ip = node['swift']['git_builder_ip']
|
||||
template '/etc/swift/pull-rings.sh' do
|
||||
source 'pull-rings.sh.erb'
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0700'
|
||||
variables(
|
||||
builder_ip: git_builder_ip,
|
||||
service_prefix: platform_options['service_prefix']
|
||||
)
|
||||
only_if '/usr/bin/id swift'
|
||||
end
|
||||
|
||||
execute "/etc/swift/pull-rings.sh" do
|
||||
cwd "/etc/swift"
|
||||
only_if "[ -x /etc/swift/pull-rings.sh ]"
|
||||
execute '/etc/swift/pull-rings.sh' do
|
||||
cwd '/etc/swift'
|
||||
only_if '[ -x /etc/swift/pull-rings.sh ]'
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: swift-container-server
|
||||
@ -17,17 +18,16 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "openstack-object-storage::common"
|
||||
include_recipe "openstack-object-storage::storage-common"
|
||||
include_recipe "openstack-object-storage::disks"
|
||||
include_recipe 'openstack-object-storage::common'
|
||||
include_recipe 'openstack-object-storage::storage-common'
|
||||
include_recipe 'openstack-object-storage::disks'
|
||||
|
||||
platform_options = node['swift']['platform']
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
|
||||
platform_options["container_packages"].each do |pkg|
|
||||
platform_options['container_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"]
|
||||
options platform_options['override_options']
|
||||
end
|
||||
end
|
||||
|
||||
@ -35,17 +35,18 @@ end
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=807170
|
||||
%w{auditor updater replicator}.each do |svc|
|
||||
template "/etc/systemd/system/openstack-swift-container-#{svc}.service" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
source "simple-systemd-config.erb"
|
||||
variables({ :description => "OpenStack Object Storage (swift) - " +
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
source 'simple-systemd-config.erb'
|
||||
variables(
|
||||
description: 'OpenStack Object Storage (swift) - ' +
|
||||
"Container #{svc.capitalize}",
|
||||
:user => "swift",
|
||||
:exec => "/usr/bin/swift-container-#{svc} " +
|
||||
"/etc/swift/container-server.conf"
|
||||
})
|
||||
only_if { platform?(%w{fedora}) }
|
||||
user: 'swift',
|
||||
exec: "/usr/bin/swift-container-#{svc} " +
|
||||
'/etc/swift/container-server.conf'
|
||||
)
|
||||
only_if { platform?('fedora') }
|
||||
end
|
||||
end
|
||||
|
||||
@ -54,68 +55,71 @@ end
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=807170
|
||||
%w{auditor updater replicator}.each do |svc|
|
||||
template "/etc/init.d/openstack-swift-container-#{svc}" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0755"
|
||||
source "simple-redhat-init-config.erb"
|
||||
variables({ :description => "OpenStack Object Storage (swift) - " +
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
source 'simple-redhat-init-config.erb'
|
||||
variables(
|
||||
description: 'OpenStack Object Storage (swift) - ' +
|
||||
"Container #{svc.capitalize}",
|
||||
:exec => "container-#{svc}"
|
||||
})
|
||||
only_if { platform?(%w{redhat centos}) }
|
||||
exec: "container-#{svc}"
|
||||
)
|
||||
only_if { platform?('redhat', 'centos') }
|
||||
end
|
||||
end
|
||||
|
||||
%w{swift-container swift-container-auditor swift-container-replicator swift-container-updater}.each do |svc|
|
||||
service_name=platform_options["service_prefix"] + svc + platform_options["service_suffix"]
|
||||
service_name = platform_options['service_prefix'] + svc + platform_options['service_suffix']
|
||||
|
||||
service svc do
|
||||
service_name service_name
|
||||
provider platform_options["service_provider"]
|
||||
supports :status => true, :restart => true
|
||||
provider platform_options['service_provider']
|
||||
supports status: true, restart: true
|
||||
action [:enable, :start]
|
||||
only_if "[ -e /etc/swift/container-server.conf ] && [ -e /etc/swift/container.ring.gz ]"
|
||||
only_if '[ -e /etc/swift/container-server.conf ] && [ -e /etc/swift/container.ring.gz ]'
|
||||
end
|
||||
end
|
||||
|
||||
template "/etc/swift/container-server.conf" do
|
||||
source "container-server.conf.erb"
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0600"
|
||||
variables("bind_ip" => node["swift"]["network"]["container-bind-ip"],
|
||||
"bind_port" => node["swift"]["network"]["container-bind-port"])
|
||||
template '/etc/swift/container-server.conf' do
|
||||
source 'container-server.conf.erb'
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0600'
|
||||
variables(
|
||||
'bind_ip' => node['swift']['network']['container-bind-ip'],
|
||||
'bind_port' => node['swift']['network']['container-bind-port']
|
||||
)
|
||||
|
||||
notifies :restart, "service[swift-container]", :immediately
|
||||
notifies :restart, "service[swift-container-replicator]", :immediately
|
||||
notifies :restart, "service[swift-container-updater]", :immediately
|
||||
notifies :restart, "service[swift-container-auditor]", :immediately
|
||||
notifies :restart, 'service[swift-container]', :immediately
|
||||
notifies :restart, 'service[swift-container-replicator]', :immediately
|
||||
notifies :restart, 'service[swift-container-updater]', :immediately
|
||||
notifies :restart, 'service[swift-container-auditor]', :immediately
|
||||
end
|
||||
|
||||
# Ubuntu 12.04 packages are missing the swift-container-sync service scripts
|
||||
# See https://bugs.launchpad.net/cloud-archive/+bug/1250171
|
||||
if platform?("ubuntu")
|
||||
cookbook_file "/etc/init/swift-container-sync.conf" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0755"
|
||||
source "swift-container-sync.conf.upstart"
|
||||
if platform?('ubuntu')
|
||||
cookbook_file '/etc/init/swift-container-sync.conf' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
source 'swift-container-sync.conf.upstart'
|
||||
action :create
|
||||
not_if "[ -e /etc/init/swift-container-sync.conf ]"
|
||||
not_if '[ -e /etc/init/swift-container-sync.conf ]'
|
||||
end
|
||||
link "/etc/init.d/swift-container-sync" do
|
||||
to "/lib/init/upstart-job"
|
||||
not_if "[ -e /etc/init.d/swift-container-sync ]"
|
||||
link '/etc/init.d/swift-container-sync' do
|
||||
to '/lib/init/upstart-job'
|
||||
not_if '[ -e /etc/init.d/swift-container-sync ]'
|
||||
end
|
||||
end
|
||||
|
||||
service_name=platform_options["service_prefix"] + 'swift-container-sync' + platform_options["service_suffix"]
|
||||
unless node["swift"]["container-server"]["allowed_sync_hosts"] == []
|
||||
service "swift-container-sync" do
|
||||
service_name = platform_options['service_prefix'] + 'swift-container-sync' + platform_options['service_suffix']
|
||||
unless node['swift']['container-server']['allowed_sync_hosts'] == []
|
||||
service 'swift-container-sync' do
|
||||
service_name service_name
|
||||
provider platform_options["service_provider"]
|
||||
supports :status => false, :restart => true
|
||||
provider platform_options['service_provider']
|
||||
supports status: false, restart: true
|
||||
action [:enable, :start]
|
||||
only_if "[ -e /etc/swift/container-server.conf ] && [ -e /etc/swift/container.ring.gz ]"
|
||||
only_if '[ -e /etc/swift/container-server.conf ] && [ -e /etc/swift/container.ring.gz ]'
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: disks
|
||||
@ -24,10 +25,9 @@ class Chef::Recipe
|
||||
include DriveUtils
|
||||
end
|
||||
|
||||
platform_options = node['swift']['platform']
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
|
||||
package "xfsprogs" do
|
||||
package 'xfsprogs' do
|
||||
action :install
|
||||
only_if { platform?(%w{ubuntu debian fedora centos}) }
|
||||
end
|
||||
@ -38,14 +38,14 @@ end
|
||||
end
|
||||
end
|
||||
|
||||
disk_enum_expr = node["swift"]["disk_enum_expr"]
|
||||
disk_test_filter = node["swift"]["disk_test_filter"]
|
||||
disk_enum_expr = node['swift']['disk_enum_expr']
|
||||
disk_test_filter = node['swift']['disk_test_filter']
|
||||
|
||||
disks = locate_disks(disk_enum_expr, disk_test_filter)
|
||||
|
||||
disks.each do |disk|
|
||||
openstack_object_storage_disk "/dev/#{disk}" do
|
||||
part [{:type => platform_options["disk_format"] , :size => :remaining}]
|
||||
part [{ type: platform_options['disk_format'] , size: :remaining }]
|
||||
action :ensure_exists
|
||||
end
|
||||
end
|
||||
@ -55,13 +55,12 @@ end
|
||||
#
|
||||
# additionally, there is an implicit assumption that bind ports
|
||||
# for all object/container/account services are on the same net
|
||||
disk_ip = locate_ip_in_cidr(node["swift"]["network"]["object-cidr"], node)
|
||||
disk_ip = locate_ip_in_cidr(node['swift']['network']['object-cidr'], node)
|
||||
|
||||
openstack_object_storage_mounts "/srv/node" do
|
||||
openstack_object_storage_mounts '/srv/node' do
|
||||
action :ensure_exists
|
||||
publish_attributes "swift/state/devs"
|
||||
devices disks.collect { |x| "#{x}1" }
|
||||
publish_attributes 'swift/state/devs'
|
||||
devices disks.map { |x| "#{x}1" }
|
||||
ip disk_ip
|
||||
format platform_options["disk_format"]
|
||||
format platform_options['disk_format']
|
||||
end
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: management-server
|
||||
@ -17,71 +18,73 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "openstack-object-storage::common"
|
||||
include_recipe 'openstack-object-storage::common'
|
||||
|
||||
# FIXME: This should probably be a role (ring-builder?), so you don't end up
|
||||
# with multiple repos!
|
||||
include_recipe "openstack-object-storage::ring-repo"
|
||||
include_recipe 'openstack-object-storage::ring-repo'
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
platform_options = node['swift']['platform']
|
||||
|
||||
if node["swift"]["authmode"] == "swauth"
|
||||
case node["swift"]["swauth_source"]
|
||||
when "package"
|
||||
platform_options["swauth_packages"].each do |pkg|
|
||||
if node['swift']['authmode'] == 'swauth'
|
||||
case node['swift']['swauth_source']
|
||||
when 'package'
|
||||
platform_options['swauth_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"]
|
||||
options platform_options['override_options']
|
||||
end
|
||||
end
|
||||
when "git"
|
||||
when 'git'
|
||||
git "#{Chef::Config[:file_cache_path]}/swauth" do
|
||||
repository node["swift"]["swauth_repository"]
|
||||
revision node["swift"]["swauth_version"]
|
||||
repository node['swift']['swauth_repository']
|
||||
revision node['swift']['swauth_version']
|
||||
action :sync
|
||||
end
|
||||
|
||||
bash "install_swauth" do
|
||||
bash 'install_swauth' do
|
||||
cwd "#{Chef::Config[:file_cache_path]}/swauth"
|
||||
user "root"
|
||||
group "root"
|
||||
user 'root'
|
||||
group 'root'
|
||||
code <<-EOH
|
||||
python setup.py install
|
||||
EOH
|
||||
environment 'PREFIX' => "/usr/local"
|
||||
environment 'PREFIX' => '/usr/local'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# determine where to find dispersion login information
|
||||
if node['swift']['swift_secret_databag_name'].nil?
|
||||
auth_user = node["swift"]["dispersion"]["auth_user"]
|
||||
auth_key = node["swift"]["dispersion"]["auth_key"]
|
||||
auth_user = node['swift']['dispersion']['auth_user']
|
||||
auth_key = node['swift']['dispersion']['auth_key']
|
||||
else
|
||||
swift_secrets = Chef::EncryptedDataBagItem.load "secrets", node['swift']['swift_secret_databag_name']
|
||||
swift_secrets = Chef::EncryptedDataBagItem.load 'secrets', node['swift']['swift_secret_databag_name']
|
||||
auth_user = swift_secrets['dispersion_auth_user']
|
||||
auth_key = swift_secrets['dispersion_auth_key']
|
||||
end
|
||||
|
||||
if node['swift']['statistics']['enabled']
|
||||
template platform_options["swift_statsd_publish"] do
|
||||
source "swift-statsd-publish.py.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0755"
|
||||
template platform_options['swift_statsd_publish'] do
|
||||
source 'swift-statsd-publish.py.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
end
|
||||
cron "cron_swift_statsd_publish" do
|
||||
cron 'cron_swift_statsd_publish' do
|
||||
command "#{platform_options['swift_statsd_publish']} > /dev/null 2>&1"
|
||||
minute "*/#{node["swift"]["statistics"]["report_frequency"]}"
|
||||
end
|
||||
end
|
||||
|
||||
template "/etc/swift/dispersion.conf" do
|
||||
source "dispersion.conf.erb"
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0600"
|
||||
variables("auth_url" => node["swift"]["auth_url"],
|
||||
"auth_user" => auth_user,
|
||||
"auth_key" => auth_key)
|
||||
template '/etc/swift/dispersion.conf' do
|
||||
source 'dispersion.conf.erb'
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0600'
|
||||
variables(
|
||||
'auth_url' => node['swift']['auth_url'],
|
||||
'auth_user' => auth_user,
|
||||
'auth_key' => auth_key
|
||||
)
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: memcached
|
||||
@ -17,4 +18,4 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "memcached"
|
||||
include_recipe 'memcached'
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: swift-object-server
|
||||
@ -17,16 +18,16 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "openstack-object-storage::common"
|
||||
include_recipe "openstack-object-storage::storage-common"
|
||||
include_recipe "openstack-object-storage::disks"
|
||||
include_recipe 'openstack-object-storage::common'
|
||||
include_recipe 'openstack-object-storage::storage-common'
|
||||
include_recipe 'openstack-object-storage::disks'
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
platform_options = node['swift']['platform']
|
||||
|
||||
platform_options["object_packages"].each do |pkg|
|
||||
platform_options['object_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"] # retain configs
|
||||
options platform_options['override_options'] # retain configs
|
||||
end
|
||||
end
|
||||
|
||||
@ -34,17 +35,18 @@ end
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=807170
|
||||
%w{auditor updater replicator}.each do |svc|
|
||||
template "/etc/systemd/system/openstack-swift-object-#{svc}.service" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
source "simple-systemd-config.erb"
|
||||
variables({ :description => "OpenStack Object Storage (swift) - " +
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
source 'simple-systemd-config.erb'
|
||||
variables(
|
||||
description: 'OpenStack Object Storage (swift) - ' +
|
||||
"Object #{svc.capitalize}",
|
||||
:user => "swift",
|
||||
:exec => "/usr/bin/swift-object-#{svc} " +
|
||||
"/etc/swift/object-server.conf"
|
||||
})
|
||||
only_if { platform?(%w{fedora})}
|
||||
user: 'swift',
|
||||
exec: "/usr/bin/swift-object-#{svc} " +
|
||||
'/etc/swift/object-server.conf'
|
||||
)
|
||||
only_if { platform?('fedora') }
|
||||
end
|
||||
end
|
||||
|
||||
@ -53,49 +55,52 @@ end
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=807170
|
||||
%w{auditor updater replicator}.each do |svc|
|
||||
template "/etc/init.d/openstack-swift-object-#{svc}" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0755"
|
||||
source "simple-redhat-init-config.erb"
|
||||
variables({ :description => "OpenStack Object Storage (swift) - " +
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
source 'simple-redhat-init-config.erb'
|
||||
variables(
|
||||
description: 'OpenStack Object Storage (swift) - ' +
|
||||
"Object #{svc.capitalize}",
|
||||
:exec => "object-#{svc}"
|
||||
})
|
||||
only_if { platform?(%w{redhat centos}) }
|
||||
exec: "object-#{svc}"
|
||||
)
|
||||
only_if { platform?('redhat', 'centos') }
|
||||
end
|
||||
end
|
||||
|
||||
%w{swift-object swift-object-replicator swift-object-auditor swift-object-updater}.each do |svc|
|
||||
service_name=platform_options["service_prefix"] + svc + platform_options["service_suffix"]
|
||||
service_name = platform_options['service_prefix'] + svc + platform_options['service_suffix']
|
||||
|
||||
service svc do
|
||||
service_name service_name
|
||||
provider platform_options["service_provider"]
|
||||
provider platform_options['service_provider']
|
||||
# the default ubuntu provider uses invoke-rc.d, which apparently is
|
||||
# status-illy broken in ubuntu
|
||||
supports :status => false, :restart => true
|
||||
supports status: false, restart: true
|
||||
action [:enable, :start]
|
||||
only_if "[ -e /etc/swift/object-server.conf ] && [ -e /etc/swift/object.ring.gz ]"
|
||||
only_if '[ -e /etc/swift/object-server.conf ] && [ -e /etc/swift/object.ring.gz ]'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
template "/etc/swift/object-server.conf" do
|
||||
source "object-server.conf.erb"
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0600"
|
||||
variables("bind_ip" => node["swift"]["network"]["object-bind-ip"],
|
||||
"bind_port" => node["swift"]["network"]["object-bind-port"])
|
||||
template '/etc/swift/object-server.conf' do
|
||||
source 'object-server.conf.erb'
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0600'
|
||||
variables(
|
||||
'bind_ip' => node['swift']['network']['object-bind-ip'],
|
||||
'bind_port' => node['swift']['network']['object-bind-port']
|
||||
)
|
||||
|
||||
notifies :restart, "service[swift-object]", :immediately
|
||||
notifies :restart, "service[swift-object-replicator]", :immediately
|
||||
notifies :restart, "service[swift-object-updater]", :immediately
|
||||
notifies :restart, "service[swift-object-auditor]", :immediately
|
||||
notifies :restart, 'service[swift-object]', :immediately
|
||||
notifies :restart, 'service[swift-object-replicator]', :immediately
|
||||
notifies :restart, 'service[swift-object-updater]', :immediately
|
||||
notifies :restart, 'service[swift-object-auditor]', :immediately
|
||||
end
|
||||
|
||||
cron "swift-recon" do
|
||||
minute "*/5"
|
||||
command "swift-recon-cron /etc/swift/object-server.conf"
|
||||
user "swift"
|
||||
cron 'swift-recon' do
|
||||
minute '*/5'
|
||||
command 'swift-recon-cron /etc/swift/object-server.conf'
|
||||
user 'swift'
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: proxy-server
|
||||
@ -16,104 +17,103 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include_recipe "openstack-object-storage::common"
|
||||
include_recipe "openstack-object-storage::memcached"
|
||||
include_recipe 'openstack-object-storage::common'
|
||||
include_recipe 'openstack-object-storage::memcached'
|
||||
|
||||
class Chef::Recipe
|
||||
class Chef::Recipe # rubocop:disable Documentation
|
||||
include IPUtils
|
||||
end
|
||||
|
||||
if node.run_list.expand(node.chef_environment).recipes.include?("openstack-object-storage::setup")
|
||||
Chef::Log.info("I ran the openstack-object-storage::setup so I will use my own swift passwords")
|
||||
if node.run_list.expand(node.chef_environment).recipes.include?('openstack-object-storage::setup')
|
||||
Chef::Log.info('I ran the openstack-object-storage::setup so I will use my own swift passwords')
|
||||
else
|
||||
setup_role = node["swift"]["setup_chef_role"]
|
||||
setup_role = node['swift']['setup_chef_role']
|
||||
setup = search(:node, "chef_environment:#{node.chef_environment} AND roles:#{setup_role}")
|
||||
if setup.length == 0
|
||||
Chef::Application.fatal! "You must have run the openstack-object-storage::setup recipe (on this or another node) before running the swift::proxy recipe on this node"
|
||||
Chef::Application.fatal! 'You must have run the openstack-object-storage::setup recipe (on this or another node) before running the swift::proxy recipe on this node'
|
||||
elsif setup.length == 1
|
||||
Chef::Log.info "Found openstack-object-storage::setup node: #{setup[0].name}"
|
||||
node.set["swift"]["service_pass"] = setup[0]["swift"]["service_pass"]
|
||||
node.set['swift']['service_pass'] = setup[0]['swift']['service_pass']
|
||||
elsif setup.length > 1
|
||||
Chef::Application.fatal! "You have multiple nodes in your environment that have run swift-setup, and that is not allowed"
|
||||
Chef::Application.fatal! 'You have multiple nodes in your environment that have run swift-setup, and that is not allowed'
|
||||
end
|
||||
end
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
platform_options = node['swift']['platform']
|
||||
|
||||
# install platform-specific packages
|
||||
platform_options["proxy_packages"].each do |pkg|
|
||||
platform_options['proxy_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"]
|
||||
options platform_options['override_options']
|
||||
end
|
||||
end
|
||||
|
||||
if node["swift"]["authmode"] == "swauth"
|
||||
case node["swift"]["swauth_source"]
|
||||
when "package"
|
||||
platform_options["swauth_packages"].each do |pkg|
|
||||
if node['swift']['authmode'] == 'swauth'
|
||||
case node['swift']['swauth_source']
|
||||
when 'package'
|
||||
platform_options['swauth_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"]
|
||||
options platform_options['override_options']
|
||||
end
|
||||
end
|
||||
when "git"
|
||||
when 'git'
|
||||
git "#{Chef::Config[:file_cache_path]}/swauth" do
|
||||
repository node["swift"]["swauth_repository"]
|
||||
revision node["swift"]["swauth_version"]
|
||||
repository node['swift']['swauth_repository']
|
||||
revision node['swift']['swauth_version']
|
||||
action :sync
|
||||
end
|
||||
|
||||
bash "install_swauth" do
|
||||
bash 'install_swauth' do
|
||||
cwd "#{Chef::Config[:file_cache_path]}/swauth"
|
||||
user "root"
|
||||
group "root"
|
||||
user 'root'
|
||||
group 'root'
|
||||
code <<-EOH
|
||||
python setup.py install
|
||||
EOH
|
||||
environment 'PREFIX' => "/usr/local"
|
||||
environment 'PREFIX' => '/usr/local'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
package "python-swift-informant" do
|
||||
package 'python-swift-informant' do
|
||||
action :install
|
||||
only_if { node["swift"]["use_informant"] }
|
||||
only_if { node['swift']['use_informant'] }
|
||||
end
|
||||
|
||||
package "python-keystone" do
|
||||
package 'python-keystone' do
|
||||
action :install
|
||||
only_if { node["swift"]["authmode"] == "keystone" }
|
||||
only_if { node['swift']['authmode'] == 'keystone' }
|
||||
end
|
||||
|
||||
directory "/var/cache/swift" do
|
||||
owner "swift"
|
||||
group "swift"
|
||||
directory '/var/cache/swift' do
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode 00700
|
||||
end
|
||||
|
||||
swift_proxy_service = platform_options["service_prefix"] + "swift-proxy" + platform_options["service_suffix"]
|
||||
service "swift-proxy" do
|
||||
swift_proxy_service = platform_options['service_prefix'] + 'swift-proxy' + platform_options['service_suffix']
|
||||
service 'swift-proxy' do
|
||||
# openstack-swift-proxy.service on fedora-17, swift-proxy on ubuntu
|
||||
service_name swift_proxy_service
|
||||
provider platform_options["service_provider"]
|
||||
supports :status => true, :restart => true
|
||||
provider platform_options['service_provider']
|
||||
supports status: true, restart: true
|
||||
action [:enable, :start]
|
||||
only_if "[ -e /etc/swift/proxy-server.conf ] && [ -e /etc/swift/object.ring.gz ]"
|
||||
only_if '[ -e /etc/swift/proxy-server.conf ] && [ -e /etc/swift/object.ring.gz ]'
|
||||
end
|
||||
|
||||
# use localhost when using chef solo otherwise, include all memcache
|
||||
# servers from all known proxies
|
||||
if Chef::Config[:solo]
|
||||
memcache_servers = [ "127.0.0.1:11211" ]
|
||||
memcache_servers = ['127.0.0.1:11211']
|
||||
else
|
||||
memcache_servers = []
|
||||
proxy_role = node["swift"]["proxy_server_chef_role"]
|
||||
proxy_role = node['swift']['proxy_server_chef_role']
|
||||
proxy_nodes = search(:node, "chef_environment:#{node.chef_environment} AND roles:#{proxy_role}")
|
||||
proxy_nodes.each do |proxy|
|
||||
proxy_ip = locate_ip_in_cidr(node["swift"]["network"]["proxy-cidr"], proxy)
|
||||
next if not proxy_ip # skip nil ips so we dont break the config
|
||||
proxy_ip = locate_ip_in_cidr(node['swift']['network']['proxy-cidr'], proxy)
|
||||
next unless proxy_ip # skip nil ips so we dont break the config
|
||||
server_str = "#{proxy_ip}:11211"
|
||||
memcache_servers << server_str unless memcache_servers.include?(server_str)
|
||||
end
|
||||
@ -123,20 +123,22 @@ end
|
||||
if node['swift']['swift_secret_databag_name'].nil?
|
||||
authkey = node['swift']['authkey']
|
||||
else
|
||||
swift_secrets = Chef::EncryptedDataBagItem.load "secrets", node['swift']['swift_secret_databag_name']
|
||||
swift_secrets = Chef::EncryptedDataBagItem.load 'secrets', node['swift']['swift_secret_databag_name']
|
||||
authkey = swift_secrets['swift_authkey']
|
||||
end
|
||||
|
||||
# create proxy config file
|
||||
template "/etc/swift/proxy-server.conf" do
|
||||
source "proxy-server.conf.erb"
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0600"
|
||||
variables("authmode" => node["swift"]["authmode"],
|
||||
"bind_host" => node["swift"]["network"]["proxy-bind-ip"],
|
||||
"bind_port" => node["swift"]["network"]["proxy-bind-port"],
|
||||
"authkey" => authkey,
|
||||
"memcache_servers" => memcache_servers)
|
||||
notifies :restart, "service[swift-proxy]", :immediately
|
||||
template '/etc/swift/proxy-server.conf' do
|
||||
source 'proxy-server.conf.erb'
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0600'
|
||||
variables(
|
||||
'authmode' => node['swift']['authmode'],
|
||||
'bind_host' => node['swift']['network']['proxy-bind-ip'],
|
||||
'bind_port' => node['swift']['network']['proxy-bind-port'],
|
||||
'authkey' => authkey,
|
||||
'memcache_servers' => memcache_servers
|
||||
)
|
||||
notifies :restart, 'service[swift-proxy]', :immediately
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: ring-repo
|
||||
@ -21,129 +22,130 @@
|
||||
# for purposes of ring synchronization
|
||||
#
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
ring_options = node["swift"]["ring"]
|
||||
platform_options = node['swift']['platform']
|
||||
ring_options = node['swift']['ring']
|
||||
|
||||
platform_options["git_packages"].each do |pkg|
|
||||
platform_options['git_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
end
|
||||
end
|
||||
|
||||
service "xinetd" do
|
||||
supports :status => false, :restart => true
|
||||
service 'xinetd' do
|
||||
supports status: false, restart: true
|
||||
action [:enable, :start]
|
||||
only_if { platform?(%w{centos redhat fedora}) }
|
||||
only_if { platform?('centos', 'redhat', 'fedora') }
|
||||
end
|
||||
|
||||
execute "create empty git repo" do
|
||||
cwd "/tmp"
|
||||
execute 'create empty git repo' do
|
||||
cwd '/tmp'
|
||||
umask 022
|
||||
command "mkdir $$; cd $$; git init; echo \"backups\" \> .gitignore; git add .gitignore; git commit -m 'initial commit' --author='chef <chef@openstack>'; git push file:///#{platform_options["git_dir"]}/rings master"
|
||||
user "swift"
|
||||
user 'swift'
|
||||
action :nothing
|
||||
end
|
||||
|
||||
directory "git-directory" do
|
||||
directory 'git-directory' do
|
||||
path "#{platform_options["git_dir"]}/rings"
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0755"
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0755'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
|
||||
execute "initialize git repo" do
|
||||
execute 'initialize git repo' do
|
||||
cwd "#{platform_options["git_dir"]}/rings"
|
||||
umask 022
|
||||
user "swift"
|
||||
command "git init --bare && touch git-daemon-export-ok"
|
||||
user 'swift'
|
||||
command 'git init --bare && touch git-daemon-export-ok'
|
||||
creates "#{platform_options["git_dir"]}/rings/config"
|
||||
action :run
|
||||
notifies :run, "execute[create empty git repo]", :immediately
|
||||
notifies :run, 'execute[create empty git repo]', :immediately
|
||||
end
|
||||
|
||||
# epel/f-17 missing systemd-ified inits
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=737183
|
||||
template "/etc/systemd/system/git.service" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
source "simple-systemd-config.erb"
|
||||
variables({ :description => "Git daemon service",
|
||||
:user => "nobody",
|
||||
:exec => "/usr/libexec/git-core/git-daemon " +
|
||||
"--base-path=/var/lib/git --export-all --user-path=public_git" +
|
||||
"--syslog --verbose"
|
||||
})
|
||||
only_if { platform?(%w{fedora}) }
|
||||
template '/etc/systemd/system/git.service' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
source 'simple-systemd-config.erb'
|
||||
variables(
|
||||
description: 'Git daemon service',
|
||||
user: 'nobody',
|
||||
exec: '/usr/libexec/git-core/git-daemon ' +
|
||||
'--base-path=/var/lib/git --export-all --user-path=public_git' +
|
||||
'--syslog --verbose'
|
||||
)
|
||||
only_if { platform?('fedora') }
|
||||
end
|
||||
|
||||
case node["platform"]
|
||||
when "centos","redhat","fedora"
|
||||
service "git-daemon" do
|
||||
service_name platform_options["git_service"]
|
||||
case node['platform']
|
||||
when 'centos', 'redhat', 'fedora'
|
||||
service 'git-daemon' do
|
||||
service_name platform_options['git_service']
|
||||
action [:enable]
|
||||
end
|
||||
when "ubuntu","debian"
|
||||
service "git-daemon" do
|
||||
service_name platform_options["git_service"]
|
||||
when 'ubuntu', 'debian'
|
||||
service 'git-daemon' do
|
||||
service_name platform_options['git_service']
|
||||
action [:enable, :start]
|
||||
end
|
||||
end
|
||||
|
||||
cookbook_file "/etc/default/git-daemon" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "644"
|
||||
source "git-daemon.default"
|
||||
cookbook_file '/etc/default/git-daemon' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '644'
|
||||
source 'git-daemon.default'
|
||||
action :create
|
||||
notifies :restart, "service[git-daemon]", :immediately
|
||||
not_if { platform?(%w{fedora centos redhat}) }
|
||||
notifies :restart, 'service[git-daemon]', :immediately
|
||||
not_if { platform?('fedora', 'centos', 'redhat') }
|
||||
end
|
||||
|
||||
directory "/etc/swift/ring-workspace" do
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0755"
|
||||
directory '/etc/swift/ring-workspace' do
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0755'
|
||||
action :create
|
||||
end
|
||||
|
||||
execute "checkout-rings" do
|
||||
cwd "/etc/swift/ring-workspace"
|
||||
execute 'checkout-rings' do
|
||||
cwd '/etc/swift/ring-workspace'
|
||||
command "git clone file://#{platform_options["git_dir"]}/rings"
|
||||
user "swift"
|
||||
creates "/etc/swift/ring-workspace/rings"
|
||||
user 'swift'
|
||||
creates '/etc/swift/ring-workspace/rings'
|
||||
end
|
||||
|
||||
[ "account", "container", "object" ].each do |ring_type|
|
||||
['account', 'container', 'object'].each do |ring_type|
|
||||
|
||||
part_power = ring_options["part_power"]
|
||||
min_part_hours = ring_options["min_part_hours"]
|
||||
replicas = ring_options["replicas"]
|
||||
part_power = ring_options['part_power']
|
||||
min_part_hours = ring_options['min_part_hours']
|
||||
replicas = ring_options['replicas']
|
||||
|
||||
Chef::Log.info("Building initial ring #{ring_type} using part_power=#{part_power}, " +
|
||||
"min_part_hours=#{min_part_hours}, replicas=#{replicas}")
|
||||
execute "add #{ring_type}.builder" do
|
||||
cwd "/etc/swift/ring-workspace/rings"
|
||||
cwd '/etc/swift/ring-workspace/rings'
|
||||
command "git add #{ring_type}.builder && git commit -m 'initial ring builders' --author='chef <chef@openstack>'"
|
||||
user "swift"
|
||||
user 'swift'
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "create #{ring_type} builder" do
|
||||
cwd "/etc/swift/ring-workspace/rings"
|
||||
cwd '/etc/swift/ring-workspace/rings'
|
||||
command "swift-ring-builder #{ring_type}.builder create #{part_power} #{replicas} #{min_part_hours}"
|
||||
user "swift"
|
||||
user 'swift'
|
||||
creates "/etc/swift/ring-workspace/rings/#{ring_type}.builder"
|
||||
notifies :run, "execute[add #{ring_type}.builder]", :immediate
|
||||
end
|
||||
end
|
||||
|
||||
bash "rebuild-rings" do
|
||||
bash 'rebuild-rings' do
|
||||
action :nothing
|
||||
cwd "/etc/swift/ring-workspace/rings"
|
||||
user "swift"
|
||||
cwd '/etc/swift/ring-workspace/rings'
|
||||
user 'swift'
|
||||
code <<-EOF
|
||||
set -x
|
||||
|
||||
@ -172,12 +174,11 @@ bash "rebuild-rings" do
|
||||
EOF
|
||||
end
|
||||
|
||||
openstack_object_storage_ring_script "/etc/swift/ring-workspace/generate-rings.sh" do
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0700"
|
||||
ring_path "/etc/swift/ring-workspace/rings"
|
||||
openstack_object_storage_ring_script '/etc/swift/ring-workspace/generate-rings.sh' do
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0700'
|
||||
ring_path '/etc/swift/ring-workspace/rings'
|
||||
action :ensure_exists
|
||||
notifies :run, "bash[rebuild-rings]", :immediate
|
||||
notifies :run, 'bash[rebuild-rings]', :immediate
|
||||
end
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: rsync
|
||||
@ -17,69 +18,70 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
platform_options = node['swift']['platform']
|
||||
|
||||
platform_options["rsync_packages"].each do |pkg|
|
||||
platform_options['rsync_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"]
|
||||
options platform_options['override_options']
|
||||
end
|
||||
end
|
||||
|
||||
# epel/f-17 broken: https://bugzilla.redhat.com/show_bug.cgi?id=737710
|
||||
cookbook_file "/etc/systemd/system/rsync.service" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
source "rsync.service"
|
||||
cookbook_file '/etc/systemd/system/rsync.service' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
source 'rsync.service'
|
||||
action :create
|
||||
only_if { platform?(%w{fedora}) }
|
||||
only_if { platform?('fedora') }
|
||||
end
|
||||
|
||||
# rhel based systems install rsync and run it with rsync. We don't want to do that
|
||||
cookbook_file "/etc/init.d/rsyncd" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0755"
|
||||
source "rsync.init"
|
||||
cookbook_file '/etc/init.d/rsyncd' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
source 'rsync.init'
|
||||
action :create
|
||||
only_if { platform?(%w{centos redhat scientific}) }
|
||||
only_if { platform?('centos', 'redhat', 'scientific') }
|
||||
end
|
||||
|
||||
# FIXME: chicken and egg
|
||||
case node["platform"]
|
||||
when "centos","redhat","fedora"
|
||||
case node['platform']
|
||||
when 'centos', 'redhat', 'fedora'
|
||||
# enable rsyncd
|
||||
rsync_servicename = "rsyncd"
|
||||
service "rsyncd" do
|
||||
supports :status => false, :restart => true, :start => true, :stop => true
|
||||
rsync_servicename = 'rsyncd'
|
||||
service 'rsyncd' do
|
||||
supports status: false, restart: true, start: true, stop: true
|
||||
action [:enable, :start]
|
||||
only_if "[ -f /etc/rsyncd.conf ]"
|
||||
only_if '[ -f /etc/rsyncd.conf ]'
|
||||
end
|
||||
# disable rsync (the one via xinetd)
|
||||
service "rsync" do
|
||||
supports :status => false, :restart => false, :start => false, :stop => false
|
||||
service 'rsync' do
|
||||
supports status: false, restart: false, start: false, stop: false
|
||||
action [:disable]
|
||||
end
|
||||
when "ubuntu","debian"
|
||||
rsync_servicename = "rsync"
|
||||
service "rsync" do
|
||||
supports :status => false, :restart => true
|
||||
when 'ubuntu', 'debian'
|
||||
rsync_servicename = 'rsync'
|
||||
service 'rsync' do
|
||||
supports status: false, restart: true
|
||||
action [:enable, :start]
|
||||
only_if "[ -f /etc/rsyncd.conf ]"
|
||||
only_if '[ -f /etc/rsyncd.conf ]'
|
||||
end
|
||||
end
|
||||
|
||||
template "/etc/rsyncd.conf" do
|
||||
source "rsyncd.conf.erb"
|
||||
mode "0644"
|
||||
template '/etc/rsyncd.conf' do
|
||||
source 'rsyncd.conf.erb'
|
||||
mode '0644'
|
||||
notifies :restart, "service[#{rsync_servicename}]", :immediately
|
||||
end
|
||||
|
||||
execute "enable rsync" do
|
||||
execute 'enable rsync' do
|
||||
command "sed -i 's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/' /etc/default/rsync"
|
||||
only_if "grep -q 'RSYNC_ENABLE=false' /etc/default/rsync"
|
||||
notifies :restart, "service[rsync]", :immediately
|
||||
notifies :restart, 'service[rsync]', :immediately
|
||||
action :run
|
||||
not_if { platform?(%w{fedora centos redhat scientific}) }
|
||||
# TODO(chrislaco) Convert these to platform_family?
|
||||
not_if { platform?('fedora', 'centos', 'redhat', 'scientific') }
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: setup
|
||||
@ -16,67 +17,67 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include_recipe "openstack-object-storage::common"
|
||||
include_recipe 'openstack-object-storage::common'
|
||||
|
||||
# make sure we die if there are multiple swift-setups
|
||||
if Chef::Config[:solo]
|
||||
Chef::Application.fatal! "This recipe uses search. Chef Solo does not support search."
|
||||
Chef::Application.fatal! 'This recipe uses search. Chef Solo does not support search.'
|
||||
else
|
||||
setup_role = node["swift"]["setup_chef_role"]
|
||||
setup_role = node['swift']['setup_chef_role']
|
||||
setup_role_count = search(:node, "chef_environment:#{node.chef_environment} AND roles:#{setup_role}").length
|
||||
if setup_role_count > 1
|
||||
Chef::Application.fatal! "You can only have one node with the swift-setup role"
|
||||
Chef::Application.fatal! 'You can only have one node with the swift-setup role'
|
||||
end
|
||||
end
|
||||
|
||||
unless node["swift"]["service_pass"]
|
||||
Chef::Log.info("Running swift setup - setting swift passwords")
|
||||
unless node['swift']['service_pass']
|
||||
Chef::Log.info('Running swift setup - setting swift passwords')
|
||||
end
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
platform_options = node['swift']['platform']
|
||||
|
||||
# install platform-specific packages
|
||||
platform_options["proxy_packages"].each do |pkg|
|
||||
platform_options['proxy_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :upgrade
|
||||
options platform_options["override_options"]
|
||||
options platform_options['override_options']
|
||||
end
|
||||
end
|
||||
|
||||
if node["swift"]["authmode"] == "swauth"
|
||||
case node["swift"]["swauth_source"]
|
||||
when "package"
|
||||
platform_options["swauth_packages"].each do |pkg|
|
||||
if node['swift']['authmode'] == 'swauth'
|
||||
case node['swift']['swauth_source']
|
||||
when 'package'
|
||||
platform_options['swauth_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :upgrade
|
||||
options platform_options["override_options"]
|
||||
options platform_options['override_options']
|
||||
end
|
||||
end
|
||||
when "git"
|
||||
when 'git'
|
||||
git "#{Chef::Config[:file_cache_path]}/swauth" do
|
||||
repository node["swift"]["swauth_repository"]
|
||||
revision node["swift"]["swauth_version"]
|
||||
repository node['swift']['swauth_repository']
|
||||
revision node['swift']['swauth_version']
|
||||
action :sync
|
||||
end
|
||||
|
||||
bash "install_swauth" do
|
||||
bash 'install_swauth' do
|
||||
cwd "#{Chef::Config[:file_cache_path]}/swauth"
|
||||
user "root"
|
||||
group "root"
|
||||
user 'root'
|
||||
group 'root'
|
||||
code <<-EOH
|
||||
python setup.py install
|
||||
EOH
|
||||
environment 'PREFIX' => "/usr/local"
|
||||
environment 'PREFIX' => '/usr/local'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
package "python-swift-informant" do
|
||||
package 'python-swift-informant' do
|
||||
action :upgrade
|
||||
only_if { node["swift"]["use_informant"] }
|
||||
only_if { node['swift']['use_informant'] }
|
||||
end
|
||||
|
||||
package "python-keystone" do
|
||||
package 'python-keystone' do
|
||||
action :upgrade
|
||||
only_if { node["swift"]["authmode"] == "keystone" }
|
||||
only_if { node['swift']['authmode'] == 'keystone' }
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: swift
|
||||
# Recipe:: storage-common
|
||||
@ -17,24 +18,24 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "openstack-object-storage::rsync"
|
||||
include_recipe 'openstack-object-storage::rsync'
|
||||
|
||||
template "/etc/swift/drive-audit.conf" do
|
||||
source "drive-audit.conf.erb"
|
||||
owner "swift"
|
||||
group "swift"
|
||||
mode "0600"
|
||||
template '/etc/swift/drive-audit.conf' do
|
||||
source 'drive-audit.conf.erb'
|
||||
owner 'swift'
|
||||
group 'swift'
|
||||
mode '0600'
|
||||
end
|
||||
|
||||
cron "drive-audit" do
|
||||
hour node["swift"]["audit_hour"]
|
||||
minute "10"
|
||||
command "swift-drive-audit /etc/swift/drive-audit.conf"
|
||||
cron 'drive-audit' do
|
||||
hour node['swift']['audit_hour']
|
||||
minute '10'
|
||||
command 'swift-drive-audit /etc/swift/drive-audit.conf'
|
||||
end
|
||||
|
||||
directory "/var/cache/swift" do
|
||||
group "swift"
|
||||
owner "swift"
|
||||
directory '/var/cache/swift' do
|
||||
group 'swift'
|
||||
owner 'swift'
|
||||
recursive true
|
||||
action :create
|
||||
mode 00700
|
||||
|
Loading…
Reference in New Issue
Block a user