diff --git a/.gitignore b/.gitignore index 12998cd7..6e632ba7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ spec/fixtures/modules/ssh spec/fixtures/modules/stdlib spec/fixtures/modules/xinetd spec/fixtures/modules/* +spec/fixtures/manifests/site.pp diff --git a/manifests/test_file.pp b/manifests/test_file.pp new file mode 100644 index 00000000..ec2a7927 --- /dev/null +++ b/manifests/test_file.pp @@ -0,0 +1,43 @@ +# == Class: swift::test_file +# +# Deploys a file that can be used to verify your swift installation. +# +# === Parameters +# +# [*password*] +# password used with tenant/user combination against auth_server. Required. +# [*auth_server*] +# server hosting keystone. Optional. Defaults to 127.0.0.1. +# [*tenant*] +# tenant used for authentication (required for retrieval of catalog). Optional. Defaults to openstack. +# [*user*] +# authenticated user. Optional. Defaults to 'admin'. +# +# === Examples +# +# class { 'swift::test_file': +# auth_server => '172.16.0.25', +# tenant => 'services', +# user => 'swift', +# password => 'admin_password', +# } +# +# === Authors +# +# Dan Bode +# +# === Copyright +# +# Copyright 2011 PuppetLabs. +# +class swift::test_file ( + $password, + $auth_server = '127.0.0.1', + $tenant = 'openstack', + $user = 'admin' +) { + file { '/tmp/swift_test_file.rb': + mode => '755', + content => template('swift/swift_keystone_test.erb') + } +} diff --git a/spec/classes/swift_test_file_spec.rb b/spec/classes/swift_test_file_spec.rb new file mode 100644 index 00000000..d86dfb94 --- /dev/null +++ b/spec/classes/swift_test_file_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe 'swift::test_file' do + + let :default_params do + {:password => 'foo'} + end + + describe 'with defaults' do + + let :params do + default_params + end + + it 'should create a reasonable test file' do + verify_contents(subject, '/tmp/swift_test_file.rb', + [ + 'proxy_local_net_ip="127.0.0.1"', + "user='openstack:admin'", + "password='foo'" + ] + ) + end + + end + + describe 'when overridding' do + + let :params do + default_params.merge({ + :auth_server => '127.0.0.2', + :tenant => 'tenant', + :user => 'user', + :password => 'password' + }) + end + + it 'should create a configured test file' do + verify_contents(subject, '/tmp/swift_test_file.rb', + [ + 'proxy_local_net_ip="127.0.0.2"', + "user='tenant:user'", + "password='password'" + ] + ) + end + + end +end diff --git a/files/swift_keystone_test.rb b/templates/swift_keystone_test.erb similarity index 97% rename from files/swift_keystone_test.rb rename to templates/swift_keystone_test.erb index 1db83ec5..f8a7398f 100644 --- a/files/swift_keystone_test.rb +++ b/templates/swift_keystone_test.erb @@ -8,9 +8,9 @@ require 'open3' require 'fileutils' # connection variables -proxy_local_net_ip='127.0.0.1' -user='openstack:admin' -password='admin_password' +proxy_local_net_ip="<%= auth_server %>" +user='<%= tenant %>:<%= user %>' +password='<%= password %>' ## headers for curl requests #user_header="-H 'X-Storage-User: #{user}'"