From cf6b8e9eac809bca6e558131a56ba55accb3b46c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 18 Jun 2016 13:41:19 -0300 Subject: Adds apache::site::user --- manifests/site.pp | 54 ++++++++++++------------------------------------ manifests/site/user.pp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 41 deletions(-) create mode 100644 manifests/site/user.pp (limited to 'manifests') diff --git a/manifests/site.pp b/manifests/site.pp index 2c76a01..6af019e 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -35,7 +35,6 @@ define apache::site( $hosting_domain = hiera('apache::site::domain', $::domain) ) { - $vhost = $filename ? { '' => "${name}", default => "$filename", @@ -61,46 +60,19 @@ define apache::site( } } - if $mpm == true and $manage_user == true and $user != 'root' { - if $ensure == present { - if !defined(Group[$gid]) { - group { "$gid": - ensure => present, - } - } - - if !defined(User["$user"]) { - user::manage { "$user": - tag => "virtual", - password => $password, - gid => $gid, - comment => $comment, - ticket => $ticket, - groups => $groups, - sshkey => $sshkey, - sshkey_options => $sshkey_options, - shell => $shell, - ensure => present, - require => Group[$gid], - } - } - } - else { - if !defined(User["$user"]) { - user::manage { "$user": - tag => "virtual", - password => $password, - ensure => absent, - } - } - - if !defined(Group[$gid]) { - group { "$gid": - ensure => absent, - require => User[$user], - } - } - } + apache::site::user { $name: + ensure => $ensure, + mpm => $mpm, + manage_user => $manage_user, + user => $user, + password => $password, + gid => $gid, + comment => $comment, + ticket => $ticket, + groups => $groups, + sshkey => $sshkey, + sshkey_options => $sshkey_options, + shell => $shell, } if $ssl == true { diff --git a/manifests/site/user.pp b/manifests/site/user.pp new file mode 100644 index 0000000..ec5866c --- /dev/null +++ b/manifests/site/user.pp @@ -0,0 +1,56 @@ +define apache::site::user( + $ensure = present, + $mpm = true, + $manage_user = true, + $user = $name, + $gid = $name, + $ticket = false, + $password = '*', + $comment = '', + $sshkey = absent, + $sshkey_options = [], + $groups = '', + $shell = '/bin/false', +){ + if $mpm == true and $manage_user == true and $user != 'root' { + if $ensure == present { + if !defined(Group[$gid]) { + group { "$gid": + ensure => present, + } + } + + if !defined(User["$user"]) { + user::manage { "$user": + tag => "virtual", + password => $password, + gid => $gid, + comment => $comment, + ticket => $ticket, + groups => $groups, + sshkey => $sshkey, + sshkey_options => $sshkey_options, + shell => $shell, + ensure => present, + require => Group[$gid], + } + } + } + else { + if !defined(User["$user"]) { + user::manage { "$user": + tag => "virtual", + password => $password, + ensure => absent, + } + } + + if !defined(Group[$gid]) { + group { "$gid": + ensure => absent, + require => User[$user], + } + } + } + } +} -- cgit v1.2.3