Class: Ansible::Ruby::Modules::User
- Inherits:
-
Base
- Object
- Ansible::Ruby::Models::Base
- Base
- Ansible::Ruby::Modules::User
- Defined in:
- lib/ansible/ruby/modules/generated/system/user.rb,
lib/ansible/ruby/modules/custom/system/user.rb
Overview
Manage user accounts and user attributes. For Windows targets, use the M(win_user) module instead.
Instance Method Summary collapse
-
#append ⇒ String?
If C(yes), add the user to the groups specified in C(groups).,If C(no), user will only be added to the groups specified in C(groups), removing them from all other groups.
-
#comment ⇒ String?
Optionally sets the description (aka I(GECOS)) of user account.
-
#create_home ⇒ String?
Unless set to C(no), a home directory will be made for the user when the account is created or if the home directory does not exist.,Changed from C(createhome) to C(create_home) in version 2.5.
-
#expires ⇒ Integer?
An expiry time for the user in epoch, it will be ignored on platforms that do not support this.
-
#force ⇒ String?
This only affects C(state=absent), it forces removal of the user and associated directories on supported platforms.
-
#generate_ssh_key ⇒ String?
Whether to generate a SSH key for the user in question.
-
#group ⇒ String?
Optionally sets the user’s primary group (takes a group name).
-
#groups ⇒ Array<String>, ...
List of groups user will be added to.
-
#hidden ⇒ Object?
MacOS only, optionally hide the user from the login window and system preferences.,The default will be ‘True’ if the I(system) option is used.
-
#home ⇒ Object?
Optionally set the user’s home directory.
-
#local ⇒ String?
Forces the use of “local” command alternatives on platforms that implement it.
-
#login_class ⇒ Object?
Optionally sets the user’s login class, a feature of most BSD OSs.
-
#move_home ⇒ String?
If set to C(yes) when used with C(home=), attempt to move the user’s old home directory to the specified directory if it isn’t there already and the old home exists.
-
#name ⇒ String
Name of the user to create, remove or modify.
-
#non_unique ⇒ String?
Optionally when used with the -u option, this option allows to change the user ID to a non-unique value.
-
#password ⇒ Object?
Optionally set the user’s password to this crypted value.,On macOS systems, this value has to be cleartext.
-
#password_lock ⇒ Object?
Lock the password (usermod -L, pw lock, usermod -C).
-
#remove ⇒ String?
This only affects C(state=absent), it attempts to remove directories associated with the user.
-
#seuser ⇒ Object?
Optionally sets the seuser type (user_u) on selinux enabled systems.
-
#shell ⇒ String?
Optionally set the user’s shell.,On macOS, before version 2.5, the default shell for non-system users was /usr/bin/false.
-
#skeleton ⇒ Object?
Optionally set a home skeleton directory.
-
#ssh_key_bits ⇒ String?
Optionally specify number of bits in SSH key to create.
-
#ssh_key_comment ⇒ String?
Optionally define the comment for the SSH key.
-
#ssh_key_file ⇒ String?
Optionally specify the SSH key filename.
-
#ssh_key_passphrase ⇒ Object?
Set a passphrase for the SSH key.
-
#ssh_key_type ⇒ String?
Optionally specify the type of SSH key to generate.
-
#state ⇒ :absent, ...
Whether the account should exist or not, taking action if the state is different from what is stated.
-
#system ⇒ String?
When creating an account C(state=present), setting this to C(yes) makes the user a system account.
-
#to_h ⇒ Object
Until Ansible 2.3, groups has to be a CSV.
-
#uid ⇒ Integer?
Optionally sets the I(UID) of the user.
-
#update_password ⇒ :always, ...
C(always) will update passwords if they differ.
Methods inherited from Base
Methods inherited from Ansible::Ruby::Models::Base
attr_option, attr_options, attribute, #initialize, remove_existing_validations, validates
Constructor Details
This class inherits a constructor from Ansible::Ruby::Models::Base
Instance Method Details
#append ⇒ String?
Returns If C(yes), add the user to the groups specified in C(groups).,If C(no), user will only be added to the groups specified in C(groups), removing them from all other groups.
43 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 43 attribute :append |
#comment ⇒ String?
Returns Optionally sets the description (aka I(GECOS)) of user account.
21 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 21 attribute :comment |
#create_home ⇒ String?
Returns Unless set to C(no), a home directory will be made for the user when the account is created or if the home directory does not exist.,Changed from C(createhome) to C(create_home) in version 2.5.
64 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 64 attribute :create_home |
#expires ⇒ Integer?
Returns An expiry time for the user in epoch, it will be ignored on platforms that do not support this. Currently supported on GNU/Linux, FreeBSD, and DragonFlyBSD.,Since version 2.6 you can remove the expiry time specify a negative value. Currently supported on GNU/Linux and FreeBSD.
114 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 114 attribute :expires |
#force ⇒ String?
Returns This only affects C(state=absent), it forces removal of the user and associated directories on supported platforms. The behavior is the same as C(userdel –force), check the man page for C(userdel) on your system for details and support.
76 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 76 attribute :force |
#generate_ssh_key ⇒ String?
Returns Whether to generate a SSH key for the user in question. This will B(not) overwrite an existing SSH key.
87 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 87 attribute :generate_ssh_key |
#group ⇒ String?
Returns Optionally sets the user’s primary group (takes a group name).
35 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 35 attribute :group |
#groups ⇒ Array<String>, ...
Returns List of groups user will be added to. When set to an empty string C(”), C(null), or C(~), the user is removed from all groups except the primary group. (C(~) means C(null) in YAML),Before version 2.3, the only input format allowed was a comma separated string. Now this parameter accepts a list as well as a comma separated string.
39 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 39 attribute :groups |
#hidden ⇒ Object?
Returns macOS only, optionally hide the user from the login window and system preferences.,The default will be ‘True’ if the I(system) option is used.
25 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 25 attribute :hidden |
#home ⇒ Object?
Returns Optionally set the user’s home directory.
51 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 51 attribute :home |
#local ⇒ String?
Returns Forces the use of “local” command alternatives on platforms that implement it. This is useful in environments that use centralized authentification when you want to manipulate the local users. I.E. it uses ‘luseradd` instead of `useradd`.,This requires that these commands exist on the targeted host, otherwise it will be a fatal error.
121 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 121 attribute :local |
#login_class ⇒ Object?
Returns Optionally sets the user’s login class, a feature of most BSD OSs.
84 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 84 attribute :login_class |
#move_home ⇒ String?
Returns If set to C(yes) when used with C(home=), attempt to move the user’s old home directory to the specified directory if it isn’t there already and the old home exists.
68 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 68 attribute :move_home |
#name ⇒ String
Returns Name of the user to create, remove or modify.
13 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 13 attribute :name |
#non_unique ⇒ String?
Returns Optionally when used with the -u option, this option allows to change the user ID to a non-unique value.
28 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 28 attribute :non_unique |
#password ⇒ Object?
Returns Optionally set the user’s password to this crypted value.,On macOS systems, this value has to be cleartext. Beware of security issues.,See U(docs.ansible.com/ansible/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module) for details on various ways to generate these password values.
57 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 57 attribute :password |
#password_lock ⇒ Object?
Returns Lock the password (usermod -L, pw lock, usermod -C). BUT implementation differs on different platforms, this option does not always mean the user cannot login via other methods. This option does not disable the user, only lock the password. Do not change the password in the same task. Currently supported on Linux, FreeBSD, DragonFlyBSD, NetBSD.
118 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 118 attribute :password_lock |
#remove ⇒ String?
Returns This only affects C(state=absent), it attempts to remove directories associated with the user. The behavior is the same as C(userdel –remove), check the man page for details and support.
80 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 80 attribute :remove |
#seuser ⇒ Object?
Returns Optionally sets the seuser type (user_u) on selinux enabled systems.
32 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 32 attribute :seuser |
#shell ⇒ String?
Returns Optionally set the user’s shell.,On macOS, before version 2.5, the default shell for non-system users was /usr/bin/false. Since 2.5, the default shell for non-system users on macOS is /bin/bash.,On other operating systems, the default shell is determined by the underlying tool being used. See Notes for details.
47 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 47 attribute :shell |
#skeleton ⇒ Object?
Returns Optionally set a home skeleton directory. Requires create_home option!.
54 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 54 attribute :skeleton |
#ssh_key_bits ⇒ String?
Returns Optionally specify number of bits in SSH key to create.
91 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 91 attribute :ssh_key_bits |
#ssh_key_comment ⇒ String?
Returns Optionally define the comment for the SSH key.
103 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 103 attribute :ssh_key_comment |
#ssh_key_file ⇒ String?
Returns Optionally specify the SSH key filename. If this is a relative filename then it will be relative to the user’s home directory.
99 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 99 attribute :ssh_key_file |
#ssh_key_passphrase ⇒ Object?
Returns Set a passphrase for the SSH key. If no passphrase is provided, the SSH key will default to having no passphrase.
107 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 107 attribute :ssh_key_passphrase |
#ssh_key_type ⇒ String?
Returns Optionally specify the type of SSH key to generate. Available SSH key types will depend on implementation present on target host.
95 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 95 attribute :ssh_key_type |
#state ⇒ :absent, ...
Returns Whether the account should exist or not, taking action if the state is different from what is stated.
60 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 60 attribute :state |
#system ⇒ String?
Returns When creating an account C(state=present), setting this to C(yes) makes the user a system account. This setting cannot be changed on existing users.
72 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 72 attribute :system |
#to_h ⇒ Object
Until Ansible 2.3, groups has to be a CSV
13 14 15 16 17 18 19 |
# File 'lib/ansible/ruby/modules/custom/system/user.rb', line 13 def to_h result = super user = result[:user] groups = user[:groups] user[:groups] = groups.join ',' if groups result end |
#uid ⇒ Integer?
Returns Optionally sets the I(UID) of the user.
17 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 17 attribute :uid |
#update_password ⇒ :always, ...
Returns C(always) will update passwords if they differ. C(on_create) will only set the password for newly created users.
110 |
# File 'lib/ansible/ruby/modules/generated/system/user.rb', line 110 attribute :update_password |