From 4eb0027c721753c084cda53a3c388a2ea234e361 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Mon, 19 Jan 2015 16:39:08 +0100 Subject: [PATCH] * Add a defined type to manage IPMI's user. --- CHANGELOG.md | 1 + manifests/ressource/user.pp | 57 +++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 manifests/ressource/user.pp diff --git a/CHANGELOG.md b/CHANGELOG.md index 79860fb..bce3ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,3 +10,4 @@ * Ensure needed modules load at boot time * Load one needed module (for Debian) one time * Update README.md file. +* Add a defined type to manage IPMI's user. diff --git a/manifests/ressource/user.pp b/manifests/ressource/user.pp new file mode 100644 index 0000000..c28c1e8 --- /dev/null +++ b/manifests/ressource/user.pp @@ -0,0 +1,57 @@ +# == Define: ipmi::ressource::user +# +# Manage IPMI's user +# +# === Parameters +# +# [*user*] +# _default_: +$title+, the title/name of the ressource/user +# +# The username. +# +# [*password*] +# _default_: +undef+ +# +# The user's password. +# +# [*user_id*] +# _default_: +2+ +# +# The user ID. This defined type don't create a new user. +# +# [*channel_id*] +# _default_: +1+ +# +# The channel ID. On most BMC, the main channel (with lan) is the first one. +# +# [*state*] +# _default_: +enable+ +# +# Ensure this user is +enable+ or +disable+. +# +define ipmi::ressource::user ( $user = $title, $password, $user_id = '2', $channel_id = '1', $state = 'enable' ) { + Exec { + path => ['/bin','/sbin','/usr/bin','/usr/sbin'], + logoutput => 'on_failure', + } + + # Rename the user with the $user_id + exec { "Rename IPMI UserID ${user_id} to ${user}": + command => "ipmitool user set name ${user_id} ${name}", + unless => "ipmitool user list ${channel_id} | grep ${user} | grep ${user_id}", + } + -> + # Change the password + exec { "IPMI ${user} password": + command => "ipmitool user set password ${user_id} ${password}", + unless => "ipmitool user test ${user_id} 16 ${password}", + notify => Exec["Enable IPMI user ${user}"], + } + -> + # Enable the IPMI's user + exec { "Enable IPMI user ${user}": + command => "ipmitool user ${state} ${user_id}", + refreshonly => true, + } + +} # Public ressource: ipmi::ressource::user