diff --git a/manifests/config.pp b/manifests/config.pp index 32e2b20..5444abd 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -55,11 +55,14 @@ mode => '0644', } - file { $::tsm::config_opt: - ensure => file, - replace => $::tsm::config_replace, - owner => 'root', - group => 'root', - mode => '0644', + if $::tsm::config_opt_hash { + file { $::tsm::config_opt: + ensure => file, + replace => $::tsm::config_replace, + owner => 'root', + group => 'root', + mode => '0644', + content => template($::tsm::config_opt_template), + } } } diff --git a/manifests/init.pp b/manifests/init.pp index 68c77ec..e4f6990 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -139,6 +139,11 @@ # keys => value # Default: {} # +# [*config_opt_hash*] +# config_opt_hash - hash with opt parameters +# keys => value +# Default: undef +# # [*tcp_server_address*] # TSM server used for this client # tcp_server_address - obligatory @@ -184,6 +189,7 @@ $inclexcl_replace = $::tsm::params::inclexcl_replace, $inclexcl_source = $::tsm::params::inclexcl_source, $config_hash = {}, + $config_opt_hash = undef, $tcp_server_address, ) inherits tsm::params { diff --git a/manifests/params.pp b/manifests/params.pp index 0af6a9a..bf7e453 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -25,17 +25,18 @@ $set_initial_password = true # default parameters fot dsm.sys - $comm_method = 'TCPip' - $tcp_port = '1500' + $comm_method = 'TCPip' + $tcp_port = '1500' - $config = '/opt/tivoli/tsm/client/ba/bin/dsm.sys' - $config_opt = '/opt/tivoli/tsm/client/ba/bin/dsm.opt' - $config_template = 'tsm/dsm.sys.erb' - $config_replace = false + $config = '/opt/tivoli/tsm/client/ba/bin/dsm.sys' + $config_opt = '/opt/tivoli/tsm/client/ba/bin/dsm.opt' + $config_template = 'tsm/dsm.sys.erb' + $config_opt_template = 'tsm/dsm.opt.erb' + $config_replace = false - $inclexcl = '/opt/tivoli/tsm/client/ba/bin/InclExcl' - $inclexcl_local = '/opt/tivoli/tsm/client/ba/bin/InclExcl.local' - $inclexcl_replace = false + $inclexcl = '/opt/tivoli/tsm/client/ba/bin/InclExcl' + $inclexcl_local = '/opt/tivoli/tsm/client/ba/bin/InclExcl.local' + $inclexcl_replace = false case $::osfamily { redhat: { diff --git a/spec/classes/tsm_spec.rb b/spec/classes/tsm_spec.rb index be97021..73b2acf 100644 --- a/spec/classes/tsm_spec.rb +++ b/spec/classes/tsm_spec.rb @@ -80,7 +80,7 @@ end it do - should contain_file('/opt/tivoli/tsm/client/ba/bin/dsm.opt').with({ + should_not contain_file('/opt/tivoli/tsm/client/ba/bin/dsm.opt').with({ 'ensure' => 'file', 'replace' => 'false', 'owner' => 'root', @@ -89,7 +89,34 @@ }) end + context 'tsm::config with dsm.opt file' do + config_opt_hash ={ + 'key1' => 'val1', + 'key2' => 'val2', + 'key3' => 'val3', + } + + describe 'should install tsm packages ' do + let(:params) {{ + :tcp_server_address => 'tsm', + :config_opt_hash => config_opt_hash, + }} + + it do + should contain_file('/opt/tivoli/tsm/client/ba/bin/dsm.opt').with({ + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644' + }) + + config_opt_hash.each do |k,v| + should contain_file('/opt/tivoli/tsm/client/ba/bin/dsm.opt').with_content(/#{k}( +)#{v}/) + end + + end + end + end context 'on Redhat 6' do let :facts do diff --git a/templates/dsm.opt.erb b/templates/dsm.opt.erb new file mode 100644 index 0000000..360ff27 --- /dev/null +++ b/templates/dsm.opt.erb @@ -0,0 +1,16 @@ + +************************************************************************ +* * +* Managed by Puppet * +* * +* Tivoli Storage Manager * +* * +************************************************************************ + +<%- if ! @config_opt_hash.nil? -%> +<%- config_opt_hash.keys.sort.each do |config_key| -%> +<%- config_value = @config_opt_hash[config_key] -%> +<%- line = "%-21s %s" % [config_key, config_value] -%> +<%= line %> +<%- end -%> +<%- end -%>