From 7a9f5db6cf16bdb074e2ea85b7a3f626668c198f Mon Sep 17 00:00:00 2001 From: karim hamidou Date: Sat, 9 Nov 2013 20:42:39 +0100 Subject: [PATCH] WIP - refactoring puppet files --- manifests/default.pp | 79 +++++++++-------- puppet_modules/postfix/manifests/.init.pp.swo | Bin 0 -> 12288 bytes puppet_modules/postfix/manifests/init.pp | 82 ++++++++++++++++++ .../postfix/templates/postfix_vhosts.erb | 1 + .../postfix/templates/postfix_vmaps.erb | 1 + 5 files changed, 123 insertions(+), 40 deletions(-) create mode 100644 puppet_modules/postfix/manifests/.init.pp.swo create mode 100644 puppet_modules/postfix/manifests/init.pp create mode 100644 puppet_modules/postfix/templates/postfix_vhosts.erb create mode 100644 puppet_modules/postfix/templates/postfix_vmaps.erb diff --git a/manifests/default.pp b/manifests/default.pp index d81498c..fc9f7e8 100644 --- a/manifests/default.pp +++ b/manifests/default.pp @@ -1,35 +1,57 @@ +# this is the main config file for puppet + +$server_name = "kitebox.dev" + exec {"apt-get update": path => ["/usr/bin/", "/usr/sbin"], } -$packages = ["postfix", "python", "bpython"] +$packages = ["python", "bpython"] + +$kite_gid = "5000" +$kite_uid = "500" group { "kite": - ensure => "present" + ensure => "present", + gid => $kite_gid } package { $packages: ensure => present, - require => Exec["apt-get update"] -} - -service {'postfix': - ensure => running, - enable => true, - hasstatus => true, - hasrestart => true, - require => Package["postfix"] + require => Exec["apt-get update"], } user { "kite": require => Group["kite"], ensure => present, gid => "kite", + uid => $kite_uid, shell => "/bin/true", home => "/home/kite", managehome => true, } +# comes from http://serverfault.com/a/524188 +class hostname ($fqdn) { + file { "/etc/hostname": + ensure => present, + owner => root, + group => root, + mode => 644, + content => "$fqdn\n", + notify => Exec["set-hostname"], + } + + exec { "set-hostname": + command => "/bin/hostname -F /etc/hostname", + unless => "/usr/bin/test `hostname` = `/bin/cat /etc/hostname`", + } +} + +class {'hostname': + fqdn => $server_name +} + file { "/var/kitemail": require => User["kite"], ensure => "directory", @@ -37,41 +59,18 @@ file { "/var/kitemail": group => "kite", } - # nginx class {'nginx': - server_name => "example.com", + server_name => $server_name, appdir => "/home/kite/app", require => Exec["apt-get update"] } -#nginx::resource::location {'kiteapp': -# ensure => present, -# www_root => '/home/kite/app', -# location => '/', -# vhost => 'kiteapp' -#} - -# code comes from : https://bitbucket.org/daks/puppet-postfix/src/2e93e657cab6/manifests/definitions/config.pp -define postfix_config ($ensure = present, $value, $nonstandard = false) { - exec {"postconf -e ${name}='${value}'": - path => ["/usr/bin/", "/usr/sbin"], - unless => $nonstandard ? { - false => "test \"x$(postconf -h ${name})\" == 'x${value}'", - true => "test \"x$(egrep '^${name} ' /etc/postfix/main.cf | cut -d= -f2 | cut -d' ' -f2)\" == 'x${value}'", - }, - notify => Service["postfix"], - require => Package["postfix"] - } -} - -postfix_config { 'home_mailbox': - value => "Maildir/", -} - -# deliver a copy of all the received emails to user kite -postfix_config { 'always_bcc': - value => "kite", +# postfix +class {'postfix': + server_name => $server_name, + appdir => "/home/kite/app", + require => Exec["apt-get update"] } # deploy files diff --git a/puppet_modules/postfix/manifests/.init.pp.swo b/puppet_modules/postfix/manifests/.init.pp.swo new file mode 100644 index 0000000000000000000000000000000000000000..5bae71487c37dabbd153da376c972bc6ea3c3441 GIT binary patch literal 12288 zcmeI2J!~9B6vrnN0b+t3KtO|doKHF%d|qSgVsX+LiAX^yBB3BsK;W3$oxK}*znGnM z&N|MB0{1{eXxu}CD5#TAKud{4LxDm?K|_NC|JmL1o#U@0g2tMaes?#wZ)e{7&zmi#v%4wxuKJ& zxa+J-Eu17v5~15+>}7#SodiAjvhRdElDc~jy#UweTKl`;+z$$P*3Y=vt%P%j@ zR$ibdpLpwj9<;Vr0jq#jz$#!BunJfOtO8a6tH23RKqsfzKZxTYa0Q$y!JECT0#*U5 zfK|XMU=^?mSOu&CRspMkRlq7>6*wUZaF4Omry1)!jDYa}fAcqh@245N4ZZ|hUL z30wfLffvCv`0H`TegQYZ4e&Ym3_K5hI?LD&h`>eg_hXEG3>0`BJO|E!DR2h-HpSSF z;5N7gJ_QoEpaUApndKJg$R-4mpQD{#vr5po%%q+`lbSehXU7YYxI15vD{ziB*pQ>YE;igzmI z=#_U1Z;X`^A7oPHj$V`jY#gE8-BWrSAy3jt^Mvc3>5^cWrON5Z$f+z)(MZu68H>Jf zX^@YIKInj6n|C`5O|*!#>0XO43Ah$>wb6OOk#M<3i$Zm3^Wz}8D$bHzYZb@3)Y?QB zUyq=UnS_ZOKH`LH|D8)coM}w|2cPnOEBkaBXI84YmTt4Lw6s(PJ(6jhUmH^Cj0f$m z^x9@Nk!8$CGftET>o2>9{@~cLeuX&y8D?P{{gn&gQ1^N~?KKaWw)}y^BR5N>6Zebg z>4@;1UL1=2)avnGmwk44DvnZgueZg77I}NTzg`T_qa!EmGTiW_!V)}00}~Mf&jr}; z=VTTjB_@l(8{A#z-N~Afk6^6KRTdYsw2rDS#&kGdr>04y6$)d%C^ZfM)3r*!Iw!hH zBvgB^I*52EhE&^IF^mw4u1_D5n`x?hEvoy=yR90`(Vo9np;n7({pui3>0zyur5M({ z`aDRBqC6hjOoUl3RPRwa{INY{5zaEFc@Whoj<60Rk1LN}r2!j{Ms&~RvUq5sXciuc zkw>lCIH+Qq@PscTL3gFmTvbGAX6iX5N~9>K3slY3!26`9twM|W(&1TbHJ-prC{prO z98!~dS|@4KL5UgNlE^_k~hx zq_QZIQMY&m`>EM2X)xM*_OF|f#%sGGGZRo!tQqX;)$(InR-4^6=4E0VW^TZdMx~52 zS2be`)i!GY^Tm?{i`z^Qn>9ZMa$`SMgsPzNlK?Ig5)ZRxeoSO4Zxc$AbSdh}s86ZT HS;GDWi!k0- literal 0 HcmV?d00001 diff --git a/puppet_modules/postfix/manifests/init.pp b/puppet_modules/postfix/manifests/init.pp new file mode 100644 index 0000000..5ac38ec --- /dev/null +++ b/puppet_modules/postfix/manifests/init.pp @@ -0,0 +1,82 @@ +# a class for installing and configuring a basic nginx setup + +class postfix ($server_name, $appdir) { + $packages = ["postfix"] + + package { $packages: + ensure => present, + } + + service {'postfix': + ensure => running, + enable => true, + hasstatus => true, + hasrestart => true, + require => Package["postfix"], + } + + # code comes from : https://bitbucket.org/daks/puppet-postfix/src/2e93e657cab6/manifests/definitions/config.pp + define postfix_config ($ensure = present, $value, $nonstandard = false) { + exec {"postconf -e ${name}='${value}'": + path => ["/usr/bin/", "/usr/sbin"], + unless => $nonstandard ? { + false => "test \"x$(postconf -h ${name})\" == 'x${value}'", + true => "test \"x$(egrep '^${name} ' /etc/postfix/main.cf | cut -d= -f2 | cut -d' ' -f2)\" == 'x${value}'", + }, + notify => Service["postfix"], + require => Package["postfix"] + } + } + + postfix_config { 'home_mailbox': + value => "Maildir/", + } + + postfix_config { 'virtual_mailbox_domains': + value => "/etc/postfix/vhosts", + } + + postfix_config { 'virtual_mailbox_base': + value => "/home/kite", + } + + postfix_config { 'virtual_mailbox_maps' : + value => "hash:/etc/postfix/vmaps" + } + + postfix_config { 'virtual_minimum_uid': + value => "500", + } + + postfix_config { 'virtual_uid_maps': + value => "static:5000", + } + + postfix_config { 'virtual_gid_maps': + value => "static:5000", + } + + file {"/etc/postfix/vhosts": + owner => "root", + group => "root", + content => template('postfix/postfix_vhosts.erb'), + } + + file {"/etc/postfix/vmaps": + owner => "root", + group => "root", + content => template('postfix/postfix_vmaps.erb'), + } + + exec {"postmap /etc/postfix/vmaps": + path => ["/usr/bin/", "/usr/sbin"], + require => File["/etc/postfix/vmaps"], + notify => Service["postfix"], + } + + # deliver a copy of all the received emails to user kite + #postfix_config { 'always_bcc': + # value => "kite", + #} + +} diff --git a/puppet_modules/postfix/templates/postfix_vhosts.erb b/puppet_modules/postfix/templates/postfix_vhosts.erb new file mode 100644 index 0000000..d4e436b --- /dev/null +++ b/puppet_modules/postfix/templates/postfix_vhosts.erb @@ -0,0 +1 @@ +<%= server_name %> diff --git a/puppet_modules/postfix/templates/postfix_vmaps.erb b/puppet_modules/postfix/templates/postfix_vmaps.erb new file mode 100644 index 0000000..18c1e93 --- /dev/null +++ b/puppet_modules/postfix/templates/postfix_vmaps.erb @@ -0,0 +1 @@ +kite@<%= server_name %> <%= server_name %>/kite -- 2.43.0