mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Update purefa_facts to collect admin accounts (#52856)
This commit is contained in:
parent
7c0bc9e4ac
commit
8062b9c0f3
1 changed files with 35 additions and 4 deletions
|
@ -30,7 +30,7 @@ options:
|
||||||
- When supplied, this argument will define the facts to be collected.
|
- When supplied, this argument will define the facts to be collected.
|
||||||
Possible values for this include all, minimum, config, performance,
|
Possible values for this include all, minimum, config, performance,
|
||||||
capacity, network, subnet, interfaces, hgroups, pgroups, hosts,
|
capacity, network, subnet, interfaces, hgroups, pgroups, hosts,
|
||||||
volumes, snapshots, pods, vgroups, offload and apps.
|
admins, volumes, snapshots, pods, vgroups, offload and apps.
|
||||||
required: false
|
required: false
|
||||||
default: minimum
|
default: minimum
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
|
@ -352,6 +352,7 @@ def generate_default_dict(array):
|
||||||
default_facts['pods'] = len(array.list_pods())
|
default_facts['pods'] = len(array.list_pods())
|
||||||
default_facts['connection_key'] = array.get(connection_key=True)['connection_key']
|
default_facts['connection_key'] = array.get(connection_key=True)['connection_key']
|
||||||
hosts = array.list_hosts()
|
hosts = array.list_hosts()
|
||||||
|
admins = array.list_admins()
|
||||||
snaps = array.list_volumes(snap=True, pending=True)
|
snaps = array.list_volumes(snap=True, pending=True)
|
||||||
pgroups = array.list_pgroups(pending=True)
|
pgroups = array.list_pgroups(pending=True)
|
||||||
hgroups = array.list_hgroups()
|
hgroups = array.list_hgroups()
|
||||||
|
@ -369,6 +370,7 @@ def generate_default_dict(array):
|
||||||
default_facts['snapshots'] = len(snaps)
|
default_facts['snapshots'] = len(snaps)
|
||||||
default_facts['protection_groups'] = len(pgroups)
|
default_facts['protection_groups'] = len(pgroups)
|
||||||
default_facts['hostgroups'] = len(hgroups)
|
default_facts['hostgroups'] = len(hgroups)
|
||||||
|
default_facts['admins'] = len(admins)
|
||||||
return default_facts
|
return default_facts
|
||||||
|
|
||||||
|
|
||||||
|
@ -403,6 +405,7 @@ def generate_perf_dict(array):
|
||||||
|
|
||||||
def generate_config_dict(array):
|
def generate_config_dict(array):
|
||||||
config_facts = {}
|
config_facts = {}
|
||||||
|
api_version = array._list_available_rest_versions()
|
||||||
# DNS
|
# DNS
|
||||||
config_facts['dns'] = array.get_dns()
|
config_facts['dns'] = array.get_dns()
|
||||||
# SMTP
|
# SMTP
|
||||||
|
@ -411,7 +414,18 @@ def generate_config_dict(array):
|
||||||
config_facts['snmp'] = array.list_snmp_managers()
|
config_facts['snmp'] = array.list_snmp_managers()
|
||||||
# DS
|
# DS
|
||||||
config_facts['directory_service'] = array.get_directory_service()
|
config_facts['directory_service'] = array.get_directory_service()
|
||||||
config_facts['directory_service'].update(array.get_directory_service(groups=True))
|
if S3_REQUIRED_API_VERSION in api_version:
|
||||||
|
config_facts['directory_service_roles'] = {}
|
||||||
|
roles = array.list_directory_service_roles()
|
||||||
|
for role in range(0, len(roles)):
|
||||||
|
role_name = roles[role]['name']
|
||||||
|
config_facts['directory_service_roles'][role_name] = {
|
||||||
|
'group': roles[role]['group'],
|
||||||
|
'group_base': roles[role]['group_base'],
|
||||||
|
}
|
||||||
|
config_facts['directory_service'].update(array.list_directory_service_roles())
|
||||||
|
else:
|
||||||
|
config_facts['directory_service'].update(array.get_directory_service(groups=True))
|
||||||
# NTP
|
# NTP
|
||||||
config_facts['ntp'] = array.get(ntpserver=True)['ntpserver']
|
config_facts['ntp'] = array.get(ntpserver=True)['ntpserver']
|
||||||
# SYSLOG
|
# SYSLOG
|
||||||
|
@ -432,9 +446,24 @@ def generate_config_dict(array):
|
||||||
config_facts['scsi_timeout'] = array.get(scsi_timeout=True)['scsi_timeout']
|
config_facts['scsi_timeout'] = array.get(scsi_timeout=True)['scsi_timeout']
|
||||||
# SSL
|
# SSL
|
||||||
config_facts['ssl_certs'] = array.get_certificate()
|
config_facts['ssl_certs'] = array.get_certificate()
|
||||||
|
# Global Admin settings
|
||||||
|
if S3_REQUIRED_API_VERSION in api_version:
|
||||||
|
config_facts['global_admin'] = array.get_global_admin_attributes()
|
||||||
return config_facts
|
return config_facts
|
||||||
|
|
||||||
|
|
||||||
|
def generate_admin_dict(array):
|
||||||
|
admin_facts = {}
|
||||||
|
admins = array.list_admins()
|
||||||
|
for admin in range(0, len(admins)):
|
||||||
|
admin_name = admins[admin]['name']
|
||||||
|
admin_facts[admin_name] = {
|
||||||
|
'type': admins[admin]['type'],
|
||||||
|
'role': admins[admin]['role'],
|
||||||
|
}
|
||||||
|
return admin_facts
|
||||||
|
|
||||||
|
|
||||||
def generate_subnet_dict(array):
|
def generate_subnet_dict(array):
|
||||||
sub_facts = {}
|
sub_facts = {}
|
||||||
subnets = array.list_subnets()
|
subnets = array.list_subnets()
|
||||||
|
@ -700,8 +729,8 @@ def main():
|
||||||
subset = [test.lower() for test in module.params['gather_subset']]
|
subset = [test.lower() for test in module.params['gather_subset']]
|
||||||
valid_subsets = ('all', 'minimum', 'config', 'performance', 'capacity',
|
valid_subsets = ('all', 'minimum', 'config', 'performance', 'capacity',
|
||||||
'network', 'subnet', 'interfaces', 'hgroups', 'pgroups',
|
'network', 'subnet', 'interfaces', 'hgroups', 'pgroups',
|
||||||
'hosts', 'volumes', 'snapshots', 'pods', 'vgroups',
|
'hosts', 'admins', 'volumes', 'snapshots', 'pods',
|
||||||
'offload', 'apps')
|
'vgroups', 'offload', 'apps')
|
||||||
subset_test = (test in valid_subsets for test in subset)
|
subset_test = (test in valid_subsets for test in subset)
|
||||||
if not all(subset_test):
|
if not all(subset_test):
|
||||||
module.fail_json(msg="value must gather_subset must be one or more of: %s, got: %s"
|
module.fail_json(msg="value must gather_subset must be one or more of: %s, got: %s"
|
||||||
|
@ -735,6 +764,8 @@ def main():
|
||||||
facts['pgroups'] = generate_pgroups_dict(array)
|
facts['pgroups'] = generate_pgroups_dict(array)
|
||||||
if 'pods' in subset or 'all' in subset:
|
if 'pods' in subset or 'all' in subset:
|
||||||
facts['pods'] = generate_pods_dict(array)
|
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:
|
if 'vgroups' in subset or 'all' in subset:
|
||||||
facts['vgroups'] = generate_vgroups_dict(array)
|
facts['vgroups'] = generate_vgroups_dict(array)
|
||||||
if 'offload' in subset or 'all' in subset:
|
if 'offload' in subset or 'all' in subset:
|
||||||
|
|
Loading…
Reference in a new issue