Hello everyone. I have been working with the collection for ServiceNow and ansible for about a week or so and I’ve come across an issue I can’t seem to resolve. I’m using the ansible inventory plugin to get my inventory from cmdb. I would like to create groups for specific versions of the linux OS’s I have in my environment.
Unfortunately in CMDB we don’t capture the OS version either major or minor numbers in CMDB, But we do capture the uname -a which I can then parse out the major kernel version number I can can assume by that number which version of the OS it is.
The issue I have is I cannot seem to correct format the key so if the major number = “3” then the group name would be RHEL7 and major number =“4” would be RHEL8. The RHEL7 and RHEL8 are the group names I’m trying to build. But whatever I try won’t work.
Here is my existing code as it stands today for just RHEL7:
keyed_groups:
- key: u_network_zone | replace(‘-’, ‘_’)
trailing_separator: no - key: “{% if short_description.split(’ ‘)[2].split(’.')[0] == ‘3’ %}RHEL7{% endif %}”
trailing_separator: no
I tried a few other way of approaching this but none of them work. Has anyone tried this or have any suggestions? By the way, this collection is from Redhat and not the collection from GITHUB or galaxy. I see they are a tad bit different. I’m using 1.4.0 in case that matters
Thanks!
Glen