Commit 3165734d authored by Victor Penso's avatar Victor Penso
Browse files

[FEATURE] add support for creating user accounts by attributes

parent 3cc3390a
default_unless[:sys][:accounts] = Hash.new
Create user accounts.
`attributes/accounts.rb`
`recipes/accounts.rb`
`tests/roles/sys_accounts_test.rb`
**Attributes**
All attributes in `node.sys.accounts`, where each key is a user
name with a configuration value. It wraps the `user` resources,
thus supports all of its options.
**Example**
:sys => {
:accounts => {
:kirk => {
:uid => 1111,
:shell => '/bin/bash'
},
:spock => {
:system => true
},
:sulu => {
:action => :remove
},
:uhura => {
:home => '/home/uhura',
:password => '$6$M4oxTop4k/2kd1nmrsiZdFfzKr1Q/',
:supports => {
:manage_home => true
}
}
}
}
......@@ -3,5 +3,5 @@ maintainer_email "hpc@gsi.de"
license "Apache 2.0"
description "System Software configuration and maintenance"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.13.3"
version "0.14.0"
#
# Cookbook Name:: sys
# Recipe:: accounts
#
# Copyright 2013, Victor Penso
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
unless node.sys.accounts.empty?
package 'ruby-shadow'
node.sys.accounts.each do |name,account|
# This is a wrapper to call the `user` resource by attributes
user name do
uid account[:uid] if account.has_key?(:uid)
gid account[:gid] if account.has_key?(:gid)
home account[:home] if account.has_key?(:home)
shell account[:shell] if account.has_key?(:shell)
password account[:password] if account.has_key?(:password)
comment account[:comment] if account.has_key?(:comment)
supports( account[:supports]) if account.has_key?(:supports)
system true if account.has_key?(:system) and account[:system]
action account[:action] if account.has_key?(:action)
end
end
end
......@@ -18,8 +18,10 @@
#
# the order of recipes matters!
%w(apt serial boot cgroups control sudo time
network nsswitch nis hosts
resolv mail fuse pam ssh banner tmp autofs ).each do |recipe|
%w(
apt serial boot cgroups control accounts sudo
time network nsswitch nis hosts resolv mail
fuse pam ssh banner tmp autofs
).each do |recipe|
include_recipe "sys::#{recipe}"
end
name "sys_accounts_test"
description "Use to test the [sys::accounts] recipe."
run_list( "recipe[sys]" )
default_attributes(
:sys => {
:accounts => {
:kirk => {
:uid => 1111,
:shell => '/bin/bash'
},
:spock => {
:system => true
},
:sulu => {
:action => :remove
},
:uhura => {
:home => '/home/uhura',
:password => '$6$M4oxTop4$LUMq8D7opKEJKN2G8E7i58RqvcKeVfeRqrMDOdGf2gpSF4mz8S0kYDu4BwlLLMkVxk/2kd1nmrsiZdFfzKr1Q/',
:supports => {
:manage_home => true
}
}
}
}
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment