1+ ---
2+ - hosts : localhost
3+ gather_facts : false
4+
5+ pre_tasks :
6+ - name : Set the required variables
7+ set_fact :
8+ ingest_token : " {{ lookup('env','ACCESS_TOKEN') }}"
9+ rum_token : " i{{ lookup('env','RUM_TOKEN') }}"
10+ 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 : Configure Demo-in-a-Box
16+ block :
17+ - name : Check to see if the config has run
18+ stat :
19+ path : /white_rabbit.followed
20+ register : wh_result
21+
22+ - name : Download demo-in-a-box
23+ get_url :
24+ url : " https://demoinabox-tst.s3.us-east-2.amazonaws.com/{{ o11y_diabversion }}.zip"
25+ dest : /home/ubuntu/demo-in-a-box.zip
26+ become : true
27+ when : not wh_result.stat.exists
28+
29+ - name : Extract demo-in-a-box into /home/ubuntu/
30+ unarchive :
31+ src : demo-in-a-box.zip
32+ dest : /home/ubuntu/
33+ owner : ubuntu
34+ group : ubuntu
35+ remote_src : yes
36+ list_files : yes
37+ become : true
38+ register : diab_dir_name
39+ when : not wh_result.stat.exists
40+
41+ - name : Delete demo-in-a-box.zip
42+ file :
43+ path : /home/ubuntu/demo-in-a-box.zip
44+ state : absent
45+ become : true
46+ when : not wh_result.stat.exists
47+
48+ - debug :
49+ var : diab_dir_name.files[0]
50+ when : not wh_result.stat.exists
51+
52+ - name : Create service for Demo-in-a-Box
53+ file :
54+ path : /etc/systemd/system/demoinabox.service
55+ state : touch
56+ become : true
57+ when : not wh_result.stat.exists
58+
59+ - name : Update service for demoinabox.service
60+ ansible.builtin.blockinfile :
61+ path : /etc/systemd/system/demoinabox.service
62+ block : |
63+ [Unit]
64+ Description=demoinabox service
65+ After=network.target
66+ StartLimitIntervalSec=0
67+ [Service]
68+ Type=simple
69+ Restart=always
70+ RestartSec=1
71+ User=ubuntu
72+ Environment="KUBECONFIG=/home/ubuntu/.kube/config"
73+ WorkingDirectory=/home/ubuntu/{{ diab_dir_name.files[0] }}democonsole
74+ ExecStart=/usr/bin/flask run -p 8081 --host=0.0.0.0
75+ [Install]
76+ WantedBy=multi-user.target
77+ marker : " ## {mark} added by ansible (configuration demo-in-a-box)"
78+ become : true
79+ when : not wh_result.stat.exists
80+
81+ - name : Install democonsole Python dependencies
82+ command : python3 -m pip install -r requirements.txt
83+ args :
84+ chdir : " /home/ubuntu/{{ diab_dir_name.files[0] }}democonsole/"
85+ when : not wh_result.stat.exists
86+
87+ - name : Helm OTel Collector repository add
88+ command : helm repo add splunk-otel-collector-chart https://signalfx.github.io/splunk-otel-collector-chart
89+ when : not wh_result.stat.exists
90+
91+ - name : Helm repository update
92+ command : helm repo update
93+ when : not wh_result.stat.exists
94+
95+ - name : Start the demoinabox service
96+ command : systemctl enable --now demoinabox.service
97+ become : true
98+ when : not wh_result.stat.exists
99+
100+ - name : Wait for demoinabox.service to start
101+ pause :
102+ seconds : 15
103+ when : not wh_result.stat.exists
104+
105+ - name : Save Demo-in-a-Box configuration
106+ uri :
107+ url : " http://localhost:8081/saveConfig"
108+ method : POST
109+ body : " realm={{ realm }}&accessToken={{ ingest_token }}&rumAccessToken={{ rum_token }}&environment={{ o11y_env_name }}&loadgenLocation=aws"
110+ status_code : [ 200, 201 ]
111+ timeout : 30
112+ when : not wh_result.stat.exists
113+
114+ - name : Start the OpenTelemetry Collector
115+ uri :
116+ url : " http://localhost:8081/startCollector"
117+ method : GET
118+ status_code : [ 200, 201 ]
119+ timeout : 30
120+ when : not wh_result.stat.exists
121+
122+ - name : Wait for OpenTelemetry Collector to start
123+ pause :
124+ seconds : 60
125+ when : not wh_result.stat.exists
126+
127+ - name : Start the frontend demo
128+ uri :
129+ url : " http://localhost:8081/startdemo?demo=frontend"
130+ method : GET
131+ status_code : [ 200, 201 ]
132+ timeout : 30
133+ when : not wh_result.stat.exists
134+
135+ - name : Wait for frontend demo to start
136+ pause :
137+ seconds : 90
138+ when : not wh_result.stat.exists
139+
140+ - name : Wait for the Online Boutique to become available
141+ uri :
142+ url : " http://localhost:81"
143+ method : GET
144+ validate_certs : no
145+ status_code : 200
146+ return_content : no
147+ register : splunk_ui
148+ until : splunk_ui.status == 200
149+ retries : 30
150+ delay : 5
151+
152+ - name : Create a file to signify that the config has run successfully
153+ file :
154+ path : " /white_rabbit.followed"
155+ state : touch
156+ become : true
157+ when : not wh_result.stat.exists
0 commit comments