mirror of
https://github.com/ansible/awx.git
synced 2026-02-22 21:46:00 -03:30
don't assume insights id is a uuid
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from ansible.module_utils.basic import * # noqa
|
from ansible.module_utils.basic import * # noqa
|
||||||
import uuid
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: scan_insights
|
module: scan_insights
|
||||||
short_description: Return insights UUID as fact data
|
short_description: Return insights id as fact data
|
||||||
description:
|
description:
|
||||||
- Inspects the /etc/redhat-access-insights/machine-id file for insights uuid and returns the found UUID as fact data
|
- Inspects the /etc/redhat-access-insights/machine-id file for insights id and returns the found id as fact data
|
||||||
version_added: "2.3"
|
version_added: "2.3"
|
||||||
options:
|
options:
|
||||||
requirements: [ ]
|
requirements: [ ]
|
||||||
@@ -28,8 +27,8 @@ EXAMPLES = '''
|
|||||||
INSIGHTS_SYSTEM_ID_FILE='/etc/redhat-access-insights/machine-id'
|
INSIGHTS_SYSTEM_ID_FILE='/etc/redhat-access-insights/machine-id'
|
||||||
|
|
||||||
|
|
||||||
def get_system_uuid(filname):
|
def get_system_id(filname):
|
||||||
system_uuid = None
|
system_id = None
|
||||||
try:
|
try:
|
||||||
f = open(INSIGHTS_SYSTEM_ID_FILE, "r")
|
f = open(INSIGHTS_SYSTEM_ID_FILE, "r")
|
||||||
except IOError:
|
except IOError:
|
||||||
@@ -37,12 +36,12 @@ def get_system_uuid(filname):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
data = f.readline()
|
data = f.readline()
|
||||||
system_uuid = str(uuid.UUID(data))
|
system_id = str(data)
|
||||||
except (IOError, ValueError):
|
except (IOError, ValueError):
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
return system_uuid
|
return system_id
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -50,12 +49,12 @@ def main():
|
|||||||
argument_spec = dict()
|
argument_spec = dict()
|
||||||
)
|
)
|
||||||
|
|
||||||
system_uuid = get_system_uuid(INSIGHTS_SYSTEM_ID_FILE)
|
system_id = get_system_id(INSIGHTS_SYSTEM_ID_FILE)
|
||||||
|
|
||||||
results = {
|
results = {
|
||||||
'ansible_facts': {
|
'ansible_facts': {
|
||||||
'insights': {
|
'insights': {
|
||||||
'system_id': system_uuid
|
'system_id': system_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user