Add support for Insights as an inventory source

This commit is contained in:
Bill Nottingham
2021-05-21 00:03:43 -04:00
parent f26d975005
commit be18803250
9 changed files with 148 additions and 1 deletions

View File

@@ -954,6 +954,10 @@ ManagedCredentialType(
"scm_username": "{{username}}",
"scm_password": "{{password}}",
},
'env': {
'INSIGHTS_USER': '{{username}}',
'INSIGHTS_PASSWORD': '{{password}}',
},
},
)

View File

@@ -828,6 +828,7 @@ class InventorySourceOptions(BaseModel):
('openstack', _('OpenStack')),
('rhv', _('Red Hat Virtualization')),
('tower', _('Ansible Tower')),
('insights', _('Red Hat Insights')),
]
# From the options of the Django management base command
@@ -1548,5 +1549,21 @@ class tower(PluginFileInjector):
collection = 'awx'
class insights(PluginFileInjector):
plugin_name = 'insights'
base_injector = 'template'
namespace = 'redhatinsights'
collection = 'insights'
downstream_namespace = 'redhat'
downstream_collection = 'insights'
use_fqcn = 'true'
def inventory_as_dict(self, inventory_update, private_data_dir):
ret = super(insights, self).inventory_as_dict(inventory_update, private_data_dir)
# this inventory plugin requires the fully qualified inventory plugin name
ret['plugin'] = f'{self.namespace}.{self.collection}.{self.plugin_name}'
return ret
for cls in PluginFileInjector.__subclasses__():
InventorySourceOptions.injectors[cls.__name__] = cls