def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( name=dict(required=True, type='str'), role=dict(type='str', choices=['readonly', 'storage_admin', 'array_admin']), state=dict(type='str', default='present', choices=['absent', 'present']), password=dict(type='str', no_log=True), old_password=dict(type='str', no_log=True), api=dict(type='bool', default=False), )) module = AnsibleModule(argument_spec, supports_check_mode=False) state = module.params['state'] array = get_system(module) api_version = array._list_available_rest_versions() if MIN_REQUIRED_API_VERSION not in api_version: module.fail_json( msg='FlashArray REST version not supported. ' 'Minimum version required: {0}'.format(MIN_REQUIRED_API_VERSION)) if state == 'absent': delete_user(module, array) elif state == 'present': create_user(module, array) else: module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( state=dict(type='str', default='present', choices=['absent', 'present']), domain=dict(type='str'), nameservers=dict(type='list'), )) required_if = [('state', 'present', ['domain', 'nameservers'])] module = AnsibleModule(argument_spec, required_if=required_if, supports_check_mode=False) state = module.params['state'] array = get_system(module) if state == 'absent': delete_dns(module, array) elif state == 'present': module.params['nameservers'] = remove(module.params['nameservers']) create_dns(module, array) else: module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( banner=dict(type='str', default="Welcome to the machine..."), state=dict(type='str', default='present', choices=['present', 'absent']), )) required_if = [('state', 'present', ['banner'])] module = AnsibleModule(argument_spec, required_if=required_if, supports_check_mode=False) state = module.params['state'] array = get_system(module) current_banner = array.get(banner=True)['banner'] # set banner if empty value or value differs if state == 'present' and (not current_banner or current_banner != module.params['banner']): set_banner(module, array) # clear banner if it has a value elif state == 'absent' and current_banner: delete_banner(module, array) module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( state=dict(type='str', default='present', choices=['absent', 'present']), connection=dict(type='str', default='async', choices=['async', 'sync']), target_url=dict(type='str', required=True), target_api=dict(type='str'), )) required_if = [('state', 'present', ['target_api'])] module = AnsibleModule(argument_spec, required_if=required_if, supports_check_mode=True) if not HAS_PURESTORAGE: module.fail_json(msg='purestorage sdk is required for this module') state = module.params['state'] array = get_system(module) target_array = _check_connected(module, array) if state == 'present' and target_array is None: create_connection(module, array) elif state == 'absent' and target_array is not None: break_connection(module, array, target_array) module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( state=dict(type='str', default='present', choices=['absent', 'present']), sender_domain=dict(type='str'), password=dict(type='str', no_log=True), user=dict(type='str'), relay_host=dict(type='str'), )) required_together = [['user', 'password']] module = AnsibleModule(argument_spec, required_together=required_together, supports_check_mode=True) state = module.params['state'] array = get_system(module) if state == 'absent': delete_smtp(module, array) elif state == 'present': create_smtp(module, array) else: module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update(dict( vgroup=dict(type='str', required=True), state=dict(type='str', default='present', choices=['absent', 'present']), eradicate=dict(type='bool', default=False), )) module = AnsibleModule(argument_spec, supports_check_mode=True) state = module.params['state'] array = get_system(module) api_version = array._list_available_rest_versions() if VGROUP_API_VERSION not in api_version: module.fail_json(msg='API version does not support volume groups.') vgroup = get_vgroup(module, array) xvgroup = get_pending_vgroup(module, array) if xvgroup and state == 'present': recover_vgroup(module, array) elif vgroup and state == 'absent': delete_vgroup(module, array) elif xvgroup and state == 'absent' and module.params['eradicate']: eradicate_vgroup(module, array) elif not vgroup and not xvgroup and state == 'present': make_vgroup(module, array) elif vgroup is None and state == 'absent': module.exit_json(changed=False) module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( ntp_servers=dict(type='list'), state=dict(type='str', default='present', choices=['absent', 'present']), )) required_if = [['state', 'present', ['ntp_servers']]] module = AnsibleModule(argument_spec, required_if=required_if, supports_check_mode=False) array = get_system(module) if module.params['state'] == 'absent': delete_ntp(module, array) else: module.params['ntp_servers'] = remove(module.params['ntp_servers']) if sorted(array.get(ntpserver=True)['ntpserver']) != sorted( module.params['ntp_servers'][0:4]): create_ntp(module, array) module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update(dict( host=dict(type='str', required=True), state=dict(type='str', default='present', choices=['absent', 'present']), protocol=dict(type='str', default='iscsi', choices=['fc', 'iscsi', 'nvme', 'mixed']), nqn=dict(type='list'), iqn=dict(type='list'), wwns=dict(type='list'), volume=dict(type='str'), lun=dict(type='int'), personality=dict(type='str', default='', choices=['hpux', 'vms', 'aix', 'esxi', 'solaris', 'hitachi-vsp', 'oracle-vm-server', 'delete', '']), preferred_array=dict(type='list'), )) module = AnsibleModule(argument_spec, supports_check_mode=True) array = get_system(module) if _is_cbs(module, array) and module.params['wwns'] or module.params['nqn']: module.fail_json(msg='Cloud block Store only support iSCSI as a protocol') api_version = array._list_available_rest_versions() if module.params['nqn'] is not None and NVME_API_VERSION not in api_version: module.fail_json(msg='NVMe protocol not supported. Please upgrade your array.') state = module.params['state'] host = get_host(module, array) if module.params['lun'] and not 1 <= module.params['lun'] <= 4095: module.fail_json(msg='LUN ID of {0} is out of range (1 to 4095)'.format(module.params['lun'])) if module.params['volume']: try: array.get_volume(module.params['volume']) except Exception: module.fail_json(msg='Volume {0} not found'.format(module.params['volume'])) if module.params['preferred_array']: try: if module.params['preferred_array'] != ['delete']: all_connected_arrays = array.list_array_connections() if not all_connected_arrays: module.fail_json(msg='No target arrays connected to source array. Setting preferred arrays not possible.') else: current_arrays = [array.get()['array_name']] for current_array in range(0, len(all_connected_arrays)): if all_connected_arrays[current_array]['type'] == "sync-replication": current_arrays.append(all_connected_arrays[current_array]['array_name']) for array_to_connect in range(0, len(module.params['preferred_array'])): if module.params['preferred_array'][array_to_connect] not in current_arrays: module.fail_json(msg='Array {0} is not a synchronously connected array.'.format(module.params['preferred_array'][array_to_connect])) except Exception: module.fail_json(msg='Failed to get existing array connections.') if host is None and state == 'present': make_host(module, array) elif host and state == 'present': update_host(module, array) elif host and state == 'absent': delete_host(module, array) elif host is None and state == 'absent': module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( pgroup=dict(type='str', required=True), state=dict(type='str', default='present', choices=['absent', 'present']), volume=dict(type='list'), host=dict(type='list'), hostgroup=dict(type='list'), target=dict(type='list'), eradicate=dict(type='bool', default=False), enabled=dict(type='bool', default=True), )) mutually_exclusive = [['volume', 'host', 'hostgroup']] module = AnsibleModule(argument_spec, mutually_exclusive=mutually_exclusive, supports_check_mode=False) state = module.params['state'] array = get_system(module) api_version = array._list_available_rest_versions() if ":" in module.params[ 'pgroup'] and OFFLOAD_API_VERSION not in api_version: module.fail_json( msg='API version does not support offload protection groups.') pgroup = get_pgroup(module, array) xpgroup = get_pending_pgroup(module, array) if module.params['host']: try: for hst in module.params['host']: array.get_host(hst) except Exception: module.fail_json(msg='Host {0} not found'.format(hst)) if module.params['hostgroup']: try: for hstg in module.params['hostgroup']: array.get_hgroup(hstg) except Exception: module.fail_json(msg='Hostgroup {0} not found'.format(hstg)) if pgroup and state == 'present': update_pgroup(module, array) elif pgroup and state == 'absent': delete_pgroup(module, array) elif xpgroup and state == 'absent' and module.params['eradicate']: eradicate_pgroup(module, array) elif not pgroup and not xpgroup and state == 'present': make_pgroup(module, array) elif pgroup is None and state == 'absent': module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( name=dict(type='str', required=True), suffix=dict(type='str'), restore=dict(type='str'), overwrite=dict(type='bool', default=False), target=dict(type='str'), eradicate=dict(type='bool', default=False), now=dict(type='bool', default=False), apply_retention=dict(type='bool', default=False), remote=dict(type='bool', default=False), state=dict(type='str', default='present', choices=['absent', 'present', 'copy']), )) required_if = [('state', 'copy', ['suffix', 'restore'])] module = AnsibleModule(argument_spec, required_if=required_if, supports_check_mode=True) if module.params['suffix'] is None: suffix = "snap-" + str( (datetime.utcnow() - datetime(1970, 1, 1, 0, 0, 0, 0)).total_seconds()) module.params['suffix'] = suffix.replace(".", "") if not module.params['target'] and module.params['restore']: module.params['target'] = module.params['restore'] state = module.params['state'] array = get_system(module) pgroup = get_pgroup(module, array) if pgroup is None: module.fail_json(msg="Protection Group {0} does not exist.".format( module.params['name'])) pgsnap = get_pgsnapshot(module, array) if state == 'copy': restore_pgsnapvolume(module, array) elif state == 'present' and not pgsnap: create_pgsnapshot(module, array) elif state == 'present' and pgsnap: update_pgsnapshot(module, array) elif state == 'absent' and pgsnap: delete_pgsnapshot(module, array) elif state == 'absent' and not pgsnap: module.exit_json(changed=False) module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( name=dict(type='str', required=True), suffix=dict(type='str'), target=dict(type='str'), overwrite=dict(type='bool', default=False), eradicate=dict(type='bool', default=False), state=dict(type='str', default='present', choices=['absent', 'copy', 'present']), )) required_if = [('state', 'copy', ['target', 'suffix'])] module = AnsibleModule(argument_spec, required_if=required_if, supports_check_mode=True) if not HAS_PURESTORAGE: module.fail_json( msg='purestorage sdk is required for this module in volume') if module.params['suffix'] is None: suffix = "snap-" + str( (datetime.utcnow() - datetime(1970, 1, 1, 0, 0, 0, 0)).total_seconds()) module.params['suffix'] = suffix.replace(".", "") state = module.params['state'] array = get_system(module) volume = get_volume(module, array) target = get_target(module, array) snap = get_snapshot(module, array) if state == 'present' and volume and not snap: create_snapshot(module, array) elif state == 'present' and volume and snap: update_snapshot(module, array) elif state == 'present' and not volume: update_snapshot(module, array) elif state == 'copy' and snap: create_from_snapshot(module, array) elif state == 'copy' and not snap: update_snapshot(module, array) elif state == 'absent' and snap: delete_snapshot(module, array) elif state == 'absent' and not snap: module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( hostgroup=dict(type='str', required=True), state=dict(type='str', default='present', choices=['absent', 'present']), host=dict(type='list'), volume=dict(type='list'), )) module = AnsibleModule(argument_spec, supports_check_mode=False) if not HAS_PURESTORAGE: module.fail_json( msg='purestorage sdk is required for this module in host') state = module.params['state'] array = get_system(module) hostgroup = get_hostgroup(module, array) if module.params['host']: try: for hst in module.params['host']: array.get_host(hst) except Exception: module.fail_json(msg='Host {0} not found'.format(hst)) if module.params['volume']: try: for vol in module.params['volume']: array.get_volume(vol) except Exception: module.fail_json(msg='Volume {0} not found'.format(vol)) if hostgroup and state == 'present': update_hostgroup(module, array) elif hostgroup and module.params['volume'] and state == 'absent': update_hostgroup(module, array) elif hostgroup and module.params['host'] and state == 'absent': update_hostgroup(module, array) elif hostgroup and state == 'absent': delete_hostgroup(module, array) elif hostgroup is None and state == 'absent': module.exit_json(changed=False) else: make_hostgroup(module, array)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( name=dict(type='str', required=True), target=dict(type='str'), overwrite=dict(type='bool', default=False), eradicate=dict(type='bool', default=False), state=dict(type='str', default='present', choices=['absent', 'present']), bw_qos=dict(type='str', aliases=['qos']), iops_qos=dict(type='str'), size=dict(type='str'), )) mutually_exclusive = [['size', 'target'], ['qos', 'target']] module = AnsibleModule(argument_spec, mutually_exclusive=mutually_exclusive, supports_check_mode=True) size = module.params['size'] bw_qos = module.params['bw_qos'] iops_qos = module.params['iops_qos'] state = module.params['state'] array = get_system(module) volume = get_volume(module, array) if not volume: destroyed = get_destroyed_volume(module, array) target = get_target(module, array) if state == 'present' and not volume and size: create_volume(module, array) elif state == 'present' and volume and (size or bw_qos or iops_qos): update_volume(module, array) elif state == 'present' and volume and target: copy_from_volume(module, array) elif state == 'present' and volume and not target: copy_from_volume(module, array) elif state == 'absent' and volume: delete_volume(module, array) elif state == 'absent' and destroyed: eradicate_volume(module, array) elif state == 'present' and not volume or not size: module.exit_json(changed=False) elif state == 'absent' and not volume: module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict(state=dict(type='str', default='enable', choices=['enable', 'disable']), )) module = AnsibleModule(argument_spec, supports_check_mode=False) array = get_system(module) if module.params['state'] == 'enable': enable_ra(module, array) else: disable_ra(module, array) module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update(dict( name=dict(type='str', required=True), host=dict(type='str', required=True), state=dict(type='str', default='present', choices=['absent', 'present']), user=dict(type='str'), notification=dict(type='str', choices=['inform', 'trap'], default='trap'), auth_passphrase=dict(type='str', no_log=True), auth_protocol=dict(type='str', choices=['MD5', 'SHA']), privacy_passphrase=dict(type='str', no_log=True), privacy_protocol=dict(type='str', choices=['AES', 'DES']), version=dict(type='str', default='v2c', choices=['v2c', 'v3']), community=dict(type='str'), )) required_together = [['auth_passphrase', 'auth_protocol'], ['privacy_passphrase', 'privacy_protocol']] required_if = [['version', 'v2c', ['community', 'host']], ['version', 'v3', ['host', 'user']]] module = AnsibleModule(argument_spec, required_together=required_together, required_if=required_if, supports_check_mode=True) state = module.params['state'] array = get_system(module) mgr_configured = False mgrs = array.list_snmp_managers() for mgr in range(0, len(mgrs)): if mgrs[mgr]['name'] == module.params['name']: mgr_configured = True break if module.params['version'] == "v3": if module.params['auth_passphrase'] and (8 > len(module.params['auth_passphrase']) > 32): module.fail_json(msg="auth_password must be between 8 and 32 characters") if module.params['privacy_passphrase'] and 8 > len(module.params['privacy_passphrase']) > 63: module.fail_json(msg="privacy_password must be between 8 and 63 characters") if state == 'absent' and mgr_configured: delete_manager(module, array) elif mgr_configured and state == 'present': update_manager(module, array) elif not mgr_configured and state == 'present': create_manager(module, array) else: module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( address=dict(type='str', required=True), enabled=dict(type='bool', default=True), state=dict(type='str', default='present', choices=['absent', 'present']), )) module = AnsibleModule(argument_spec, supports_check_mode=True) pattern = re.compile(r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$") if not pattern.match(module.params['address']): module.fail_json(msg='Valid email address not provided.') array = get_system(module) exists = False try: emails = array.list_alert_recipients() except Exception: module.fail_json(msg='Failed to get existing email list') for email in range(0, len(emails)): if emails[email]['name'] == module.params['address']: exists = True enabled = emails[email]['enabled'] break if module.params['state'] == 'present' and not exists: create_alert(module, array) elif module.params[ 'state'] == 'present' and exists and not enabled and module.params[ 'enabled']: enable_alert(module, array) elif module.params[ 'state'] == 'present' and exists and enabled and not module.params[ 'enabled']: disable_alert(module, array) elif module.params['state'] == 'absent' and exists: delete_alert(module, array) module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update(dict( uri=dict(type='list'), state=dict(type='str', default='present', choices=['absent', 'present']), enable=dict(type='bool', default=False), bind_password=dict(type='str', no_log=True), bind_user=dict(type='str'), base_dn=dict(type='str'), group_base=dict(type='str'), ro_group=dict(type='str'), sa_group=dict(type='str'), aa_group=dict(type='str'), )) required_together = [['uri', 'bind_password', 'bind_user', 'base_dn', 'group_base']] module = AnsibleModule(argument_spec, required_together=required_together, supports_check_mode=False) state = module.params['state'] array = get_system(module) ds_exists = False dirserv = array.get_directory_service() ds_enabled = dirserv['enabled'] if dirserv['base_dn']: ds_exists = True if state == 'absent' and ds_exists: delete_ds(module, array) elif ds_exists and module.params['enable'] and ds_enabled: update_ds(module, array) elif ds_exists and not module.params['enable'] and ds_enabled: disable_ds(module, array) elif ds_exists and module.params['enable'] and not ds_enabled: enable_ds(module, array) elif not ds_exists and state == 'present': create_ds(module, array) else: module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update(dict( address=dict(type='str', required=True), protocol=dict(type='str', choices=['tcp', 'tls', 'udp'], required=True), port=dict(type='str'), state=dict(type='str', default='present', choices=['absent', 'present']), )) module = AnsibleModule(argument_spec, supports_check_mode=False) array = get_system(module) if module.params['state'] == 'absent': delete_syslog(module, array) else: add_syslog(module, array) module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( name=dict(type='str', required=True), state=dict(type='str', default='present', choices=['present']), )) module = AnsibleModule(argument_spec, supports_check_mode=False) array = get_system(module) pattern = re.compile("^[a-zA-Z0-9]([a-zA-Z0-9-]{0,54}[a-zA-Z0-9])?$") if not pattern.match(module.params['name']): module.fail_json( msg= 'Array name {0} does not conform to array name rules. See documentation.' .format(module.params['name'])) if module.params['name'] != array.get()['array_name']: update_name(module, array) module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( role=dict(required=True, type='str', choices=[ 'array_admin', 'ops_admin', 'readonly', 'storage_admin' ]), state=dict(type='str', default='present', choices=['absent', 'present']), group_base=dict(type='str'), group=dict(type='str'), )) required_together = [['group', 'group_base']] module = AnsibleModule(argument_spec, required_together=required_together, supports_check_mode=False) state = module.params['state'] array = get_system(module) role_configured = False role = array.list_directory_services_roles(names=[module.params['role']]) if role['group'] is not None: role_configured = True if state == 'absent' and role_configured: delete_role(module, array) elif role_configured and state == 'present': update_role(module, array) elif not role_configured and state == 'present': create_role(module, array) else: module.exit_json(changed=False)
def main(): argument_spec = purefa_argument_spec() argument_spec.update(dict( gather_subset=dict(default='minimum', type='list',) )) module = AnsibleModule(argument_spec, supports_check_mode=False) array = get_system(module) subset = [test.lower() for test in module.params['gather_subset']] valid_subsets = ('all', 'minimum', 'config', 'performance', 'capacity', 'network', 'subnet', 'interfaces', 'hgroups', 'pgroups', 'hosts', 'admins', 'volumes', 'snapshots', 'pods', 'vgroups', 'offload', 'apps', 'arrays') subset_test = (test in valid_subsets for test in subset) if not all(subset_test): module.fail_json(msg="value must gather_subset must be one or more of: %s, got: %s" % (",".join(valid_subsets), ",".join(subset))) facts = {} if 'minimum' in subset or 'all' in subset: facts['default'] = generate_default_dict(array) if 'performance' in subset or 'all' in subset: facts['performance'] = generate_perf_dict(array) if 'config' in subset or 'all' in subset: facts['config'] = generate_config_dict(array) if 'capacity' in subset or 'all' in subset: facts['capacity'] = generate_capacity_dict(array) if 'network' in subset or 'all' in subset: facts['network'] = generate_network_dict(array) if 'subnet' in subset or 'all' in subset: facts['subnet'] = generate_subnet_dict(array) if 'interfaces' in subset or 'all' in subset: facts['interfaces'] = generate_interfaces_dict(array) if 'hosts' in subset or 'all' in subset: facts['hosts'] = generate_host_dict(array) if 'volumes' in subset or 'all' in subset: facts['volumes'] = generate_vol_dict(array) if 'snapshots' in subset or 'all' in subset: facts['snapshots'] = generate_snap_dict(array) if 'hgroups' in subset or 'all' in subset: facts['hgroups'] = generate_hgroups_dict(array) if 'pgroups' in subset or 'all' in subset: facts['pgroups'] = generate_pgroups_dict(array) if 'pods' in subset or 'all' in subset: facts['pods'] = generate_pods_dict(array) if 'admins' in subset or 'all' in subset: facts['admins'] = generate_admin_dict(array) if 'vgroups' in subset or 'all' in subset: facts['vgroups'] = generate_vgroups_dict(array) if 'offload' in subset or 'all' in subset: facts['nfs_offload'] = generate_nfs_offload_dict(array) facts['s3_offload'] = generate_s3_offload_dict(array) if 'apps' in subset or 'all' in subset: facts['apps'] = generate_apps_dict(array) if 'arrays' in subset or 'all' in subset: facts['arrays'] = generate_conn_array_dict(array) module.exit_json(ansible_facts={'ansible_purefa_facts': facts})
def main(): argument_spec = purefa_argument_spec() argument_spec.update( dict( state=dict(type='str', default='present', choices=['present', 'absent']), protocol=dict(type='str', default='nfs', choices=['nfs', 's3']), name=dict(type='str', required=True), initialize=dict(default=True, type='bool'), access_key=dict(type='str'), secret=dict(type='str', no_log=True), bucket=dict(type='str'), share=dict(type='str'), address=dict(type='str'), options=dict(type='str', default=''), )) required_if = [] if argument_spec['state'] == "present": required_if = [('protocol', 'nfs', ['address', 'share']), ('protocol', 's3', ['access_key', 'secret', 'bucket'])] module = AnsibleModule(argument_spec, required_if=required_if, supports_check_mode=False) array = get_system(module) api_version = array._list_available_rest_versions() if MIN_REQUIRED_API_VERSION not in api_version: module.fail_json( msg='FlashArray REST version not supported. ' 'Minimum version required: {0}'.format(MIN_REQUIRED_API_VERSION)) if not re.match(r"^[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9]$", module.params['name']) or len(module.params['name']) > 56: module.fail_json( msg='Target name invalid. ' 'Target name must be between 1 and 56 characters (alphanumeric and -) in length ' 'and begin and end with a letter or number. The name must include at least one letter.' ) if module.params['protocol'] == "s3": if not re.match( r"^[a-z0-9][a-z0-9.\-]*[a-z0-9]$", module.params['bucket']) or len(module.params['bucket']) > 63: module.fail_json( msg='Bucket name invalid. ' 'Bucket name must be between 3 and 63 characters ' '(ilowercase, alphanumeric, dash or period) in length ' 'and begin and end with a letter or number.') apps = array.list_apps() app_version = 0 all_good = False for app in range(0, len(apps)): if apps[app]['name'] == 'offload': if (apps[app]['enabled'] and apps[app]['status'] == 'healthy' and LooseVersion( apps[app]['version']) >= LooseVersion('5.2.0')): all_good = True app_version = apps[app]['version'] break if not all_good: module.fail_json( msg='Correct Offload app not installed or incorrectly configured') else: if LooseVersion(array.get()['version']) != LooseVersion(app_version): module.fail_json( msg= 'Offload app version must match Purity version. Please upgrade.' ) target = get_target(module, array) if module.params['state'] == 'present' and not target: target_count = len(array.list_offload()) # Currently only 1 offload target is supported # TODO: (SD) when more targets supported add in REST version check as well if target_count != 0: module.fail_json( msg='Currently only 1 Offload Target is supported.') create_offload(module, array) elif module.params['state'] == 'present' and target: update_offload(module, array) elif module.params['state'] == 'absent' and target: delete_offload(module, array) module.exit_json(changed=False)