From f4ae1521349c498800b66d0076b235d770b5cffb Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 14 Jan 2015 21:33:08 +0100 Subject: [PATCH] Add defaults attributes for some ressources for the defined types group and user. --- manifests/hypervisor/group.pp | 16 +++++++++++----- manifests/hypervisor/user.pp | 8 +++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/manifests/hypervisor/group.pp b/manifests/hypervisor/group.pp index a76c636..7ec550b 100644 --- a/manifests/hypervisor/group.pp +++ b/manifests/hypervisor/group.pp @@ -31,19 +31,28 @@ # define proxmox::hypervisor::group ( $group = $title, $role, $acl_path = '/', $permission_file = '/etc/pve/user.cfg', $users = '' ) { + File { + owner => root, + group => www-data, + mode => 0640, + } + + Exec { + path => ['/bin','/sbin','/usr/bin','/usr/sbin'], + logoutput => 'on_failure', + } + # Manage group only if Proxmox is available if $::is_proxmox == 'true' { # Create the group in Proxmox exec { "create_${group}_group": - path => ['/bin','/sbin','/usr/bin','/usr/sbin'], command => "pveum groupadd ${group}", unless => "grep '^group:${group}' ${permission_file}", } -> # Define the permission exec { "add_${group}_permission": - path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ], command => "pveum aclmod ${acl_path} -group ${group} -role ${role}", unless => "grep '@${group}' ${permission_file}", } @@ -58,9 +67,6 @@ define proxmox::hypervisor::group ( $group = $title, $role, $acl_path = '/', $pe if ! defined(File["${permission_file}"]) { file { "${permission_file}": ensure => present, - owner => root, - group => www-data, - mode => 0640, } } diff --git a/manifests/hypervisor/user.pp b/manifests/hypervisor/user.pp index 4fb3655..219f4a0 100644 --- a/manifests/hypervisor/user.pp +++ b/manifests/hypervisor/user.pp @@ -21,6 +21,11 @@ # define proxmox::hypervisor::user ( $user = $title, $group = '', $permission_file = '/etc/pve/user.cfg' ) { + Exec { + path => ['/bin','/sbin','/usr/bin','/usr/sbin'], + logoutput => 'on_failure', + } + # Manage user only if Proxmox is available if $::is_proxmox == 'true' { @@ -31,14 +36,12 @@ define proxmox::hypervisor::user ( $user = $title, $group = '', $permission_file if empty($group) == false { # Create the user in Proxmox exec { "add_${user}_user": - path => ['/bin','/sbin','/usr/bin','/usr/sbin'], command => "pveum useradd ${user}", unless => "grep '^user:${user}' ${permission_file}", } -> # Then add this user to a group exec { "add_${user}_to_${group}": - path => ['/bin', '/sbin', '/usr/bin', '/usr/sbin' ], command => "pveum usermod ${user} -group ${group}", # The grep command should return 2 lines (minium) that match the pattern unless => "test `grep '${user}' -c ${permission_file}` -ge 2", @@ -47,7 +50,6 @@ define proxmox::hypervisor::user ( $user = $title, $group = '', $permission_file else { # Create the user in Proxmox exec { "add_${user}_user": - path => ['/bin','/sbin','/usr/bin','/usr/sbin'], command => "pveum useradd ${user}", unless => "grep '^user:${user}' ${permission_file}", }