Skip to content

Commit 832a013

Browse files
committed
DIAB test
1 parent b2b0f3d commit 832a013

File tree

2 files changed

+163
-0
lines changed

2 files changed

+163
-0
lines changed

playbook.yaml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
- hosts: localhost
3+
gather_facts: false
4+
5+
pre_tasks:
6+
- name: set the required vars
7+
set_fact:
8+
eu0_ingest_token: "{{ lookup('env','ACCESS_TOKEN') }}"
9+
eu0_rum_token: "i{{ lookup('env','RUM_TOKEN') }}"
10+
eu0_realm: "{{ lookup('env','REALM') }}"
11+
o11y_env_name: "{{ lookup('env','INSTANCE') }}"
12+
o11y_diabversion: "demo-in-a-box-2.0"
13+
14+
tasks:
15+
- name: check to see if the config has run
16+
stat:
17+
path: /white_rabbit.followed
18+
register: wh_result
19+
20+
- name: wait for dpkg to be unlocked
21+
become: yes
22+
shell: while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1; do sleep 5; done;
23+
when: not wh_result.stat.exists
24+
25+
- name: download demo-in-a-box bits
26+
get_url:
27+
url: "https://demoinabox-tst.s3.us-east-2.amazonaws.com/{{ o11y_diabversion }}.zip"
28+
dest: /home/ubuntu/demo-in-a-box.zip
29+
become: yes
30+
when: not wh_result.stat.exists
31+
32+
- name: extract demo-in-a-box into /home/ubuntu/
33+
unarchive:
34+
src: demo-in-a-box.zip
35+
dest: /home/ubuntu/
36+
owner: ubuntu
37+
group: ubuntu
38+
remote_src: yes
39+
list_files: yes
40+
become: yes
41+
register: diab_dir_name
42+
when: not wh_result.stat.exists
43+
44+
- debug:
45+
var: diab_dir_name.files[0]
46+
when: not wh_result.stat.exists
47+
48+
- name: delete the servicefile for demoinabox.service
49+
file:
50+
state: absent
51+
path: /etc/systemd/system/demoinabox.service
52+
become: yes
53+
when: not wh_result.stat.exists
54+
55+
- name: create servicefile for demoinabox.service
56+
file:
57+
path: /etc/systemd/system/demoinabox.service
58+
state: touch
59+
become: yes
60+
when: not wh_result.stat.exists
61+
62+
- name: update servicefile for demoinabox.service
63+
ansible.builtin.blockinfile:
64+
path: /etc/systemd/system/demoinabox.service
65+
block: |
66+
[Unit]
67+
Description=demoinabox service
68+
After=network.target
69+
StartLimitIntervalSec=0
70+
[Service]
71+
Type=simple
72+
Restart=always
73+
RestartSec=1
74+
User=ubuntu
75+
Environment="KUBECONFIG=/home/ubuntu/.kube/config"
76+
WorkingDirectory=/home/ubuntu/{{ diab_dir_name.files[0] }}democonsole
77+
ExecStart=/usr/bin/flask run -p 8081 --host=0.0.0.0
78+
[Install]
79+
WantedBy=multi-user.target
80+
marker: "## {mark} added by ansible (configuration demo-in-a-box)"
81+
become: yes
82+
when: not wh_result.stat.exists
83+
84+
- name: install democonsole dependencies
85+
command: python3 -m pip install -r requirements.txt
86+
args:
87+
chdir: "/home/ubuntu/{{ diab_dir_name.files[0] }}democonsole/"
88+
when: not wh_result.stat.exists
89+
90+
- name: install democonsole dependencies
91+
command: helm repo add splunk-otel-collector-chart https://signalfx.github.io/splunk-otel-collector-chart
92+
when: not wh_result.stat.exists
93+
94+
- name: helm repo update
95+
command: helm repo update
96+
when: not wh_result.stat.exists
97+
98+
- name: start the demoinabox service
99+
command: systemctl enable --now demoinabox.service
100+
become: yes
101+
when: not wh_result.stat.exists
102+
103+
- name: chill out for 30 seconds to let the diab service start
104+
pause:
105+
seconds: 30
106+
when: not wh_result.stat.exists
107+
108+
- name: request config save with required vars - eu0
109+
uri:
110+
url: "http://localhost:8081/saveConfig"
111+
method: POST
112+
body: "realm={{ eu0_realm }}&accessToken={{ eu0_ingest_token }}&rumAccessToken={{ eu0_rum_token }}&environment={{ o11y_env_name }}&loadgenLocation=aws"
113+
status_code: [ 200, 201 ]
114+
timeout: 30
115+
when: not wh_result.stat.exists
116+
117+
- name: run the inital config
118+
uri:
119+
url: "http://localhost:8081/startCollector"
120+
method: GET
121+
status_code: [ 200, 201 ]
122+
timeout: 30
123+
when: not wh_result.stat.exists
124+
125+
- name: chill out for 120 seconds to let the OTEL collector start
126+
pause:
127+
seconds: 120
128+
when: not wh_result.stat.exists
129+
130+
- name: start the frontend demo
131+
uri:
132+
url: "http://localhost:8081/startdemo?demo=frontend"
133+
method: GET
134+
status_code: [ 200, 201 ]
135+
timeout: 30
136+
when: not wh_result.stat.exists
137+
138+
- name: chill out and let the frontend demo start
139+
pause:
140+
seconds: 90
141+
when: not wh_result.stat.exists
142+
143+
- name: wait for the hipster shop to become available
144+
uri:
145+
url: "http://localhost:81"
146+
method: GET
147+
validate_certs: no
148+
status_code: 200
149+
return_content: no
150+
register: splunk_ui
151+
until: splunk_ui.status == 200
152+
retries: 30
153+
delay: 5
154+
155+
- name: create a file to signify that the config has run successfully
156+
file:
157+
path: "/white_rabbit.followed"
158+
state: touch
159+
become: yes
160+
when: not wh_result.stat.exists

workshop/aws/ec2/templates/userdata.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ packages:
2222
- openjdk-17-jdk
2323
%{ endif ~}
2424
- python3-pip
25+
- ansible
26+
- python3-flask
2527
- zsh
2628

2729
groups:
@@ -179,6 +181,7 @@ runcmd:
179181
- unzip -qq $WSARCHIVE.zip -d /home/ubuntu/
180182
- mkdir /home/ubuntu/workshop
181183
- mv /home/ubuntu/observability-workshop-$WSVERSION/workshop/* /home/ubuntu/workshop
184+
- mv /home/ubuntu/observability-workshop-$WSVERSION/playbook.yml /home/ubuntu
182185
- rm -rf /home/ubuntu/observability-workshop-$WSVERSION
183186
# Set apm-config.sh executable
184187
- chmod +x /home/ubuntu/workshop/apm/apm-config.sh

0 commit comments

Comments
 (0)