Loading manifests/hash.pp +0 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,4 @@ define postfix::hash ( path => $name, mode => $mode, } Class['postfix'] -> Postfix::Hash[$title] } manifests/init.pp +17 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,14 @@ # # [*configs*] - (hash) # # [*hash*] - (hash) A hash of postfix::hash resources # # [*transport*] - (hash) A hash of postfix::transport resources # # [*virtual*] - (hash) A hash of postfix::virtual resources # # [*conffile*] - (hash) A hash of postfix::conffile resources # # [*amavis_procs*] - (integer) Number of amavis scanners to spawn # # [*inet_interfaces*] - (string) Loading Loading @@ -96,7 +104,11 @@ class postfix ( Stdlib::Absolutepath $confdir = '/etc/postfix', String $root_group = 'root', String $alias_maps = 'hash:/etc/aliases', Hash $configs = {}, Optional[Hash] $configs = {}, Optional[Hash] $hash = {}, Optional[Hash] $transport = {}, Optional[Hash] $virtual = {}, Optional[Hash] $conffile = {}, Integer $amavis_procs = 2, String $inet_interfaces = 'all', String $inet_protocols = 'all', Loading Loading @@ -157,6 +169,10 @@ class postfix ( } create_resources('::postfix::config', $configs) create_resources('::postfix::transport', $transport) create_resources('::postfix::virtual', $virtual) create_resources('::postfix::hash', $hash) create_resources('::postfix::conffile', $conffile) contain 'postfix::packages' contain 'postfix::files' Loading spec/classes/postfix_spec.rb +80 −0 Original line number Diff line number Diff line Loading @@ -466,6 +466,86 @@ describe 'postfix' do is_expected.to contain_postfix__config('message_size_limit').with_value('51200000') end end context 'when hash hash is used' do let(:params) do { hash: { '/etc/postfix/transport' => { 'ensure' => 'present', }, }, } end it 'updates master.cf with the specified contents' do is_expected.to contain_postfix__hash('/etc/postfix/transport').with_ensure('present') end end context 'when transport hash is used' do let(:params) do { transport: { 'local_relay' => { 'nexthop' => '[10.12.0.2]:9925', }, }, } end it 'updates master.cf with the specified contents' do is_expected.to contain_postfix__transport('local_relay').with_nexthop('[10.12.0.2]:9925') end end context 'when virtual hash is used' do let(:params) do { virtual: { 'someone@somedomain.tld' => { 'destination' => 'internal@ourdomain.tld', }, }, } end it 'updates master.cf with the specified contents' do is_expected.to contain_postfix__virtual('someone@somedomain.tld').with_destination('internal@ourdomain.tld') end end context 'when conffile hash is used' do let(:params) do { conffile: { 'ldapoptions.cf' => { 'mode' => '0640', 'options' => { 'server_host' => 'ldap.mydomain.com', 'bind' => 'yes', 'bind_dn' => 'cn=admin,dc=mydomain,dc=com', 'bind_pw' => 'password', 'search_base' => 'dc=example, dc=com', 'query_filter' => 'mail=%s', 'result_attribute' => 'uid', }, }, }, } end it 'creates ldapoptions.cf with the specified contents' do is_expected.to contain_postfix__conffile('ldapoptions.cf').with( 'mode' => '0640', 'options' => { 'server_host' => 'ldap.mydomain.com', 'bind' => 'yes', 'bind_dn' => 'cn=admin,dc=mydomain,dc=com', 'bind_pw' => 'password', 'search_base' => 'dc=example, dc=com', 'query_filter' => 'mail=%s', 'result_attribute' => 'uid', } ) end end end end end Loading Loading
manifests/hash.pp +0 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,4 @@ define postfix::hash ( path => $name, mode => $mode, } Class['postfix'] -> Postfix::Hash[$title] }
manifests/init.pp +17 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,14 @@ # # [*configs*] - (hash) # # [*hash*] - (hash) A hash of postfix::hash resources # # [*transport*] - (hash) A hash of postfix::transport resources # # [*virtual*] - (hash) A hash of postfix::virtual resources # # [*conffile*] - (hash) A hash of postfix::conffile resources # # [*amavis_procs*] - (integer) Number of amavis scanners to spawn # # [*inet_interfaces*] - (string) Loading Loading @@ -96,7 +104,11 @@ class postfix ( Stdlib::Absolutepath $confdir = '/etc/postfix', String $root_group = 'root', String $alias_maps = 'hash:/etc/aliases', Hash $configs = {}, Optional[Hash] $configs = {}, Optional[Hash] $hash = {}, Optional[Hash] $transport = {}, Optional[Hash] $virtual = {}, Optional[Hash] $conffile = {}, Integer $amavis_procs = 2, String $inet_interfaces = 'all', String $inet_protocols = 'all', Loading Loading @@ -157,6 +169,10 @@ class postfix ( } create_resources('::postfix::config', $configs) create_resources('::postfix::transport', $transport) create_resources('::postfix::virtual', $virtual) create_resources('::postfix::hash', $hash) create_resources('::postfix::conffile', $conffile) contain 'postfix::packages' contain 'postfix::files' Loading
spec/classes/postfix_spec.rb +80 −0 Original line number Diff line number Diff line Loading @@ -466,6 +466,86 @@ describe 'postfix' do is_expected.to contain_postfix__config('message_size_limit').with_value('51200000') end end context 'when hash hash is used' do let(:params) do { hash: { '/etc/postfix/transport' => { 'ensure' => 'present', }, }, } end it 'updates master.cf with the specified contents' do is_expected.to contain_postfix__hash('/etc/postfix/transport').with_ensure('present') end end context 'when transport hash is used' do let(:params) do { transport: { 'local_relay' => { 'nexthop' => '[10.12.0.2]:9925', }, }, } end it 'updates master.cf with the specified contents' do is_expected.to contain_postfix__transport('local_relay').with_nexthop('[10.12.0.2]:9925') end end context 'when virtual hash is used' do let(:params) do { virtual: { 'someone@somedomain.tld' => { 'destination' => 'internal@ourdomain.tld', }, }, } end it 'updates master.cf with the specified contents' do is_expected.to contain_postfix__virtual('someone@somedomain.tld').with_destination('internal@ourdomain.tld') end end context 'when conffile hash is used' do let(:params) do { conffile: { 'ldapoptions.cf' => { 'mode' => '0640', 'options' => { 'server_host' => 'ldap.mydomain.com', 'bind' => 'yes', 'bind_dn' => 'cn=admin,dc=mydomain,dc=com', 'bind_pw' => 'password', 'search_base' => 'dc=example, dc=com', 'query_filter' => 'mail=%s', 'result_attribute' => 'uid', }, }, }, } end it 'creates ldapoptions.cf with the specified contents' do is_expected.to contain_postfix__conffile('ldapoptions.cf').with( 'mode' => '0640', 'options' => { 'server_host' => 'ldap.mydomain.com', 'bind' => 'yes', 'bind_dn' => 'cn=admin,dc=mydomain,dc=com', 'bind_pw' => 'password', 'search_base' => 'dc=example, dc=com', 'query_filter' => 'mail=%s', 'result_attribute' => 'uid', } ) end end end end end Loading