mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 08:37:48 -02:30
Add service account support to Insights credential
Adds fields client_id and client_secret which will result in authentication via service account on console.redhat.com Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
committed by
Chris Meyers
parent
22ecb2030c
commit
edba126193
@@ -1039,30 +1039,68 @@ ManagedCredentialType(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
ManagedCredentialType(
|
insights = ManagedCredentialType(
|
||||||
namespace='insights',
|
namespace='insights',
|
||||||
kind='insights',
|
kind='insights',
|
||||||
name=gettext_noop('Insights'),
|
name=gettext_noop('Insights'),
|
||||||
managed=True,
|
managed=True,
|
||||||
inputs={
|
inputs={
|
||||||
'fields': [
|
'fields': [
|
||||||
{'id': 'username', 'label': gettext_noop('Username'), 'type': 'string'},
|
{
|
||||||
{'id': 'password', 'label': gettext_noop('Password'), 'type': 'string', 'secret': True},
|
'id': 'username',
|
||||||
|
'label': gettext_noop('Username'),
|
||||||
|
'type': 'string',
|
||||||
|
'help_text': gettext_noop(
|
||||||
|
'Required for basic authentication. ' 'May be blank if using client_id and client_secret',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'password',
|
||||||
|
'label': gettext_noop('Password'),
|
||||||
|
'type': 'string',
|
||||||
|
'secret': True,
|
||||||
|
'help_text': gettext_noop(
|
||||||
|
'Required for basic authentication. ' 'May be blank if using client_id and client_secret',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'client_id',
|
||||||
|
'label': gettext_noop('Client ID'),
|
||||||
|
'type': 'string',
|
||||||
|
'help_text': gettext_noop(
|
||||||
|
'Required for service account authentication. ' 'May be blank if using username and password',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'client_secret',
|
||||||
|
'label': gettext_noop('Client Secret'),
|
||||||
|
'type': 'string',
|
||||||
|
'secret': True,
|
||||||
|
'help_text': gettext_noop(
|
||||||
|
'Required for service account authentication. ' 'May be blank if using username and password',
|
||||||
|
),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
'required': ['username', 'password'],
|
'required': [],
|
||||||
},
|
},
|
||||||
injectors={
|
injectors={
|
||||||
'extra_vars': {
|
'extra_vars': {
|
||||||
"scm_username": "{{username}}",
|
'scm_username': '{{username}}',
|
||||||
"scm_password": "{{password}}",
|
'scm_password': '{{password}}',
|
||||||
|
'client_id': '{{client_id}}',
|
||||||
|
'client_secret': '{{client_secret}}',
|
||||||
|
'authentication': '{% if client_id %}service_account{% else %}basic{% endif %}',
|
||||||
},
|
},
|
||||||
'env': {
|
'env': {
|
||||||
'INSIGHTS_USER': '{{username}}',
|
'INSIGHTS_USER': '{{username}}',
|
||||||
'INSIGHTS_PASSWORD': '{{password}}',
|
'INSIGHTS_PASSWORD': '{{password}}',
|
||||||
|
'INSIGHTS_CLIENT_ID': '{{client_id}}',
|
||||||
|
'INSIGHTS_CLIENT_SECRET': '{{client_secret}}',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
ManagedCredentialType(
|
ManagedCredentialType(
|
||||||
namespace='rhv',
|
namespace='rhv',
|
||||||
kind='cloud',
|
kind='cloud',
|
||||||
|
|||||||
@@ -1695,6 +1695,14 @@ class insights(PluginFileInjector):
|
|||||||
downstream_collection = 'insights'
|
downstream_collection = 'insights'
|
||||||
use_fqcn = True
|
use_fqcn = True
|
||||||
|
|
||||||
|
def inventory_as_dict(self, inventory_update, private_data_dir):
|
||||||
|
inventory_data = super().inventory_as_dict(inventory_update, private_data_dir)
|
||||||
|
credential = inventory_update.get_cloud_credential()
|
||||||
|
if credential.get_input('client_id', default=''):
|
||||||
|
inventory_data['authentication'] = 'service_account'
|
||||||
|
|
||||||
|
return inventory_data
|
||||||
|
|
||||||
|
|
||||||
class openshift_virtualization(PluginFileInjector):
|
class openshift_virtualization(PluginFileInjector):
|
||||||
plugin_name = 'kubevirt'
|
plugin_name = 'kubevirt'
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
"INSIGHTS_USER": "fooo",
|
"INSIGHTS_USER": "fooo",
|
||||||
"INSIGHTS_PASSWORD": "fooo"
|
"INSIGHTS_PASSWORD": "fooo",
|
||||||
|
"INSIGHTS_CLIENT_ID": "fooo",
|
||||||
|
"INSIGHTS_CLIENT_SECRET": "fooo"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user