Open Shkrelic opened 1 month ago
@Shkrelic Hello. Thanks for the issue. I'm working on it but I have problems mocking your data model.
I've created a new table u_flattened_ci_rel
with:
parent
field reference to cmdb_ci_app_server_tomcat
child
reference to cmdb_ci_ec2_instance
Is this layout the same as yours?
As a result, I have:
ansible-inventory -i now.yml --list
{
"_meta": {
"hostvars": {
"i101": {
"sys_id": "f9fc8d0633a8d210392d0e570e5c7bff",
"u_child_ip_address": "10.1.0.101",
"u_child_name": "i101",
"u_level": "1",
"u_parent": "tomcat_pxgnodig",
"u_parent_name": "tomcat_pxgnodig",
"u_parent_support_group": "Application Development",
"u_type": "active"
}
}
},
"all": {
"children": [
"ungrouped"
]
},
"ungrouped": {
"hosts": [
"i101"
]
}
}
i101
should have 2 tomcats but got only one. I think this confirms the issue.
Could you paste the whole output please?
SUMMARY
When pulling records with duplicate key/hostnames, lists should be used in appropriate fields, rather than strings.
For example, when using the u_flattned_ci_rel table to find application/server mappings, u_child can be utilized as the inventory_hostname_source. This creates a problem which overwrites the field with the last query results. I did not open this as a bug as it seems like it is probably working as intended.
ISSUE TYPE
COMPONENT NAME
inventory plugin - servicenow.itsm.now
ADDITIONAL INFORMATION
This feature would be extremely useful to map application relationships and required support groups when making OS level changes to the Runs on:runs host running/serving an application/DB.
For example;
prd-server01 runs apache webserver prd-server01 runs tomcat webserver
inventory should create the following when pulling from this table using u_child as the inventory_hostname_source:
Expected:
Actual:
EXAMPLE