Skip to content

Commit

Permalink
cutting rubocop offenses down to 32
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean OMeara committed Nov 5, 2013
1 parent 4675d77 commit b113d5b
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 155 deletions.
90 changes: 45 additions & 45 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# encoding: utf-8
# Author:: Joshua Timberman <[email protected]>
# Copyright:: Copyright (c) 2009, Opscode, Inc.
# License:: Apache License, Version 2.0
Expand All @@ -16,13 +16,13 @@
# limitations under the License.

# Generic cookbook attributes
default['postfix']['mail_type'] = "client"
default['postfix']['relayhost_role'] = "relayhost"
default['postfix']['mail_type'] = 'client'
default['postfix']['relayhost_role'] = 'relayhost'
default['postfix']['multi_environment_relay'] = false
default['postfix']['use_procmail'] = false
default['postfix']['aliases'] = {}
default['postfix']['main_template_source'] = "postfix"
default['postfix']['master_template_source'] = "postfix"
default['postfix']['main_template_source'] = 'postfix'
default['postfix']['master_template_source'] = 'postfix'
default['postfix']['sender_canonical_map_entries'] = {}

case node['platform']
Expand All @@ -35,69 +35,69 @@
end

# Non-default main.cf attributes
default['postfix']['main']['biff'] = "no"
default['postfix']['main']['append_dot_mydomain'] = "no"
default['postfix']['main']['biff'] = 'no'
default['postfix']['main']['append_dot_mydomain'] = 'no'
default['postfix']['main']['myhostname'] = (node['fqdn'] || node['hostname']).to_s.chomp('.')
default['postfix']['main']['mydomain'] = (node['domain'] || node['hostname']).to_s.chomp('.')
default['postfix']['main']['myorigin'] = "$myhostname"
default['postfix']['main']['mydestination'] = [ node['postfix']['main']['myhostname'], node['hostname'], "localhost.localdomain", "localhost" ].compact
default['postfix']['main']['smtpd_use_tls'] = "yes"
default['postfix']['main']['smtp_use_tls'] = "yes"
default['postfix']['main']['alias_maps'] = [ "hash:#{node['postfix']['aliases_db']}" ]
default['postfix']['main']['myorigin'] = '$myhostname'
default['postfix']['main']['mydestination'] = [node['postfix']['main']['myhostname'], node['hostname'], 'localhost.localdomain', 'localhost'].compact
default['postfix']['main']['smtpd_use_tls'] = 'yes'
default['postfix']['main']['smtp_use_tls'] = 'yes'
default['postfix']['main']['alias_maps'] = ["hash:#{node['postfix']['aliases_db']}"]
default['postfix']['main']['mailbox_size_limit'] = 0
default['postfix']['main']['recipient_delimiter'] = "+"
default['postfix']['main']['smtp_sasl_auth_enable'] = "no"
default['postfix']['main']['mynetworks'] = "127.0.0.0/8"
default['postfix']['main']['inet_interfaces'] = "loopback-only"
default['postfix']['main']['recipient_delimiter'] = '+'
default['postfix']['main']['smtp_sasl_auth_enable'] = 'no'
default['postfix']['main']['mynetworks'] = '127.0.0.0/8'
default['postfix']['main']['inet_interfaces'] = 'loopback-only'

# Conditional attributes
case node['platform']
when 'smartos'
default['postfix']['main']['smtpd_use_tls'] = "no"
default['postfix']['main']['smtp_use_tls'] = "no"
cafile = "/opt/local/etc/postfix/cacert.pem"
when "rhel"
cafile = "/etc/pki/tls/cert.pem"
default['postfix']['main']['smtpd_use_tls'] = 'no'
default['postfix']['main']['smtp_use_tls'] = 'no'
cafile = '/opt/local/etc/postfix/cacert.pem'
when 'rhel'
cafile = '/etc/pki/tls/cert.pem'
else
cafile = "/etc/postfix/cacert.pem"
cafile = '/etc/postfix/cacert.pem'
end

if node['postfix']['use_procmail']
default['postfix']['main']['mailbox_command'] = '/usr/bin/procmail -a "$EXTENSION"'
end

if node['postfix']['main']['smtpd_use_tls'] == "yes"
default['postfix']['main']['smtpd_tls_cert_file'] = "/etc/ssl/certs/ssl-cert-snakeoil.pem"
default['postfix']['main']['smtpd_tls_key_file'] = "/etc/ssl/private/ssl-cert-snakeoil.key"
if node['postfix']['main']['smtpd_use_tls'] == 'yes'
default['postfix']['main']['smtpd_tls_cert_file'] = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
default['postfix']['main']['smtpd_tls_key_file'] = '/etc/ssl/private/ssl-cert-snakeoil.key'
default['postfix']['main']['smtpd_tls_CAfile'] = cafile
default['postfix']['main']['smtpd_tls_session_cache_database'] = "btree:${data_directory}/smtpd_scache"
default['postfix']['main']['smtpd_tls_session_cache_database'] = 'btree:${data_directory}/smtpd_scache'
end

if node['postfix']['main']['smtp_use_tls'] == "yes"
if node['postfix']['main']['smtp_use_tls'] == 'yes'
default['postfix']['main']['smtp_tls_CAfile'] = cafile
default['postfix']['main']['smtp_tls_session_cache_database'] = "btree:${data_directory}/smtp_scache"
default['postfix']['main']['smtp_tls_session_cache_database'] = 'btree:${data_directory}/smtp_scache'
end

if node['postfix']['main']['smtp_sasl_auth_enable'] == "yes"
if node['postfix']['main']['smtp_sasl_auth_enable'] == 'yes'
default['postfix']['main']['smtp_sasl_password_maps'] = "hash:#{node['postfix']['conf_dir']}/postfix/sasl_passwd"
default['postfix']['main']['smtp_sasl_security_options'] = "noanonymous"
default['postfix']['sasl']['smtp_sasl_user_name'] = ""
default['postfix']['sasl']['smtp_sasl_passwd'] = ""
default['postfix']['main']['relayhost'] = ""
default['postfix']['main']['smtp_sasl_security_options'] = 'noanonymous'
default['postfix']['sasl']['smtp_sasl_user_name'] = ''
default['postfix']['sasl']['smtp_sasl_passwd'] = ''
default['postfix']['main']['relayhost'] = ''
end

# Default main.cf attributes according to `postconf -d`
#default['postfix']['main']['relayhost'] = ""
#default['postfix']['main']['milter_default_action'] = "tempfail"
#default['postfix']['main']['milter_protocol'] = "6"
#default['postfix']['main']['smtpd_milters'] = ""
#default['postfix']['main']['non_smtpd_milters'] = ""
#default['postfix']['main']['sender_canonical_classes'] = nil
#default['postfix']['main']['recipient_canonical_classes'] = nil
#default['postfix']['main']['canonical_classes'] = nil
#default['postfix']['main']['sender_canonical_maps'] = nil
#default['postfix']['main']['recipient_canonical_maps'] = nil
#default['postfix']['main']['canonical_maps'] = nil
# # Default main.cf attributes according to `postconf -d`
# default['postfix']['main']['relayhost'] = ''
# default['postfix']['main']['milter_default_action'] = 'tempfail'
# default['postfix']['main']['milter_protocol'] = '6'
# default['postfix']['main']['smtpd_milters'] = ''
# default['postfix']['main']['non_smtpd_milters'] = ''
# default['postfix']['main']['sender_canonical_classes'] = nil
# default['postfix']['main']['recipient_canonical_classes'] = nil
# default['postfix']['main']['canonical_classes'] = nil
# default['postfix']['main']['sender_canonical_maps'] = nil
# default['postfix']['main']['recipient_canonical_maps'] = nil
# default['postfix']['main']['canonical_maps'] = nil

# Master.cf attributes
default['postfix']['master']['submission'] = false
6 changes: 3 additions & 3 deletions files/default/tests/minitest/aliases_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# encoding: utf-8
# Copyright 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,11 +16,11 @@

require File.expand_path('../support/helpers', __FILE__)

describe "postfix::aliases" do
describe 'postfix::aliases' do
include Helpers::Postfix

it 'manages /etc/aliases' do
file("/etc/aliases").must_match(/^# This file is generated by Chef for/)
file('/etc/aliases').must_match(/^# This file is generated by Chef for/)
end

end
6 changes: 3 additions & 3 deletions files/default/tests/minitest/client_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# encoding: utf-8
# Copyright 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,9 +16,9 @@

require File.expand_path('../support/helpers', __FILE__)

describe "postfix::client" do
describe 'postfix::client' do
include Helpers::Postfix
it 'doesnt configure postfix because solo is unsupported' do
skip "Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo"
skip 'Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo'
end
end
12 changes: 6 additions & 6 deletions files/default/tests/minitest/default_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# encoding: utf-8
# Copyright 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,23 +16,23 @@

require File.expand_path('../support/helpers', __FILE__)

describe "postfix::default" do
describe 'postfix::default' do
include Helpers::Postfix

it 'installs the postfix package' do
package("postfix").must_be_installed
package('postfix').must_be_installed
end

it 'enables the postfix service' do
service("postfix").must_be_enabled
service('postfix').must_be_enabled
end

it 'starts the postfix service' do
service("postfix").must_be_running
service('postfix').must_be_running
end

it 'configures postfix main.cf' do
file("/etc/postfix/main.cf").must_match(/^# Generated by Chef for /)
file('/etc/postfix/main.cf').must_match(/^# Generated by Chef for /)
end

end
6 changes: 3 additions & 3 deletions files/default/tests/minitest/sasl_auth_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# encoding: utf-8
# Copyright 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,11 +15,11 @@
#
require File.expand_path('../support/helpers', __FILE__)

describe "postfix::sasl_auth" do
describe 'postfix::sasl_auth' do
include Helpers::Postfix

it 'manages /etc/postfix/sasl_passwd' do
file("/etc/postfix/sasl_passwd").must_match(/^# This file is generated by Chef for/)
file('/etc/postfix/sasl_passwd').must_match(/^# This file is generated by Chef for/)
end

end
6 changes: 3 additions & 3 deletions files/default/tests/minitest/server_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# encoding: utf-8
# Copyright 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,9 +15,9 @@
#
require File.expand_path('../support/helpers', __FILE__)

describe "postfix::server" do
describe 'postfix::server' do
include Helpers::Postfix
it 'doesnt configure postfix because solo is unsupported' do
skip "Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo"
skip 'Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo'
end
end
5 changes: 3 additions & 2 deletions files/default/tests/minitest/support/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# encoding: utf-8
# Copyright 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,11 +14,12 @@
# limitations under the License.
#

# helpers
module Helpers
# postfix
module Postfix
include MiniTest::Chef::Assertions
include MiniTest::Chef::Context
include MiniTest::Chef::Resources

end
end
91 changes: 46 additions & 45 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
name "postfix"
maintainer "Opscode, Inc."
maintainer_email "[email protected]"
license "Apache 2.0"
description "Installs and configures postfix for client or outbound relayhost, or to do SASL auth"
version "3.0.3"
recipe "postfix", "Installs and configures postfix"
recipe "postfix::sasl_auth", "Set up postfix to auth to a server with sasl"
recipe "postfix::aliases", "Manages /etc/aliases"
recipe "postfix::client", "Searches for the relayhost based on an attribute"
recipe "postfix::server", "Sets the mail_type attribute to master"
# encoding: utf-8
name 'postfix'
description 'Installs and configures postfix for client or outbound relayhost, or to do SASL auth'
maintainer 'Opscode, Inc.'
maintainer_email '[email protected]'
license 'Apache 2.0'
version '3.0.3'
recipe 'postfix', 'Installs and configures postfix'
recipe 'postfix::sasl_auth', 'Set up postfix to auth to a server with sasl'
recipe 'postfix::aliases', 'Manages /etc/aliases'
recipe 'postfix::client', 'Searches for the relayhost based on an attribute'
recipe 'postfix::server', 'Sets the mail_type attribute to master'

%w{ubuntu debian redhat centos amazon scientific smartos}.each do |os|
supports os
end

attribute "postfix/main",
:display_name => "postfix/main",
:description => "Hash of Postfix main.cf attributes",
:type => "hash"

attribute "postfix/aliases",
:display_name => "Postfix Aliases",
:description => "Hash of Postfix aliases mapping a name to a value. Example 'root' => '[email protected]'. See aliases man page for details.",
:type => "hash"

attribute "postfix/mail_type",
:display_name => "Postfix Mail Type",
:description => "Is this node a client or server?",
:default => "client"

attribute "postfix/smtp_sasl_user_name",
:display_name => "Postfix SMTP SASL Username",
:description => "User to auth SMTP via SASL",
:default => ""

attribute "postfix/smtp_sasl_passwd",
:display_name => "Postfix SMTP SASL Password",
:description => "Password for smtp_sasl_user_name",
:default => ""

attribute "postfix/relayhost_role",
:display_name => "Postfix Relayhost's role",
:description => "String containing the role name",
:default => "relayhost"

attribute "postfix/use_procmail",
:display_name => "Postfix Use procmail?",
:description => "Whether procmail should be used as the local delivery agent for a server",
:default => "no"
attribute 'postfix/main',
display_name: 'postfix/main',

This comment has been minimized.

Copy link
@MiniCodeMonkey

MiniCodeMonkey Nov 12, 2013

Am I the only one that receives this error now?

[2013-11-12T15:47:30+00:00] FATAL: SyntaxError: compile error /tmp/vagrant-chef-1/chef-solo-1/cookbooks/postfix/metadata.rb:19: syntax error, unexpected ':', expecting $end display_name: 'postfix/main', ^

This comment has been minimized.

Copy link
@mrjcleaver

This comment has been minimized.

Copy link
@arielpts

arielpts Nov 27, 2013

It's because of your Ruby version, 1.8.7.

@someara,
Please use the rocket syntax (=>) instead of the new syntax (:) instead!

description: 'Hash of Postfix main.cf attributes',
type: 'hash'

attribute 'postfix/aliases',
display_name: 'Postfix Aliases',
description: "Hash of Postfix aliases mapping a name to a value. Example 'root' => '[email protected]'. See aliases man page for details.",
type: 'hash'

attribute 'postfix/mail_type',
display_name: 'Postfix Mail Type',
description: 'Is this node a client or server?',
default: 'client'

attribute 'postfix/smtp_sasl_user_name',
display_name: 'Postfix SMTP SASL Username',
description: 'User to auth SMTP via SASL',
default: ''

attribute 'postfix/smtp_sasl_passwd',
display_name: 'Postfix SMTP SASL Password',
description: 'Password for smtp_sasl_user_name',
default: ''

attribute 'postfix/relayhost_role',
display_name: "Postfix Relayhost's role",
description: 'String containing the role name',
default: 'relayhost'

attribute 'postfix/use_procmail',
display_name: 'Postfix Use procmail?',
description: 'Whether procmail should be used as the local delivery agent for a server',
default: 'no'
12 changes: 6 additions & 6 deletions recipes/aliases.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# encoding: utf-8
# Copyright:: Copyright (c) 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,14 +14,14 @@
# limitations under the License.
#

include_recipe "postfix"
include_recipe 'postfix'

execute "update-postfix-aliases" do
command "newaliases"
execute 'update-postfix-aliases' do
command 'newaliases'
action :nothing
end

template node['postfix']['aliases_db'] do
source "aliases.erb"
notifies :run, "execute[update-postfix-aliases]"
source 'aliases.erb'
notifies :run, 'execute[update-postfix-aliases]'
end
Loading

0 comments on commit b113d5b

Please sign in to comment.