Skip to content

Commit 4f580c9

Browse files
committed
refactor: update implementation of bundle info command
Signed-off-by: Gerard Vanloo <gerard.vanloo@ibm.com>
1 parent b763cb4 commit 4f580c9

File tree

3 files changed

+94
-49
lines changed

3 files changed

+94
-49
lines changed

sre/Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ launch_start_workflow: ## Launches the AWX workflow's equivalent of make start_i
107107
launch_stop_workflow: ## Launches the AWX workflow's equivalent of make stop_incident
108108
ansible-playbook -i inventory.yaml playbooks/manage_awx.yaml --tags "launch_stop_workflow"
109109

110+
.PHONY: generate_agent_bundle
111+
generate_agent_bundle: ## Generates a bundle for an LLM Agent to interface with
112+
ansible-playbook -i inventory.yaml playbooks/generate_agent_bundle.yaml
113+
110114
# TODO: See why the OBJC_DISABLE_INITIALIZE_FORK_SAFETY is needed
111115

112116
.PHONY: incident documentation
@@ -170,10 +174,6 @@ bundle_status:
170174
cat roles/bundle_status/status-${INCIDENT_NUMBER}.json
171175
rm roles/bundle_status/status-${INCIDENT_NUMBER}.json
172176

173-
.SILENT: bundle_info
174-
bundle_info:
175-
ANSIBLE_STDOUT_CALLBACK=json ansible-playbook base.yaml --tags "get_bundle_info" --extra-vars "run_uuid=${RUN_UUID} sre_agent_name__version_number=${PARTICIPANT_AGENT_UUID} scenario_number=${INCIDENT_NUMBER} run_number=1 s3_bucket_name_for_results='sre-runner-with-awx' sre_bench_runner=true kubeconfig=/tmp/${CLUSTER_ASSIGNED_NAME}.yaml s3_endpoint_url='https://s3.us-east-2.amazonaws.com'" | jq '.plays[].tasks[] | select(.task.name == "bundle_info : Return grafana url").hosts.localhost.msg'
176-
177177
.PHONY: deploy_observability_stack
178178
deploy_observability_stack: ## DEPRECATED: Deploys the observability tools to cluster
179179
@echo "WARNING: 'make deploy_observability_stack' is deprecated. Please use 'make deploy_environment_tools' instead."
@@ -273,3 +273,11 @@ e2e_awx_stage_three: ## DEPRECATED: Given an incident number, run_uuid end the s
273273
@echo "Executing 'make launch_stop_workflow'..."
274274
@echo ""
275275
$(MAKE) launch_stop_workflow
276+
277+
.SILENT: bundle_info
278+
bundle_info:
279+
@echo "WARNING: 'make bundle_info is deprecated. Please use 'make generate_agent_bundle' instead."
280+
@echo "This command will be removed in a future version."
281+
@echo "Executing 'make generate_agent_bundle'..."
282+
@echo ""
283+
$(MAKE) generate_agent_bundle
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
- name: Manage SRE and FinOps Incident Environment Tool Stack
3+
hosts:
4+
- environment
5+
pre_tasks:
6+
- name: Import system role
7+
ansible.builtin.import_role:
8+
name: system
9+
tags:
10+
- always
11+
vars:
12+
system_cluster:
13+
kubeconfig: "{{ cluster.kubeconfig }}"
14+
15+
- name: Validate that storage is configured
16+
ansible.builtin.assert:
17+
that: "storage.local is defined or storage.s3 is defined"
18+
fail_msg: Storage has not been configured. Please assign either local or s3 bucket storage.
19+
success_msg: Storage is configured.
20+
tasks:
21+
- name: Include Helm Release variables from tools role
22+
ansible.builtin.include_vars:
23+
file: ../roles/tools/defaults/main/helm_releases.yaml
24+
25+
- name: Get Service object for the Ingress controller
26+
kubernetes.core.k8s_info:
27+
api_version: v1
28+
kind: Service
29+
name: "{{ tools_helm_releases.ingress.name }}"
30+
namespace: "{{ tools_helm_releases.ingress.namespace }}"
31+
kubeconfig: "{{ cluster.kubeconfig }}"
32+
wait: true
33+
register: service_info
34+
until:
35+
- service_info.resources[0].status.loadBalancer.ingress is defined
36+
delay: 15
37+
retries: 12
38+
39+
- name: Extract the Ingress hostname information
40+
ansible.builtin.set_fact:
41+
ingress_hostname: "{{ service_info.resources[0].status.loadBalancer.ingress[0].hostname }}"
42+
when:
43+
- service_info.resources[0].status.loadBalancer.ingress | length > 0
44+
- service_info.resources[0].status.loadBalancer.ingress[0].hostname is defined
45+
46+
- name: Copy restricted kubeconfig into temporary directory from S3 bucket
47+
amazon.aws.s3_object:
48+
endpoint_url: "{{ storage.s3.endpoint }}"
49+
bucket: "{{ storage.s3.bucket }}"
50+
object: "/{{ storage.s3.directory }}/kubeconfig"
51+
dest: /tmp/kubeconfig
52+
mode: get
53+
register: bucket_retrieval_result
54+
until:
55+
- bucket_retrieval_result.contents != ""
56+
retries: 3
57+
delay: 60
58+
when:
59+
- storage.s3 is defined
60+
61+
- name: Copy restricted kubeconfig into temporary directory from local directory
62+
ansible.builtin.copy:
63+
dest: /tmp/kubeconfig
64+
mode: "0644"
65+
src: "{{ storage.local.directory }}/kubeconfig"
66+
when:
67+
- storage.local is defined
68+
69+
- name: Print agent bundle
70+
ansible.builtin.debug:
71+
msg: |
72+
{{
73+
{
74+
"prometheus_url": "http://" + ingress_hostname + "/prometheus",
75+
"kubeconfig": lookup("ansible.builtin.file", "/tmp/kubeconfig")
76+
}
77+
}}
78+
vars:
79+
restricted_kubeconfig_exists: "{{ '/tmp/kubeconfig' is exists }}"
80+
when:
81+
- ingress_hostname is defined
82+
- restricted_kubeconfig_exists

sre/roles/bundle_info/tasks/main.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)