Skip to content

Commit 09b9158

Browse files
committed
windmill. update provision files for logs table
1 parent 2b4fd35 commit 09b9158

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE TABLE IF NOT EXISTS `logs` (
2+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
3+
`session_id` varchar(64) NOT NULL,
4+
`operator_id` varchar(64) NOT NULL,
5+
`session_created` varchar(64) NOT NULL,
6+
`session_connected` varchar(64) NOT NULL,
7+
`session_disconnected` varchar(64) NOT NULL,
8+
PRIMARY KEY (`id`)
9+
) ENGINE=InnoDB DEFAULT CHARSET=utf8

windmill/roles/windmill/files/opt/windmill/helpers/windmill-start-ssh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
logger -t "windmill" "SSH_START_SESSION: vpn_ip=$1 port=$2"
44

5+
# create session log
6+
log_id=$(curl -s -X POST \
7+
-F "session_id=$3" \
8+
-F "operator_id=$(whoami)" \
9+
"http://localhost:8080/api/logs/" | grep -P '\d+' -o)
10+
511
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p $2 root@$1
612

13+
# after ssh close, update info on logs
14+
curl -s -X PUT \
15+
"http://localhost:8080/api/logs/$log_id" >/dev/null
16+
717
exit 0

windmill/roles/windmill/tasks/main.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@
8383
tags:
8484
- windmill
8585

86+
- name: Copy logs.sql db to host
87+
copy: src=logs.sql dest=/tmp/logs.sql
88+
tags:
89+
- windmill
90+
91+
- name: Create logs table
92+
mysql_db:
93+
state: import
94+
name: windmill
95+
target: /tmp/logs.sql
96+
tags:
97+
- windmill
98+
8699
- stat: path=/root/.my.cnf
87100
register: mariadb_pass
88101

0 commit comments

Comments
 (0)