File tree Expand file tree Collapse file tree
uid2-operator-ami/ansible Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from flask import Flask
2+ from datetime import datetime , timezone
23import json
34import os
45
@@ -14,5 +15,12 @@ def get_config():
1415 except Exception as e :
1516 return str (e ), 500
1617
18+ @app .route ('/getCurrentTime' , methods = ['GET' ])
19+ def get_time ():
20+ try :
21+ return datetime .now (timezone .utc ).isoformat (timespec = "seconds" )
22+ except Exception as e :
23+ return str (e ), 500
24+
1725if __name__ == '__main__' :
1826 app .run (processes = 8 )
Original file line number Diff line number Diff line change @@ -22,6 +22,33 @@ ifconfig lo 127.0.0.1
2222echo " Starting vsock proxy..."
2323/app/vsockpx --config /app/proxies.nitro.yaml --daemon --workers $(( ( $(nproc) + 3 ) / 4 )) --log-level 3
2424
25+ TIME_SYNC_URL=" http://127.0.0.1:27015/getCurrentTime"
26+ TIME_SYNC_INTERVAL_SECONDS=" ${TIME_SYNC_INTERVAL_SECONDS:- 300} "
27+
28+ sync_enclave_time () {
29+ local current_time
30+ if current_time=$( curl -s -f -x socks5h://127.0.0.1:3305 " ${TIME_SYNC_URL} " ) ; then
31+ if ! date -u -s " ${current_time} " ; then
32+ echo " Time sync: failed to set enclave time from '${current_time} '"
33+ return 1
34+ fi
35+ echo " Time sync: updated enclave time to ${current_time} "
36+ else
37+ echo " Time sync: failed to fetch time from parent instance"
38+ return 1
39+ fi
40+ }
41+
42+ start_time_sync_loop () {
43+ while true ; do
44+ sync_enclave_time || true
45+ sleep " ${TIME_SYNC_INTERVAL_SECONDS} "
46+ done
47+ }
48+
49+ sync_enclave_time || true
50+ start_time_sync_loop &
51+
2552build_parameterized_config () {
2653 curl -s -f -o " ${PARAMETERIZED_CONFIG} " -x socks5h://127.0.0.1:3305 http://127.0.0.1:27015/getConfig
2754 REQUIRED_KEYS=(" optout_base_url" " core_base_url" " core_api_token" " optout_api_token" " environment" " uid_instance_id_prefix" )
Original file line number Diff line number Diff line change 1919 name : nmap-ncat
2020 state : latest
2121
22+ - name : Install chrony for time sync
23+ ansible.builtin.dnf :
24+ name : chrony
25+ state : latest
26+
27+ - name : Comment out default chrony pool servers
28+ ansible.builtin.replace :
29+ path : /etc/chrony.conf
30+ regexp : ' ^pool\s+'
31+ replace : ' # pool '
32+
33+ - name : Configure AWS Time Sync Service in chrony
34+ ansible.builtin.lineinfile :
35+ path : /etc/chrony.conf
36+ line : ' server 169.254.169.123 prefer iburst'
37+ state : present
38+ insertafter : EOF
39+
40+ - name : Enable RTC sync in chrony
41+ ansible.builtin.lineinfile :
42+ path : /etc/chrony.conf
43+ line : ' rtcsync'
44+ state : present
45+ insertafter : EOF
46+
47+ - name : Allow chrony to step clock at startup
48+ ansible.builtin.lineinfile :
49+ path : /etc/chrony.conf
50+ line : ' makestep 1.0 3'
51+ state : present
52+ insertafter : EOF
53+
54+ - name : Ensure chronyd is enabled at boot
55+ ansible.builtin.systemd :
56+ name : chronyd
57+ state : started
58+ enabled : true
59+
2260 - name : Install python
2361 ansible.builtin.dnf :
2462 name :
You can’t perform that action at this time.
0 commit comments