There are many approaches to managing users. You can edit system files like /etc/passwd directly, or you can use commands on some systems like ‘useradd’ or ‘adduser’. In all cases it is desirable to make this a data-driven process.
Add users
Remove users
A simple approach which adds new users to the password file, and to a group called ‘users’ in the group file. Is shown below. This example does not edit the shadow file. A simple pattern that can be modified for use is shown below.
Note that, although this is a simple minded approach, it is the most efficient of the approaches shown here as all operations can be carried out in a single operation for each file.
[%CFEngine_include_snippet(add_users.cf, .* )%]
A second approach is to use the shell commands supplied by some operating systems; this assumes that suitable defaults have been set up manually. Also the result is not repairable in a simple convergent manner. The command needs to edit multiple files for each user, and is quite inefficient.
[%CFEngine_include_snippet(add_users_1.cf, .* )%]
An alternative approach is to use a method to wrap around the handling of a user. Although this looks nice, it is less efficient than the first method because it must edit the files multiple times.
[%CFEngine_include_snippet(add_users_1.cf, .* )%]
Add lines to the password file, and users to group if they are not already there.
[%CFEngine_include_snippet(add_users_to_passwd_and_group.cf, .* )%]
[%CFEngine_include_snippet(acl_file_example.cf, .* )%]
[%CFEngine_include_snippet(acl_generic_example.cf, .* )%]
[%CFEngine_include_snippet(acl_secret_example.cf, .* )%]
[%CFEngine_include_snippet(active_directory_example.cf, .* )%]
[%CFEngine_include_snippet(active_list_users_directory_example.cf, .* )%]
[%CFEngine_include_snippet(active_directory_show_users_example.cf, .* )%]
[%CFEngine_include_snippet(get_a_list_of_users.cf, .* )%]
[%CFEngine_include_snippet(ldap_interactions.cf, .* )%]