User Overview
User Overview
A user in the context of an AIX system refers to an entity that can be created, modified, or deleted using the provided module. This module allows for the creation of a new user with specified attributes, modification of existing user attributes, or deletion of a user. The module requires root user privileges or a privileged user with specific authorizations to perform these actions. It supports operations on users present in the local machine or in an LDAP server.
User Attributes and Options
The module provides options to specify user attributes, delete the home directory upon user removal, and enforce password changes on first login. This flexibility ensures that user management can be tailored to specific requirements.
Example: Creating a User
This example demonstrates how to create a user named aixguest1010
The code snippet shows how to create a user named aixguest1010
EXAMPLES = r'''
- name: Create user aixguest1010
ibm.power_aix.user:
state: present
name: aixguest1010
change_passwd_on_login: false
password: as$12ndhkfjk$1c
attributes:
home: /home/test/aixguest1010
data: 1272
'''
Main Functions
There are several main functions in this module. Some of them are get_user_attrs
changed_attrs
modify_user
create_user
remove_user
user_exists
change_password
main
modify_user
create_user
remove_user
modify_user
modify_user
The modify_user
chuser
The modify_user
chuser
def modify_user(module):
'''
Modify_user function modifies the attributes of the user and returns
output, return code and error of chuser command, if any.
arguments:
module (dict): The Ansible module
note:
Exits with fail_json in case of error
return:
(message for command, changed status)
'''
name = module.params['name']
msg = None
changed = False
# Get current user attributes
current_attrs = get_user_attrs(module)
# Get user attributes to change
attrs = changed_attrs(module, current_attrs)
# Redefine attributes
create_user
create_user
The create_user
mkuser
The create_user
mkuser
def create_user(module):
'''
Create_user function creates the user with the attributes provided in the
attribiutes field. It returns the standard output, return code and error
for mkuser command, if any.
arguments:
module (dict): The Ansible module
note:
Exits with fail_json in case of error
If this successfully returns, that means changes were made.
return:
Message for successful command.
'''
attributes = module.params['attributes']
name = module.params['name']
opts = ""
load_module_opts = None
msg = ""
# Adding the load module to the command so that the user is created at the right location.
remove_user
remove_user
The remove_user
userdel
remove_homedir
The remove_user
userdel
def remove_user(module):
'''
Remove_user function removes the user from the system.It returns the standard output,
return code and error for mkuser command, if any.
arguments:
module (dict): The Ansible module
note:
Exits with fail_json in case of error
return:
Message for successfull command
'''
name = module.params['name']
cmd = ['userdel']
if module.params['remove_homedir']:
cmd.append('-r')
cmd.append(name)
rc, stdout, stderr = module.run_command(cmd)
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human