Skip to main content

EMGR Module Overview

EMGR Overview

EMGR refers to the interim fix manager used to manage system interim fixes on AIX systems. It installs packages created with the epkg command and maintains the database containing interim fix information. EMGR can perform various operations such as installing, committing, checking, mounting, unmounting, removing, listing interim fixes, and viewing package locks.

Supported Actions

The module supports actions like install, commit, check, mount, unmount, remove, view_package, display_ifix, and list. It requires AIX version 7.1 TL3 or higher and Python 3.6 or newer. The module also requires a privileged user with the authorization aix.system.install.

How to Use EMGR

To use EMGR, specify the action to be performed (e.g., install, commit, check) and provide the necessary parameters such as ifix_package, ifix_label, or list_file. The module supports various options to control the behavior of the EMGR command.


Example Usage of EMGR

An example usage of the EMGR module is to install an ifix package from a file generated with epkg. This can be done by specifying the action as 'install' and providing the path to the ifix_package, the working directory, and setting from_epkg to true.

- name: Install ifix package from file generated with epkg
emgr:
action: install
ifix_package: /usr/sys/inst.images/IJ22714s1a.200212.AIX72TL04SP00-01.epkg.Z
working_dir: /usr/sys/inst.images
from_epkg: true
extend_fs: true

Main Functions

The EMGR module includes several main functions that facilitate its operations.


param_one_of

The param_one_of function checks if at least one parameter from a given list is defined in the module's parameters dictionary. It ensures that the required parameters are provided and that only one parameter is defined if exclusivity is required.

def param_one_of(one_of_list, required=True, exclusive=True):
"""
Check at parameter of one_of_list is defined in module.params dictionary.

arguments:
one_of_list (list) list of parameter to check
required (bool) at least one parameter has to be defined.
exclusive (bool) only one parameter can be defined.
note:
Ansible might have this embedded in some version: require_if 4th parameter.
Exits with fail_json in case of error
"""

count = 0
action = module.params['action']
for param in one_of_list:
if module.params[param] is not None and module.params[param]:
count += 1
break
if count == 0 and required:
results['msg'] = f'Missing parameter: action is { action } but\


parse_ifix_details

The parse_ifix_details function parses the output of the emgr -l command to return the interim fixes as a list of dictionaries. It extracts relevant information such as ID, state, label, install time, updated by, and abstract from the command output.

def parse_ifix_details(output):
"""
Parses the output of "emgr -l" command to return the ifixes as a list instead of str.

argument:
stdout (str) standard output of the command.

return:
List of dictionaries containing information about the iFixes.
"""
ifix_name = []

info_list = ["ID", "STATE", "LABEL", "INSTALL TIME", "UPDATED BY", "ABSTRACT"]
position_dict = {}

def get_value(line, field):
field_index = info_list.index(field)
next_field_index = field_index + 1
start_position = position_dict[field]

# End-of-line


is_ifix_installed

The is_ifix_installed function checks if a specified interim fix is already installed on the system. It uses the emgr -c -L command to verify the installation status of the interim fix.

def is_ifix_installed(module, ifix_package):

# Utility function to check if the ifix is installed in the system.
ifix_label = ifix_package.split('/')[-1].split('.')[0]
cmd = 'emgr -c -L' + ifix_label

rc = module.run_command(cmd)[0]

if rc == 0:
return True
else:
return False


main

The main function is the entry point of the module. It defines the module's parameters, initializes the results dictionary, and handles the different actions that can be performed by the emgr command, such as install, commit, check, mount, unmount, remove, view_package, display_ifix, and list.

def main():
global module
global results

module = AnsibleModule(
supports_check_mode=True,
argument_spec=dict(
action=dict(type='str', default='list', choices=['install', 'commit', 'check', 'mount', 'unmount',
'remove', 'view_package', 'display_ifix', 'list']),
ifix_package=dict(type='path'),
ifix_label=dict(type='str'),
ifix_number=dict(type='str'),
ifix_vuid=dict(type='str'),
package=dict(type='str'),
alternate_dir=dict(type='path'),
list_file=dict(type='path'),
working_dir=dict(type='path'),
from_epkg=dict(type='bool', default=False),
mount_install=dict(type='bool', default=False),
commit=dict(type='bool', default=False),
extend_fs=dict(type='bool', default=False),

 

This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human