* (#7) Add a new defined type to manage users for PVE WebGUI.
This commit is contained in:
parent
980a3e3951
commit
b27e15f8f6
@ -3,9 +3,11 @@
|
|||||||
* Add a variable to choose to keep PVE enterprise repo for the subscribers.
|
* Add a variable to choose to keep PVE enterprise repo for the subscribers.
|
||||||
* (#4) Add an access control list for PveProxy.
|
* (#4) Add an access control list for PveProxy.
|
||||||
* (#4) Add a new class to manage Proxmox's service (proxmox::hypervisor::service).
|
* (#4) Add a new class to manage Proxmox's service (proxmox::hypervisor::service).
|
||||||
* (#6) Add a new defined class to manage groups for PVE WebGUI.
|
* (#6) Add a new defined type to manage groups for PVE WebGUI.
|
||||||
|
* (#7) Add a new defined type to manage users for PVE WebGUI.
|
||||||
* Update the README.md file for (#6) group defined type.
|
* Update the README.md file for (#6) group defined type.
|
||||||
* Add a test for (#6) group defined type.
|
* Add a test for (#6) group defined type.
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
### 0.0.2 - 2014/01/08
|
### 0.0.2 - 2014/01/08
|
||||||
|
57
manifests/hypervisor/user.pp
Normal file
57
manifests/hypervisor/user.pp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# == Define: proxmox::hypervisor::user
|
||||||
|
#
|
||||||
|
# Manage users allowed to WebGUI
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*user*]
|
||||||
|
# _default_: +$title+, the title/name of the ressource
|
||||||
|
#
|
||||||
|
# Is the username.
|
||||||
|
#
|
||||||
|
# [*group*]
|
||||||
|
# _default_: +undef+
|
||||||
|
#
|
||||||
|
# The group list for the user.
|
||||||
|
#
|
||||||
|
# [*permission_file*]
|
||||||
|
# _default_: +/etc/pve/user.cfg+
|
||||||
|
#
|
||||||
|
# The file where group's informations are stored.
|
||||||
|
#
|
||||||
|
define proxmox::hypervisor::user ( $user = $title, $group = '', $permission_file = '/etc/pve/user.cfg' ) {
|
||||||
|
|
||||||
|
# Manage user only if Proxmox is available
|
||||||
|
if $::is_proxmox == 'true' {
|
||||||
|
|
||||||
|
## Work with an if/else test because the user must be create before adding
|
||||||
|
# it to a group ...
|
||||||
|
|
||||||
|
# If a group was set
|
||||||
|
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",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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}",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} # Public ressource: proxmox::hypervisor::user
|
Loading…
Reference in New Issue
Block a user