Commit graph

48 commits

Author SHA1 Message Date
Nigel Metheringham
c6c7189e23 Take SHADOWFILE from existing user object rather than class 2012-11-04 09:54:50 +00:00
Nigel Metheringham
ed5bf78485 Use the existing framework when running ssh_keygen 2012-11-04 09:47:30 +00:00
Nigel Metheringham
eecf6cf94f Ensure user owns their ssh key directory on creation
Lost section from commit 8049777
2012-11-04 09:44:38 +00:00
Michael DeHaan
ade071eb29 Fix user example 2012-11-03 18:57:19 -04:00
Michael DeHaan
61a4674413 Merge branch 'nigelm_freebsd' of git://github.com/nigelm/ansible into merge-service
Make things more reusable, correct some errors along the SSH key path

Conflicts:
	library/user
2012-11-03 18:38:05 -04:00
Nigel Metheringham
871d3afdf4 Added some documentation to the classes 2012-11-01 19:16:54 +00:00
Stephen Fromm
f0d2a1260b Make sure ownership is set correctly for user's new ssh keys 2012-10-30 09:37:23 -07:00
Nigel Metheringham
0fc939d33f Turn off some of the additional debug syslogging 2012-10-29 22:04:06 +00:00
Nigel Metheringham
346f8ffe0e Rework of user module to support portability
Split module into a main calling function, and a generic
(Linux useradd/usermod/userdel) User class.
Added a __new__ function that selects most appropriate superclass
Added a FreeBSD User class
Tested against FreeBSD 9.0
2012-10-29 22:00:58 +00:00
Michael DeHaan
d55e7f35cd Merge pull request #1455 from bleader/devel
user module: fix typo in documentation
2012-10-25 18:26:58 -07:00
Michael DeHaan
24637fa9b0 Merge pull request #1448 from jpmens/user_user1
User is alias for name in 'user' module
2012-10-25 18:18:56 -07:00
bleader
fd650d783a user module: fix typo in documentation
tyep -> type

Signed-off-by: bleader <bleader@ratonland.org>
2012-10-25 20:56:13 +02:00
Jan-Piet Mens
9484f55581 User is alias for name in 'user' module 2012-10-25 14:03:13 +02:00
Stephen Fromm
d7b5cbb6ac Skip check of primary group when checking other group membership 2012-10-24 20:39:42 -07:00
Jan-Piet Mens
ecbb1eb63b fix DOCUMENTATION for user 2012-10-24 07:35:56 +02:00
Stephen Fromm
ccb4f41b73 Document ssh_key options are in version 0.9 2012-10-23 08:21:40 -07:00
Jan-Piet Mens
d069c57974 Reformat code: examples consistently
- added terse syntax to modules.rst
 - added description of special variables to template module
2012-10-23 15:14:01 +02:00
Stephen Fromm
fb87376b1b Use os.path.join where appropriate 2012-10-19 22:22:27 -07:00
Stephen Fromm
213b2306be Add ability to create SSH key for user in user module
This allows one to create a SSH key for user.  You may define:
ssh_key_type, ssh_key_bits, ssh_key_file, ssh_key_comment,
and ssh_key_passphrase.  If no passphrase is provided, the
key will be passphrase-less.  This will not overwrite an existing key.
In the JSON returned, it will provide the ssh_fingerprint and
ssh_key_file.
2012-10-19 22:00:31 -07:00
Luke Antins
980b1c4b74 Add examples to user module documentation. 2012-10-18 02:55:58 +01:00
Michael DeHaan
6f4c3deb11 user module should be using module.BOOLEANS for choices 2012-10-12 18:06:36 -04:00
Jan-Piet Mens
c78a0a4a49 Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
Stephen Fromm
f5d39b8677 Add module documentation for git, group, service, and user 2012-09-29 23:50:25 -07:00
Stephen Fromm
1222cf8de9 Add option required=(True|False) to get_bin_path and update modules
Added required as optional argument to get_bin_path(). It defaults to
false.  Updated following modules to use required=True when calling
get_bin_path():  apt_repository, easy_install, group, pip,
supervisorctl, and user.
Also removed _find_supervisorctl() from supervisorctl module and updated
_is_running() to not need it.
2012-08-30 11:01:37 -07:00
Stephen Fromm
f0da6b191a Migrate remaining modules to use get_bin_path in module_common.py
* Migraed easy_install, pip, service, setup, and user.
* Updated fail_json message in apt_repository
* Fixed easy_install to not hardcode location of virtualenv in
  /usr/local/bin/.
* Made handling of virtualenv more consistent between easy_install and
  pip.
2012-08-29 20:26:22 -07:00
Michael DeHaan
3c2eba57fd Make pep8 tests run against the library directory as well, and associated tweaks (mostly to indentation) in the library
directory.
2012-08-11 12:35:58 -04:00
Stephen Fromm
62a4a68658 Abstract how to look up user password to be more flexible
This adds user_password() to abstract how the user's password is looked
up.  If spwd is not available, this will read the shadow file for the
user's shadow entry.  This will then facilitate idempotent password
changes on hosts without spwd.
2012-08-07 23:57:17 -07:00
Michael DeHaan
baacde6c74 Add encoding lines to python modules such that they can take unicode options if they are fed them, since the
AnsibleModule stuff no longer base64 encodes for simplicity and speed reasons.
2012-08-02 21:29:10 -04:00
Michael DeHaan
4782bc1949 Port the file module over to the new common code infrastructure + cleanup some redundant imports since the module code already imports those things. 2012-07-30 21:50:32 -04:00
Mark Theunissen
b7b44fbf93 Undefined variable error 2012-07-24 09:26:45 -05:00
Stephen Fromm
47cd5de2cc Update user module to use new shared module code 2012-07-23 11:29:59 -07:00
Michael DeHaan
3d4efc0504 Change the way we do with_items to make them happen next to each other in runner, which eliminates the problem of with_items and vars_files sometimes not playing nice with each other.
(Also a fix for the user module error handling when the user
is not present at the time of the return.  This can only really be caused by multiple ansible executions).
2012-07-14 19:18:33 -04:00
Jeremy Smitherman
53459e5609 Added yes/no to user options instead of False comparison for force and remove options for user module 2012-07-11 12:16:40 -04:00
Stephen Fromm
50039260e2 Minor fix to user module to further streamline setting 'changed' flag 2012-07-10 16:37:07 -07:00
Michael DeHaan
a1f93baa68 Merge pull request #568 from sfromm/user
User modules fixes
2012-07-10 16:04:17 -07:00
Stephen Fromm
5adbe2453c Fixes to user module for better error handling
The user module now returns the output, both stdout and stderr, from
useradd, usermod, and userdel.  This should help debug cases why one of
those commands fail.  In addition, the user module will now call
fail_json() when the attempted command failed so as to properly
communicate a failure in a playbook.
2012-07-10 15:55:39 -07:00
Seth Vidal
bbd42fcf36 modify user module so that password is NEVER logged before the command runs 2012-07-10 17:13:51 -04:00
Brad Olson
637e0d0df3 Remove call to undefined debug() in module 'user'.
I think when we stopped using stderr for debugging modules because
paramiko didn't like it, many modules used the idiom of defining
a debug function that used standard error. The def's and calls were
removed.

This looks like a stray debug() that didn't get removed and didn't
show up unless you alter a user's groups. If it's hit, 'user' fails
with a global undefined function error.
2012-05-15 09:19:43 -04:00
Stephen Fromm
67ee30f135 Apply logging of arguments to modules (issue #122)
The ohai and facter modules use /usr/bin/logger to log the fact that
they have been invoked.  I added 'import os' to the ping module
so that it could have the same syslog statements as the other modules.
I separated the condensed:
    shlex.split(open(argfile, 'r').read())
into two separate statements similar to the other modules.
2012-05-09 15:19:20 -07:00
Stephen Fromm
7d52ace295 Move import of spwd under a try block
Resolves issue #333.  If spwd is not available, the password will
be set regardless.
2012-05-08 10:40:44 -07:00
Brendan Beveridge
2f53b91697 remove now useless append check in user_mod 2012-05-08 09:49:37 +10:00
Brendan Beveridge
26b1bed22c Fixes issue #315
This adds some logic when usings groups possibly in combination with append

  if just specifying groups and the current groups do not match the list
     set groups
  if specifying groups with append and any group thats not in the current groups
     set groups with -a
2012-05-08 09:43:51 +10:00
Jeroen Hoekx
23c691bd30 Group order in user module should not matter.
Groups are not necessarily returned in the defined order, especially when the user already existed before ansible started managing the system.
2012-05-02 11:54:27 +02:00
Daniel Néri
0c4c3422f3 Add 'system' option for user and group modules
Creates system accounts/groups; corresponds to the '-r' option for {user,group}add.

The option is only honored when users/groups are added, not when modified.
2012-05-01 21:38:55 +02:00
Michael DeHaan
31f6cd6408 Because paramiko using a pty can't distinguish stderr and stdout, remove handling that
treated -D as a way to show stderr, and make sure modules don't include things on stderr.
Update docs and test module script to come into line.
2012-04-27 01:25:38 -04:00
Stephen Fromm
cf6bfba2f8 Update user module to support supplementary group membership
This adds two options to the user module: groups and append.  groups is
a comma-delimited list of supplementary groups a user should belong to.
If a user is currently a member of a group not listed in groups, the
user will be removed from it.  To change this behavior, use append=yes.
This will append the user to the list of supplementary groups and *not*
remove the user from unlisted groups.
2012-03-28 14:12:35 -07:00
Stephen Fromm
e44bf9e19c Update user module to support group name
This changes the gid option to group.  One may provide a primary group
as either a gid or a name.  The module will then check to verify that
the group already exists.  If the group does not already exist, the
module will fail.
2012-03-26 23:03:09 -04:00
Stephen Fromm
e60dc41473 Add user module to create, modify, and delete user accounts
This relies on useradd, usermod, and userdel utilities on the system.
The argument name is required; if state is not provided, present is
assumed.  Other options supported for creating or modifying an existing
account:  uid, gid, comment, home, shell, and password.  If managing the
password, it must already be encrypted.  When creating an account, you
can also provide the argument createhome to control whether the home
directory is created.  Arguments supported for deleting an account are:
force (remove account even if user is logged in) and remove (remove home
directory).
2012-03-22 11:21:41 -07:00