You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-role-conductor-work.../templates/create_system_service.json.j2

117 lines
4.0 KiB
Django/Jinja

{
"ownerApp" : "Orchestrator",
"name" : "create_system_service",
"createBy" : "Marco Lettere",
"description": "Create a confidential client for software procedures that need to be members of each VO and VRE",
"version" : 1,
"ownerEmail" : "marco.lettere@nubisware.com",
"inputParameters" : ["client_id", "client_secret", "description"],
"tasks" : [
{
"name": "INLINE_TASK",
"taskReferenceName": "init",
"type": "INLINE",
"inputParameters": {
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
"id" : "${workflow.input.client_id}",
"secret" : "${workflow.input.client_secret}",
"description" : "${workflow.input.description}",
"evaluatorType" : "javascript",
"expression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; function f(){ if(e($.id)) throw('Client ID must not be empty'); return { client : { clientId : $.id, description : ($.description ? $.description : $.id), secret : ($.secret ? $.secret : Java.type('java.util.UUID').randomUUID().toString()), rootUrl : '', enabled : true, serviceAccountsEnabled : true, standardFlowEnabled : true, authorizationServicesEnabled : false, publicClient : false, fullScopeAllowed : true, protocol : 'openid-connect'}}}; f()"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "authorize",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${init.input.keycloak}/protocol/openid-connect/token",
"method" : "POST",
"headers" : {
"Accept" : "application/json"
},
"body" : {
"client_id" : "orchestrator",
"client_secret" : "{{ keycloak_auth }}",
"grant_type" : "client_credentials"
}
}
},
{
"name" : "pyrest",
"taskReferenceName" : "create_client",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${init.input.keycloak_admin}/clients",
"body" : "${init.output.result.client}",
"method" : "POST",
"headers" : {
"Authorization" : "Bearer ${authorize.output.body.access_token}",
"Content-Type" : "application/json"
}
}
},
{
"name": "INLINE_TASK",
"taskReferenceName": "extract_client_id",
"type": "INLINE",
"inputParameters": {
"evaluatorType" : "javascript",
"client_location" : "${create_client.output.headers.location}",
"expression": "var client_id = $.client_location.split('/').pop(); function f(){return {'client_id' : client_id}}; f()"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "get_service_account_user",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${init.input.keycloak_admin}/clients/${extract_client_id.output.result.client_id}/service-account-user",
"method" : "GET",
"headers" : {
"Authorization" : "Bearer ${authorize.output.body.access_token}",
"Accept" : "application/json"
}
}
},
{
"name" : "pyrest",
"type" : "SIMPLE",
"taskReferenceName": "retrieve_infra_member_role",
"inputParameters" : {
"url" : "${init.input.keycloak_admin}/roles/Infrastructure-Member",
"method" :"GET",
"headers" : {
"Authorization" : "Bearer ${authorize.output.body.access_token}",
"Accept" : "application/json"
}
}
},
{
"name": "jq_1",
"taskReferenceName": "to_array",
"type": "JSON_JQ_TRANSFORM",
"inputParameters": {
"role": "${retrieve_infra_member_role.output.body}",
"queryExpression" : ".role"
}
},
{
"name" : "pyrest",
"type" : "SIMPLE",
"taskReferenceName": "assign_infra_member_role",
"inputParameters" : {
"url" : "${init.input.keycloak_admin}/users/${get_service_account_user.output.body.id}/role-mappings/realm",
"method" :"POST",
"headers" : {
"Authorization" : "Bearer ${authorize.output.body.access_token}",
"Content-Type" : "application/json",
"Accept":"application/json"
},
"body" : "${to_array.output.resultList}"
}
}
]
}