Add swift-dispersion configuration
* Add config file for swift-dispersion-populate & swift-dispersion-report * Add creation of keystone user for swift-dispersion
This commit is contained in:
		
				
					committed by
					
						
						François Charlier
					
				
			
			
				
	
			
			
			
						parent
						
							4a0eb9d836
						
					
				
				
					commit
					22d2f61289
				
			
							
								
								
									
										33
									
								
								manifests/dispersion.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								manifests/dispersion.pp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
class swift::dispersion (
 | 
			
		||||
  $auth_url = 'http://127.0.0.1:5000/v2.0/',
 | 
			
		||||
  $auth_user = 'dispersion',
 | 
			
		||||
  $auth_tenant = 'services',
 | 
			
		||||
  $auth_pass = 'dispersion_password',
 | 
			
		||||
  $auth_version = '2.0',
 | 
			
		||||
  $swift_dir = '/etc/swift',
 | 
			
		||||
  $coverage = 1,
 | 
			
		||||
  $retries = 5,
 | 
			
		||||
  $concurrency = 25,
 | 
			
		||||
  $dump_json = 'no'
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
  include swift::params
 | 
			
		||||
 | 
			
		||||
  file { '/etc/swift/dispersion.conf':
 | 
			
		||||
    ensure  => present,
 | 
			
		||||
    content => template('swift/dispersion.conf.erb'),
 | 
			
		||||
    owner   => 'swift',
 | 
			
		||||
    group   => 'swift',
 | 
			
		||||
    mode    => '0660',
 | 
			
		||||
    require => Package['swift'],
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  exec { 'swift-dispersion-populate':
 | 
			
		||||
    path      => ['/bin', '/usr/bin'],
 | 
			
		||||
    subscribe => File['/etc/swift/dispersion.conf'],
 | 
			
		||||
    timeout   => 0,
 | 
			
		||||
    onlyif    => "swift -A ${auth_url} -U ${auth_tenant}:${auth_user} -K ${auth_pass} -V ${auth_version} stat | grep 'Account: '",
 | 
			
		||||
    unless    => "swift -A ${auth_url} -U ${auth_tenant}:${auth_user} -K ${auth_pass} -V ${auth_version} list | grep dispersion_",
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								manifests/keystone/dispersion.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								manifests/keystone/dispersion.pp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
class swift::keystone::dispersion(
 | 
			
		||||
  $auth_user = 'dispersion',
 | 
			
		||||
  $auth_pass = 'dispersion_password'
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
  keystone_user { $auth_user:
 | 
			
		||||
    ensure   => present,
 | 
			
		||||
    password => $auth_pass,
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  keystone_user_role { "${auth_user}@services":
 | 
			
		||||
    ensure  => present,
 | 
			
		||||
    roles   => 'admin',
 | 
			
		||||
    require => Keystone_user[$auth_user]
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										108
									
								
								spec/classes/swift_dispersion_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								spec/classes/swift_dispersion_spec.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,108 @@
 | 
			
		||||
require 'spec_helper'
 | 
			
		||||
 | 
			
		||||
describe 'swift::dispersion' do
 | 
			
		||||
 | 
			
		||||
  let :facts do
 | 
			
		||||
    { :osfamily => 'Debian' }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it { should contain_file('/etc/swift/dispersion.conf').with(
 | 
			
		||||
    :ensure  => 'present',
 | 
			
		||||
    :owner   => 'swift',
 | 
			
		||||
    :group   => 'swift',
 | 
			
		||||
    :mode    => '0660',
 | 
			
		||||
    :require => 'Package[swift]')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  describe 'with default parameters' do
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^\[dispersion\]$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^auth_url = http:\/\/127.0.0.1:5000\/v2.0\/$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^auth_version = 2.0$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^auth_user = services:dispersion$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^auth_key = dispersion_password$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^swift_dir = \/etc\/swift$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^dispersion_coverage = 1$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^retries = 5$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^concurrency = 25$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^dump_json = no$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_exec('swift-dispersion-populate').with(
 | 
			
		||||
      :path      => ['/bin', '/usr/bin'],
 | 
			
		||||
      :subscribe => 'File[/etc/swift/dispersion.conf]',
 | 
			
		||||
      :onlyif    => "swift -A http://127.0.0.1:5000/v2.0/ -U services:dispersion -K dispersion_password -V 2.0 stat | grep 'Account: '",
 | 
			
		||||
      :unless    => "swift -A http://127.0.0.1:5000/v2.0/ -U services:dispersion -K dispersion_password -V 2.0 list | grep dispersion_"
 | 
			
		||||
    )}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe 'when parameters are overriden' do
 | 
			
		||||
    let :params do
 | 
			
		||||
      {
 | 
			
		||||
        :auth_url     => 'https://169.254.0.1:7000/auth/v8.0/',
 | 
			
		||||
        :auth_user    => 'foo',
 | 
			
		||||
        :auth_tenant  => 'bar',
 | 
			
		||||
        :auth_pass    => 'dummy',
 | 
			
		||||
        :auth_version => '1.0',
 | 
			
		||||
        :swift_dir    => '/usr/local/etc/swift',
 | 
			
		||||
        :coverage     => 42,
 | 
			
		||||
        :retries      => 51,
 | 
			
		||||
        :concurrency  => 4682,
 | 
			
		||||
        :dump_json    => 'yes'
 | 
			
		||||
      }
 | 
			
		||||
    end
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^\[dispersion\]$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^auth_url = https:\/\/169.254.0.1:7000\/auth\/v8.0\/$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^auth_version = 1.0$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^auth_user = bar:foo$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^auth_key = dummy$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^swift_dir = \/usr\/local\/etc\/swift$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^dispersion_coverage = 42$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^retries = 51$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^concurrency = 4682$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_file('/etc/swift/dispersion.conf') \
 | 
			
		||||
      .with_content(/^dump_json = yes$/)
 | 
			
		||||
    }
 | 
			
		||||
    it { should contain_exec('swift-dispersion-populate').with(
 | 
			
		||||
      :path      => ['/bin', '/usr/bin'],
 | 
			
		||||
      :subscribe => 'File[/etc/swift/dispersion.conf]',
 | 
			
		||||
      :onlyif    => "swift -A https://169.254.0.1:7000/auth/v8.0/ -U bar:foo -K dummy -V 1.0 stat | grep 'Account: '",
 | 
			
		||||
      :unless    => "swift -A https://169.254.0.1:7000/auth/v8.0/ -U bar:foo -K dummy -V 1.0 list | grep dispersion_"
 | 
			
		||||
    )}
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										48
									
								
								spec/classes/swift_keystone_dispersion_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								spec/classes/swift_keystone_dispersion_spec.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
require 'spec_helper'
 | 
			
		||||
 | 
			
		||||
describe 'swift::keystone::dispersion' do
 | 
			
		||||
 | 
			
		||||
  describe 'with default class parameters' do
 | 
			
		||||
 | 
			
		||||
    it { should contain_keystone_user('dispersion').with(
 | 
			
		||||
      :ensure   => 'present',
 | 
			
		||||
      :password => 'dispersion_password'
 | 
			
		||||
    ) }
 | 
			
		||||
 | 
			
		||||
    it { should contain_keystone_user_role('dispersion@services').with(
 | 
			
		||||
      :ensure  => 'present',
 | 
			
		||||
      :roles   => 'admin',
 | 
			
		||||
      :require => 'Keystone_user[dispersion]'
 | 
			
		||||
    ) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe 'when overriding password' do
 | 
			
		||||
 | 
			
		||||
    let :params do
 | 
			
		||||
      {
 | 
			
		||||
        :auth_pass => 'foo'
 | 
			
		||||
      }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it { should contain_keystone_user('dispersion').with(
 | 
			
		||||
      :ensure   => 'present',
 | 
			
		||||
      :password => 'foo'
 | 
			
		||||
    ) }
 | 
			
		||||
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe 'when overriding auth user' do
 | 
			
		||||
 | 
			
		||||
    let :params do
 | 
			
		||||
      {
 | 
			
		||||
        :auth_user => 'bar'
 | 
			
		||||
      }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it { should contain_keystone_user('bar') }
 | 
			
		||||
 | 
			
		||||
    it { should contain_keystone_user_role('bar@services') }
 | 
			
		||||
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										11
									
								
								templates/dispersion.conf.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								templates/dispersion.conf.erb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
[dispersion]
 | 
			
		||||
auth_url = <%= auth_url %>
 | 
			
		||||
auth_version = <%= auth_version %>
 | 
			
		||||
auth_user = <%= auth_tenant %>:<%= auth_user %>
 | 
			
		||||
auth_key = <%= auth_pass %>
 | 
			
		||||
swift_dir = <%= swift_dir %>
 | 
			
		||||
dispersion_coverage = <%= coverage %>
 | 
			
		||||
retries = <%= retries %>
 | 
			
		||||
concurrency = <%= concurrency %>
 | 
			
		||||
dump_json = <%= dump_json %>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user