Managing Tunables Flow
In this document, we will explain the process of managing tunables in the AIX system using the Ansible module. The process involves initializing the module, handling different actions like showing, modifying, or resetting tunables, and creating a dictionary of current tunable values.
The flow starts with initializing the Ansible module with the required parameters. Depending on the action specified (show, modify, or reset), the module performs the corresponding task. If the action is 'modify', it ensures compatibility of the change type and bosboot tunables before calling the modify function. The modify function checks for necessary parameters, creates a dictionary of current tunable values, validates new values, constructs the command to modify the tunables, and executes it. If successful, it updates the results with a success message; otherwise, it fails with an error message.
Flow drill down
Main Function
First, the main
modify
def main():
'''
Main function
'''
global results
module = AnsibleModule(
argument_spec=dict(
action=dict(type='str', required=True, choices=['show', 'modify', 'reset']),
component=dict(type='str', required=True, choices=['vmo', 'ioo', 'schedo', 'no',
'raso', 'nfso', 'asoo']),
change_type=dict(type='str', default='current', choices=['current', 'reboot', 'both']),
bosboot_tunables=dict(type='bool', default=False),
tunable_params=dict(type='list', elements='str'),
tunable_params_with_value=dict(type='dict'),
restricted_tunables=dict(type='bool', default=False)
),
supports_check_mode=False
)
results = dict(
changed=False,
Handling the Modify Action
Next, the modify
create_tunables_dict
def modify(module):
'''
Handles the modify action
arguments:
module (dict): The Ansible module
note:
Exits with fail_json in case of error
return:
Message for successful command along with display standard output
'''
component = module.params['component']
bosboot_tunables = module.params['bosboot_tunables']
change_type = module.params['change_type']
restricted_tunables = module.params['restricted_tunables']
tunable_params_with_value = module.params['tunable_params_with_value']
parameters = ''
changed_tunables = ''
cmd = ''
Creating the Tunables Dictionary
Then, the create_tunables_dict
def create_tunables_dict(module):
'''
Utility function to create tunables dictionary with values
arguments:
module (dict): The Ansible module
note:
Exits with fail_json in case of error
return:
creates a dictionary with all tunables and their values
'''
component = module.params['component']
global tunables_dict
cmd = component + ' -F -x'
rc, std_out, std_err = module.run_command(cmd, use_unsafe_shell=True)
if rc != 0:
# In case command returns non zero return code, fail case
results['msg'] = "Failed to get tunables existing values for validation."
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human