Skip to content

Commit 6860848

Browse files
committed
Add playbook to generate portal template files
1 parent 1530db6 commit 6860848

File tree

4 files changed

+150
-14
lines changed

4 files changed

+150
-14
lines changed

extensions/mcp/github_mcp/template_rhdh/server.yaml renamed to extensions/mcp/github-mcp-server/template_rhdh/server.yaml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
apiVersion: scaffolder.backstage.io/v1beta3
33
kind: Template
44
metadata:
5-
name: github_mcp
6-
title: GitHub MCP Server
7-
description: >-
8-
GitHub MCP server - Access GitHub repositories, issues, and pull requests.
5+
name: github-mcp-server
6+
title: github-mcp-server
7+
description: GitHub MCP Server - Access GitHub repositories, issues, and pull requests
98
namespace: default
109
tags:
1110
- aap-operations
@@ -15,8 +14,7 @@ spec:
1514
type: service
1615
parameters:
1716
- title: Prompts
18-
description: >-
19-
GitHub MCP server - Access GitHub repositories, issues, and pull requests.
17+
description: GitHub MCP Server - Access GitHub repositories, issues, and pull requests
2018
required:
2119
- token
2220
- inventory
@@ -50,21 +48,27 @@ spec:
5048
ui:field: AAPResourcePicker
5149
resource: credentials
5250
- title: Survey
53-
description: >-
54-
GitHub MCP server - Access GitHub repositories, issues, and pull requests.
51+
description: GitHub MCP Server - Access GitHub repositories, issues, and pull requests
5552
properties:
56-
github_mcp_repo:
57-
title: GitHub Repository URL
53+
source_repo:
54+
title: source_repo
5855
type: string
59-
description: URL of the GitHub repository for installing from
56+
description: source_repo
6057
ui:options:
6158
rows: 5
62-
github_mcp_branch:
63-
title: GitHub Repository Branch
59+
source_repo_branch:
60+
title: source_repo_branch
6461
type: string
65-
description: Branch of the GitHub repository for installing from
62+
description: source_repo_branch
6663
ui:options:
6764
rows: 5
65+
build_path:
66+
title: build_path
67+
type: string
68+
description: build_path
69+
ui:options:
70+
rows: 5
71+
6872
steps:
6973
- id: launch-job
7074
name: Launch Network Operations / Create Full Network Backup

playbooks/generate_template.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
- name: Generate portal template files
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
7+
vars:
8+
mcp_roles:
9+
- github_mcp
10+
11+
tasks:
12+
- name: Load MCP roles to gain access to defaults
13+
ansible.builtin.include_role:
14+
name: "{{ item }}"
15+
tasks_from: noop # don't know why this doesn't do anything
16+
public: true
17+
apply:
18+
ignore_errors: true # there should be a better way of doing this
19+
loop: "{{ mcp_roles }}"
20+
21+
- name: Zip registry with details
22+
ansible.builtin.set_fact:
23+
{
24+
"{{ item }}": "{{ lookup('vars', item + '_registry') | zip(lookup('vars', item + '_build_details')) }}",
25+
}
26+
loop: "{{mcp_roles }}"
27+
28+
- name: Combine role registries
29+
ansible.builtin.set_fact:
30+
registries: "{{ registries | default([]) | union(lookup('vars', item)) }}"
31+
loop: "{{ mcp_roles }}"
32+
33+
- name: Create destination directories
34+
ansible.builtin.file:
35+
dest: "{{ lookup('env', 'PWD') }}/extensions/mcp/{{ item[0].name }}/template_rhdh/"
36+
state: directory
37+
mode: "0755"
38+
loop: "{{ registries }}"
39+
40+
- name: Template each registry
41+
ansible.builtin.template:
42+
src: server.yaml.j2
43+
dest: "{{ lookup('env', 'PWD') }}/extensions/mcp/{{ item[0].name }}/template_rhdh/server.yaml"
44+
mode: "0644"
45+
lstrip_blocks: true
46+
loop: "{{ registries }}"

playbooks/server.yaml.j2

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
apiVersion: scaffolder.backstage.io/v1beta3
3+
kind: Template
4+
metadata:
5+
name: {{ item[0].name }}
6+
title: {{ item[0].name }}
7+
description: {{ item[0].description }}
8+
namespace: default
9+
tags:
10+
- aap-operations
11+
- intermediate
12+
- mcp
13+
spec:
14+
type: service
15+
parameters:
16+
- title: Prompts
17+
description: {{ item[0].description }}
18+
required:
19+
- token
20+
- inventory
21+
- credentials
22+
properties:
23+
token:
24+
title: Token
25+
type: string
26+
description: Oauth2 token
27+
ui:field: AAPTokenField
28+
ui:widget: password
29+
ui:backstage:
30+
review:
31+
show: false
32+
inventory:
33+
title: Inventory
34+
description: Please enter the inventory you want to use the services on
35+
resource: inventories
36+
ui:field: AAPResourcePicker
37+
credentials:
38+
title: Credentials
39+
description: >-
40+
Select credentials for accessing the nodes this job will be ran
41+
against. You can only select one credential of each type. For
42+
machine credentials (SSH), checking "Prompt on launch" without
43+
selecting credentials will require you to select a machine
44+
credential at run time. If you select credentials and check "Prompt
45+
on launch", the selected credential(s) become the defaults that can
46+
be updated at run time.
47+
type: array
48+
ui:field: AAPResourcePicker
49+
resource: credentials
50+
- title: Survey
51+
description: {{ item[0].description }}
52+
properties:
53+
{% for key, value in item[1].items() %}
54+
{{ key }}:
55+
title: {{ key }}
56+
type: string
57+
description: {{ key }}
58+
ui:options:
59+
rows: 5
60+
{% endfor %}
61+
{% raw %}
62+
steps:
63+
- id: launch-job
64+
name: Launch Network Operations / Create Full Network Backup
65+
action: rhaap:launch-job-template
66+
input:
67+
token: ${{ parameters.token }}
68+
values:
69+
templateID: null
70+
inventory: ${{ parameters.inventory }}
71+
credentials: ${{ parameters.credentials }}
72+
extraVariables:
73+
github_mcp_repo: ${{ parameters.github_mcp_repo }}
74+
github_mcp_branch: ${{ parameters.github_mcp_branch }}
75+
output:
76+
text:
77+
- title: Create execution environment template executed successfully
78+
content: |
79+
**Job ID:** ${{ steps['launch-job'].output.data.id }}
80+
**Job STATUS:** ${{ steps['launch-job'].output.data.status }}
81+
links:
82+
- title: View in RH AAP
83+
url: ${{ steps['launch-job'].output.data.url }}
84+
{% endraw %}

roles/github_mcp/tasks/noop.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# Do nothing

0 commit comments

Comments
 (0)