Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrections #27

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*~
*.gem
*.rbc
*.swp
.bundle
.config
coverage
Expand All @@ -18,3 +19,6 @@ tmp
_yardoc
doc/
Gemfile.lock
spec/fixtures/manifests/
spec/fixtures/modules/
vendor/
104 changes: 104 additions & 0 deletions files/build.aug
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,107 @@ let block_newlines (entry:lens) (comment:lens) =
let named_block (kw:regexp) (entry:lens) = [ key kw . block entry . eol ]


(************************************************************************
* Group: COMBINATORICS
************************************************************************)

(************************************************************************
* View: combine_two_ord
* Combine two lenses, ensuring first lens is first
*
* Parameters:
* a:lens - the first lens
* b:lens - the second lens
************************************************************************)
let combine_two_ord (a:lens) (b:lens) = a . b

(************************************************************************
* View: combine_two
* Combine two lenses
*
* Parameters:
* a:lens - the first lens
* b:lens - the second lens
************************************************************************)
let combine_two (a:lens) (b:lens) =
combine_two_ord a b | combine_two_ord b a

(************************************************************************
* View: combine_two_opt_ord
* Combine two lenses optionally, ensuring first lens is first
* (a, and optionally b)
*
* Parameters:
* a:lens - the first lens
* b:lens - the second lens
************************************************************************)
let combine_two_opt_ord (a:lens) (b:lens) = a . b?

(************************************************************************
* View: combine_two_opt
* Combine two lenses optionally
* (either a, b, or both, in any order)
*
* Parameters:
* a:lens - the first lens
* b:lens - the second lens
************************************************************************)
let combine_two_opt (a:lens) (b:lens) =
combine_two_opt_ord a b | combine_two_opt_ord b a

(************************************************************************
* View: combine_three_ord
* Combine three lenses, ensuring first lens is first
* (a followed by either b, c, in any order)
*
* Parameters:
* a:lens - the first lens
* b:lens - the second lens
* c:lens - the third lens
************************************************************************)
let combine_three_ord (a:lens) (b:lens) (c:lens) =
combine_two_ord a (combine_two b c)

(************************************************************************
* View: combine_three
* Combine three lenses
*
* Parameters:
* a:lens - the first lens
* b:lens - the second lens
* c:lens - the third lens
************************************************************************)
let combine_three (a:lens) (b:lens) (c:lens) =
combine_three_ord a b c
| combine_three_ord b a c
| combine_three_ord c b a


(************************************************************************
* View: combine_three_opt_ord
* Combine three lenses optionally, ensuring first lens is first
* (a followed by either b, c, or any of them, in any order)
*
* Parameters:
* a:lens - the first lens
* b:lens - the second lens
* c:lens - the third lens
************************************************************************)
let combine_three_opt_ord (a:lens) (b:lens) (c:lens) =
combine_two_opt_ord a (combine_two_opt b c)

(************************************************************************
* View: combine_three_opt
* Combine three lenses optionally
* (either a, b, c, or any of them, in any order)
*
* Parameters:
* a:lens - the first lens
* b:lens - the second lens
* c:lens - the third lens
************************************************************************)
let combine_three_opt (a:lens) (b:lens) (c:lens) =
combine_three_opt_ord a b c
| combine_three_opt_ord b a c
| combine_three_opt_ord c b a

30 changes: 24 additions & 6 deletions files/dovecot.aug
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ let value = any . (Rx.space . any)*
(* View: command_start *)
let command_start = Util.del_str "!"

(* View: block_args
Map block arguments after block name and before "{" *)
let block_args = Sep.space . store /([A-Za-z0-9\/\\_-]+|\"[A-Za-z0-9 ]*\")/

(******************************************************************
* Group: ENTRIES
Expand All @@ -82,7 +79,28 @@ let entry = [ indent . key keys. eq . (Sep.opt_space . store value)? . eol ]
Map commands started with "!". *)
let command = [ command_start . key commands . Sep.space . store Rx.fspath . eol ]

let mailbox = [ indent . key /mailbox/ . block_args? . Build.block_newlines (entry) comment . eol ]
(*
View: dquote_spaces
Make double quotes mandatory if value contains spaces,
and optional if value doesn't contain spaces.

Based off Quote.dquote_spaces

Parameters:
lns1:lens - the lens before
lns2:lens - the lens after
*)
let dquote_spaces (lns1:lens) (lns2:lens) =
(* bare has no spaces, and is optionally quoted *)
let bare = Quote.do_dquote_opt (store /[^" \t\n]+/)
(* quoted has at least one space, and must be quoted *)
in let quoted = Quote.do_dquote (store /[^"\n]*[ \t]+[^"\n]*/)
in [ lns1 . bare . lns2 ] | [ lns1 . quoted . lns2 ]

let mailbox = indent
. dquote_spaces
(key /mailbox/ . Sep.space)
(Build.block_newlines (entry) comment . eol)

let block_ldelim_newlines_re = /[ \t]+\{([ \t\n]*\n)?/

Expand All @@ -96,7 +114,7 @@ let block_newlines (entry:lens) (comment:lens) =
Map block enclosed in brackets recursively.
Block may be indented and have optional argument.
Block body may have entries, comments, empty lines, and nested blocks recursively. *)
let rec block = [ indent . key block_names . block_args? . block_newlines (entry|block|mailbox) comment . eol ]
let rec block = [ indent . key block_names . (Sep.space . Quote.do_dquote_opt (store /[\/A-Za-z0-9_-]+/))? . block_newlines (entry|block|mailbox) comment . eol ]


(******************************************************************
Expand All @@ -109,7 +127,7 @@ let lns = (comment|empty|entry|command|block)*

(* Variable: filter *)
let filter = incl "/etc/dovecot/dovecot.conf"
. (incl "/etc/dovecot/conf.d/*")
. (incl "/etc/dovecot/conf.d/*.conf")
. Util.stdexcl

let xfm = transform lns filter
1 change: 0 additions & 1 deletion files/util.aug
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,3 @@ Variable: stdexcl
(excl "*.bak") .
(excl "*.old") .
(excl "#*#")

51 changes: 32 additions & 19 deletions manifests/config/augeas.pp
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
class dovecot::config::augeas {
file { '/usr/share/augeas/lenses/dist/dovecot.aug':
ensure => present,
source => 'puppet:///modules/dovecot/dovecot.aug',
owner => root,
group => root,
mode => '0644'
}

file { '/usr/share/augeas/lenses/dist/build.aug':
ensure => present,
source => 'puppet:///modules/dovecot/build.aug',
owner => root,
group => root,
mode => '0644'
case $::lsbdistcodename {
/squeeze|squeeze-lts|wheezy/: {
$install_lenses = true
}
/lucid|precise|trusty|utopic/: {
$install_lenses = true
}
default: { $install_lenses = false }
}

file { '/usr/share/augeas/lenses/dist/util.aug':
ensure => present,
source => 'puppet:///modules/dovecot/util.aug',
owner => root,
group => root,
mode => '0644'
if $install_lenses {
file { '/usr/share/augeas/lenses/dist/dovecot.aug':
ensure => present,
source => 'puppet:///modules/dovecot/dovecot.aug',
owner => root,
group => root,
mode => '0644'
}

file { '/usr/share/augeas/lenses/dist/build.aug':
ensure => present,
source => 'puppet:///modules/dovecot/build.aug',
owner => root,
group => root,
mode => '0644'
}

file { '/usr/share/augeas/lenses/dist/util.aug':
ensure => present,
source => 'puppet:///modules/dovecot/util.aug',
owner => root,
group => root,
mode => '0644'
}
}
}
2 changes: 1 addition & 1 deletion manifests/config/dovecotcfmulti.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Augeas {
context => "/files/etc/dovecot/${config_file}",
notify => Service['dovecot'],
require => Exec['dovecot'],
require => Package['dovecot'],
}

augeas { "dovecot /etc/dovecot/${config_file} ${name}":
Expand Down
2 changes: 1 addition & 1 deletion manifests/config/dovecotcfsingle.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Augeas {
context => "/files/etc/dovecot/${config_file}",
notify => Service['dovecot'],
require => Exec['dovecot'],
require => Package['dovecot'],
}

case $ensure {
Expand Down
20 changes: 10 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
class dovecot {

Package <| tag == 'dovecot' |> ->
Augeas <| tag == 'dovecot' |> ->
Service <| tag == 'dovecot' |>

$mailpackages = $::osfamily ? {
default => ['dovecot-imapd', 'dovecot-pop3d'],
'Debian' => ['dovecot-imapd', 'dovecot-pop3d'],
'Redhat' => ['dovecot',]
}

ensure_packages([$mailpackages])

exec { 'dovecot':
command => 'echo "dovecot packages are installed"',
path => '/usr/sbin:/bin:/usr/bin:/sbin',
logoutput => true,
refreshonly => true,
require => Package[$mailpackages],
package {[$mailpackages]:
ensure => present,
tag => 'dovecot',
}


service { 'dovecot':
ensure => running,
require => Exec['dovecot'],
enable => true
enable => true,
tag => 'dovecot',
}
}
6 changes: 3 additions & 3 deletions manifests/ldap.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
mode => '0600',
owner => root,
group => dovecot,
before => Exec['dovecot'],
before => Package['dovecot'],
}

file { '/etc/dovecot/dovecot-ldap-userdb.conf.ext':
Expand All @@ -30,7 +30,7 @@
mode => '0600',
owner => root,
group => dovecot,
before => Exec['dovecot'],
before => Package['dovecot'],
}

file { '/etc/dovecot/conf.d/auth-ldap.conf.ext':
Expand All @@ -39,7 +39,7 @@
mode => '0600',
owner => root,
group => dovecot,
before => Exec['dovecot'],
before => Package['dovecot'],
}

dovecot::config::dovecotcfmulti { 'ldapauth':
Expand Down
3 changes: 2 additions & 1 deletion manifests/lmtp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
package { $package_name:
ensure => installed,
alias => 'dovecot-lmtpd',
before => Exec['dovecot']
before => Package['dovecot'],
tag => 'dovecot',
}

if $dovecot::base::protocols !~ /lmtp/ {
Expand Down
2 changes: 1 addition & 1 deletion manifests/mail.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
mode => '0644',
owner => root,
group => root,
before => Exec['dovecot'],
require => Package['dovecot'],
}
}

Expand Down
10 changes: 5 additions & 5 deletions manifests/managesieved.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
}

package { $package_name :
ensure => installed,
before => Exec['dovecot'],
require => Package['dovecot'],
alias => 'dovecot-managesieved',
ensure => installed,
require => Package['dovecot'],
alias => 'dovecot-managesieved',
tag => 'dovecot',
}

dovecot::config::dovecotcfmulti { 'managesieved-plugin':
config_file => 'conf.d/20-managesieve.conf',
changes => [
"set service[1] 'managesieve'",
"set service[2] 'managesieve-login'",
],
],
}

}
2 changes: 1 addition & 1 deletion manifests/passwdfile.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
content => template('dovecot/auth-passwdfile.conf.ext'),
mode => '0600',
owner => root,
before => Exec['dovecot'],
before => Package['dovecot'],
}

dovecot::config::dovecotcfmulti { 'passwdfileauth':
Expand Down
5 changes: 2 additions & 3 deletions manifests/postgres.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
owner => root,
group => dovecot,
require => Package['dovecot-pgsql'],
before => Exec['dovecot'],
}

package {'dovecot-pgsql':
ensure => installed,
before => Exec['dovecot'],
notify => Service['dovecot']
notify => Service['dovecot'],
tag => 'dovecot',
}

dovecot::config::dovecotcfmulti { 'sqlauth':
Expand Down
Loading