def run_module(): # define available arguments/parameters a user can pass to the module argument_spec = vmanage_argument_spec() argument_spec.update(type=dict(type='str', required=False, default='all'), ) # seed the result dict in the object # we primarily care about changed and state # change is if this module effectively modified the target # state will include any data that you want your module to pass back # for consumption, for example, in a subsequent task result = dict(changed=False, original_message='', message='') # the AnsibleModule object will be our abstraction working with Ansible # this includes instantiation, a couple of common attr would be the # args/params passed to the execution, as well as if the module # supports check mode module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, ) vmanage = Vmanage(module) policy_data = PolicyData(vmanage.auth, vmanage.host) vmanage.result['local_policy'] = policy_data.export_local_policy_list() vmanage.exit_json(**vmanage.result)
def local(ctx, name, json): #pylint: disable=unused-argument """ Show local policy information """ local_policy = LocalPolicy(ctx.auth, ctx.host, ctx.port) policy_data = PolicyData(ctx.auth, ctx.host, ctx.port) pp = pprint.PrettyPrinter(indent=2) if name: policy_list_dict = local_policy.get_policy_list_dict(type=type) if name in policy_list_dict: pp.pprint(policy_list_dict[name]) else: local_policy_list = policy_data.export_local_policy_list() pp.pprint(local_policy_list)