commit
c830597402
@ -0,0 +1,2 @@ |
|||||||
|
- delete groups |
||||||
|
|
@ -0,0 +1,66 @@ |
|||||||
|
#!/bin/sh |
||||||
|
# |
||||||
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc) |
||||||
|
# |
||||||
|
# This file is part of cdist. |
||||||
|
# |
||||||
|
# cdist is free software: you can redistribute it and/or modify |
||||||
|
# it under the terms of the GNU General Public License as published by |
||||||
|
# the Free Software Foundation, either version 3 of the License, or |
||||||
|
# (at your option) any later version. |
||||||
|
# |
||||||
|
# cdist is distributed in the hope that it will be useful, |
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
# GNU General Public License for more details. |
||||||
|
# |
||||||
|
# You should have received a copy of the GNU General Public License |
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
# |
||||||
|
# |
||||||
|
# Manage groups. |
||||||
|
# |
||||||
|
|
||||||
|
name="$__object_id" |
||||||
|
|
||||||
|
command= |
||||||
|
if grep -q "^$name" "$__object/explorer/group"; then |
||||||
|
# group exists |
||||||
|
command="groupmod" |
||||||
|
else |
||||||
|
# group does not exist |
||||||
|
command="groupadd" |
||||||
|
fi |
||||||
|
|
||||||
|
|
||||||
|
get_current_value() { |
||||||
|
local key="$1" |
||||||
|
local index |
||||||
|
case "$key" in |
||||||
|
password) |
||||||
|
cut -d':' -f 2 "$__object/explorer/gshadow" |
||||||
|
break |
||||||
|
;; |
||||||
|
gid) index=3;; |
||||||
|
esac |
||||||
|
cut -d':' -f $index "$__object/explorer/group" |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
set -- "$@" |
||||||
|
cd "$__object/parameter" |
||||||
|
for property in $(ls .); do |
||||||
|
current_value=$(get_current_value "$property") |
||||||
|
new_value="$(cat "$property")" |
||||||
|
if [ "$new_value" != "$current_value" ]; then |
||||||
|
# Shedule changed properties for update |
||||||
|
set -- "$@" "--$property" \"$new_value\" |
||||||
|
fi |
||||||
|
done |
||||||
|
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then |
||||||
|
# Update changed properties |
||||||
|
echo $command $@ $name |
||||||
|
fi |
||||||
|
|
@ -0,0 +1,52 @@ |
|||||||
|
cdist-type__group(7) |
||||||
|
=================== |
||||||
|
Steven Armstrong <steven-cdist--@--armstrong.cc> |
||||||
|
|
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
cdist-type__group - Manage groups |
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
This cdist type allows you to create or modify groups on the target. |
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS |
||||||
|
------------------- |
||||||
|
None. |
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS |
||||||
|
------------------- |
||||||
|
gid:: |
||||||
|
see groupmod(8) |
||||||
|
password:: |
||||||
|
see above |
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES |
||||||
|
-------- |
||||||
|
|
||||||
|
-------------------------------------------------------------------------------- |
||||||
|
# Create a group 'foobar' with operating system default settings |
||||||
|
__group foobar |
||||||
|
|
||||||
|
# Same but with a specific gid |
||||||
|
__group foobar --gid 1234 |
||||||
|
|
||||||
|
# Same but with a gid and password |
||||||
|
__group foobar --gid 1234 --password 'crypted-password-string' |
||||||
|
-------------------------------------------------------------------------------- |
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO |
||||||
|
-------- |
||||||
|
- cdist-type(7) |
||||||
|
|
||||||
|
|
||||||
|
COPYING |
||||||
|
------- |
||||||
|
Copyright \(C) 2011 Steven Armstrong. Free use of this software is |
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3). |
@ -0,0 +1,2 @@ |
|||||||
|
gid |
||||||
|
password |
@ -0,0 +1,61 @@ |
|||||||
|
cdist-type__user(7) |
||||||
|
=================== |
||||||
|
Steven Armstrong <steven-cdist--@--armstrong.cc> |
||||||
|
|
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
cdist-type__package - Manage packages |
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
This cdist type allows you to install or uninstall packages on the target. |
||||||
|
It dispatches the actual work to the package system dependant types. |
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS |
||||||
|
------------------- |
||||||
|
state:: |
||||||
|
The state the package should be in, either "installed" or "uninstalled" |
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS |
||||||
|
------------------- |
||||||
|
name:: |
||||||
|
The name of the package to install. Default is to use the object_id as the |
||||||
|
package name. |
||||||
|
version:: |
||||||
|
The version of the package to install. Default is to install the version |
||||||
|
choosen by the local package manager. |
||||||
|
type:: |
||||||
|
The package type to use. Default is determined based on the $os explorer |
||||||
|
variable. |
||||||
|
e.g. __package_apt for Debian |
||||||
|
__package_emerge for Gentoo |
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES |
||||||
|
-------- |
||||||
|
|
||||||
|
-------------------------------------------------------------------------------- |
||||||
|
# Install the package vim on the target |
||||||
|
__package vim --state installed |
||||||
|
|
||||||
|
# Same but install specific version |
||||||
|
__package vim --state installed --version 7.3.50 |
||||||
|
|
||||||
|
# Force use of a specific package type |
||||||
|
__package vim --state installed --type __package_apt |
||||||
|
-------------------------------------------------------------------------------- |
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO |
||||||
|
-------- |
||||||
|
- cdist-type(7) |
||||||
|
|
||||||
|
|
||||||
|
COPYING |
||||||
|
------- |
||||||
|
Copyright \(C) 2011 Steven Armstrong. Free use of this software is |
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3). |
@ -1,2 +0,0 @@ |
|||||||
name |
|
||||||
version |
|
@ -1 +0,0 @@ |
|||||||
state |
|
@ -0,0 +1,2 @@ |
|||||||
|
- delete users |
||||||
|
|
@ -0,0 +1,27 @@ |
|||||||
|
#!/bin/sh |
||||||
|
# |
||||||
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc) |
||||||
|
# |
||||||
|
# This file is part of cdist. |
||||||
|
# |
||||||
|
# cdist is free software: you can redistribute it and/or modify |
||||||
|
# it under the terms of the GNU General Public License as published by |
||||||
|
# the Free Software Foundation, either version 3 of the License, or |
||||||
|
# (at your option) any later version. |
||||||
|
# |
||||||
|
# cdist is distributed in the hope that it will be useful, |
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
# GNU General Public License for more details. |
||||||
|
# |
||||||
|
# You should have received a copy of the GNU General Public License |
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
# |
||||||
|
# |
||||||
|
# Get an existing users passwd entry. |
||||||
|
# |
||||||
|
|
||||||
|
name=$__object_id |
||||||
|
|
||||||
|
getent passwd "$name" || true |
||||||
|
|
@ -0,0 +1,27 @@ |
|||||||
|
#!/bin/sh |
||||||
|
# |
||||||
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc) |
||||||
|
# |
||||||
|
# This file is part of cdist. |
||||||
|
# |
||||||
|
# cdist is free software: you can redistribute it and/or modify |
||||||
|
# it under the terms of the GNU General Public License as published by |
||||||
|
# the Free Software Foundation, either version 3 of the License, or |
||||||
|
# (at your option) any later version. |
||||||
|
# |
||||||
|
# cdist is distributed in the hope that it will be useful, |
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
# GNU General Public License for more details. |
||||||
|
# |
||||||
|
# You should have received a copy of the GNU General Public License |
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
# |
||||||
|
# |
||||||
|
# Get an existing users shadow entry. |
||||||
|
# |
||||||
|
|
||||||
|
name=$__object_id |
||||||
|
|
||||||
|
getent shadow "$name" || true |
||||||
|
|
@ -0,0 +1,70 @@ |
|||||||
|
#!/bin/sh |
||||||
|
# |
||||||
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc) |
||||||
|
# |
||||||
|
# This file is part of cdist. |
||||||
|
# |
||||||
|
# cdist is free software: you can redistribute it and/or modify |
||||||
|
# it under the terms of the GNU General Public License as published by |
||||||
|
# the Free Software Foundation, either version 3 of the License, or |
||||||
|
# (at your option) any later version. |
||||||
|
# |
||||||
|
# cdist is distributed in the hope that it will be useful, |
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
# GNU General Public License for more details. |
||||||
|
# |
||||||
|
# You should have received a copy of the GNU General Public License |
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
# |
||||||
|
# |
||||||
|
# Manage users. |
||||||
|
# |
||||||
|
|
||||||
|
name="$__object_id" |
||||||
|
|
||||||
|
command= |
||||||
|
if grep -q "^$name" "$__object/explorer/passwd"; then |
||||||
|
# user exists |
||||||
|
command="usermod" |
||||||
|
else |
||||||
|
# user does not exist |
||||||
|
command="useradd" |
||||||
|
fi |
||||||
|
|
||||||
|
|
||||||
|
get_current_value() { |
||||||
|
local key="$1" |
||||||
|
local index |
||||||
|
case "$key" in |
||||||
|
password) |
||||||
|
cut -d':' -f 2 "$__object/explorer/shadow" |
||||||
|
break |
||||||
|
;; |
||||||
|
uid) index=3;; |
||||||
|
gid) index=4;; |
||||||
|
comment) index=5;; |
||||||
|
home) index=6;; |
||||||
|
shell) index=7;; |
||||||
|
esac |
||||||
|
cut -d':' -f $index "$__object/explorer/passwd" |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
set -- "$@" |
||||||
|
cd "$__object/parameter" |
||||||
|
for property in $(ls .); do |
||||||
|
current_value=$(get_current_value "$property") |
||||||
|
new_value="$(cat "$property")" |
||||||
|
if [ "$new_value" != "$current_value" ]; then |
||||||
|
# Shedule changed properties for update |
||||||
|
set -- "$@" "--$property" \"$new_value\" |
||||||
|
fi |
||||||
|
done |
||||||
|
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then |
||||||
|
# Update changed properties |
||||||
|
echo $command $@ $name |
||||||
|
fi |
||||||
|
|
@ -0,0 +1,62 @@ |
|||||||
|
cdist-type__user(7) |
||||||
|
=================== |
||||||
|
Steven Armstrong <steven-cdist--@--armstrong.cc> |
||||||
|
|
||||||
|
|
||||||
|
NAME |
||||||
|
---- |
||||||
|
cdist-type__user - Manage users |
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
----------- |
||||||
|
This cdist type allows you to create or modify users on the target. |
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS |
||||||
|
------------------- |
||||||
|
None. |
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS |
||||||
|
------------------- |
||||||
|
comment:: |
||||||
|
see usermod(8) |
||||||
|
home:: |
||||||
|
see above |
||||||
|
gid:: |
||||||
|
see above |
||||||
|
groups:: |
||||||
|
see above |
||||||
|
password:: |
||||||
|
see above |
||||||
|
shell:: |
||||||
|
see above |
||||||
|
uid:: |
||||||
|
see above |
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES |
||||||
|
-------- |
||||||
|
|
||||||
|
-------------------------------------------------------------------------------- |
||||||
|
# Create user account for foobar with operating system default settings |
||||||
|
__user foobar |
||||||
|
|
||||||
|
# Same but with a different shell |
||||||
|
__user foobar --shell /bin/zsh |
||||||
|
|
||||||
|
# Set explicit uid and home |
||||||
|
__user foobar --uid 1001 --shell /bin/zsh --home /home/foobar |
||||||
|
-------------------------------------------------------------------------------- |
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO |
||||||
|
-------- |
||||||
|
- cdist-type(7) |
||||||
|
|
||||||
|
|
||||||
|
COPYING |
||||||
|
------- |
||||||
|
Copyright \(C) 2011 Steven Armstrong. Free use of this software is |
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3). |
@ -0,0 +1,7 @@ |
|||||||
|
comment |
||||||
|
home |
||||||
|
gid |
||||||
|
groups |
||||||
|
password |
||||||
|
shell |
||||||
|
uid |
Loading…
Reference in new issue