diff --git a/manifests/storage/container.pp b/manifests/storage/container.pp index 7c7c69ed..18c10f7b 100644 --- a/manifests/storage/container.pp +++ b/manifests/storage/container.pp @@ -1,5 +1,12 @@ +# +# === Parameters +# +# [*allowed_sync_hosts*] A list of hosts allowed in the X-Container-Sync-To +# field for containers. Defaults to one entry list '127.0.0.1'. +# class swift::storage::container( - $package_ensure = 'present' + $package_ensure = 'present', + $allowed_sync_hosts = ['127.0.0.1'], ) { swift::storage::generic { 'container': package_ensure => $package_ensure diff --git a/spec/classes/swift_storage_container_spec.rb b/spec/classes/swift_storage_container_spec.rb index 10ed556d..38c80b96 100644 --- a/spec/classes/swift_storage_container_spec.rb +++ b/spec/classes/swift_storage_container_spec.rb @@ -60,7 +60,8 @@ describe 'swift::storage::container' do let :facts do { :operatingsystem => 'RedHat', - :osfamily => 'RedHat' + :osfamily => 'RedHat', + :concat_basedir => '/var/lib/puppet/concat' } end it 'should have some support services' do @@ -73,5 +74,30 @@ describe 'swift::storage::container' do ) end end + + describe 'configuration file' do + let :pre_condition do + "class { 'ssh::server::install': } + class { 'swift': swift_hash_suffix => 'foo' } + class { 'swift::storage::all': storage_local_net_ip => '10.0.0.1' }" + end + + let :fragment_file do + "/var/lib/puppet/concat/_etc_swift_container-server.conf/fragments/00_swift-container-6001" + end + + it { should contain_file(fragment_file).with_content(/^allowed_sync_hosts = 127.0.0.1$/) } + + describe 'with allowed_sync_hosts' do + + let :params do + { :allowed_sync_hosts => ['127.0.0.1', '10.1.0.1', '10.1.0.2'], } + end + + it { + should contain_file(fragment_file).with_content(/^allowed_sync_hosts = 127.0.0.1,10.1.0.1,10.1.0.2$/) + } + end + end end end diff --git a/templates/container-server.conf.erb b/templates/container-server.conf.erb index 9d007366..d3a6d58c 100644 --- a/templates/container-server.conf.erb +++ b/templates/container-server.conf.erb @@ -6,6 +6,7 @@ mount_check = <%= mount_check %> user = <%= user %> log_facility = <%= log_facility %> workers = <%= workers %> +allowed_sync_hosts = <%= scope.lookupvar("swift::storage::container::allowed_sync_hosts").to_a.join(',') %> [pipeline:main] pipeline = <%= pipeline.to_a.join(' ') %>