Skip to content

Commit

Permalink
Add new lense for Teleport service
Browse files Browse the repository at this point in the history
  • Loading branch information
liana committed Jul 19, 2023
1 parent b993ce9 commit f146233
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 0 deletions.
84 changes: 84 additions & 0 deletions lenses/teleport.aug
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
(*
Module: Teleport

Parses /etc/teleport.yaml configuration file

Author: Ostapchuk Liana [email protected]

About: Reference
https://goteleport.com/docs/reference/config/

Example of teleport configuration file:

> version: v3
> teleport:
> nodename: nodename
> data_dir: <path>
> log:
> output: stderr
> severity: INFO
> format:
> output: text
> ca_pin: sha256:........
> auth_servers:
> - host:port
> diag_addr:
> auth_service:
> enabled: yes
> listen_addr: 0.0.0.0:3025
> proxy_listener_mode: multiplex
> ssh_service:
> enabled: yes
> labels:
> team: name
> owner: username
> env: dev
>
> commands:
> - name: hostname
> command: [hostname]
> period: 1m0s
> proxy_service:
> enabled: yes
> # https_keypairs: []
> https_keypairs_reload_interval: 0s

*)

module Teleport =

(************************************************************************
* USEFUL PRIMITIVES
*************************************************************************)
autoload xfm

let colon = Sep.colon
let space = Sep.space
let key = key /[^-,# \n\t]+/
let value = store Rx.space_in
let eol = Util.eol
let indent = Util.indent
let dash = Util.del_str "- "
let comment = Util.comment


(************************************************************************
* `KEY: VALUE` PAIR
*************************************************************************)

let k = key . colon . eol
let v = [ value . eol+ ]
let kv = [ key . colon . space . value . eol+ ]

(************************************************************************
* LENS & FILTER
*************************************************************************)

let entry = (comment . eol* ) | ( indent . dash . v ) | (indent . kv)
let nested_kv = [ indent . k . Util.empty* . entry* ]

let lns = kv* . nested_kv*

let filter = incl "/etc/teleport.yaml"

let xfm = transform lns filter
139 changes: 139 additions & 0 deletions lenses/tests/test_teleport.aug
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
(*
Module: Teleport

Parses /etc/teleport.yaml configuration file

Author: Ostapchuk Liana [email protected]

About: Reference
https://goteleport.com/docs/reference/config/

Example of teleport configuration file:

> version: v3
> teleport:
> nodename: nodename
> data_dir: <path>
> log:
> output: stderr
> severity: INFO
> format:
> output: text
> ca_pin: sha256:........
> auth_servers:
> - host:port
> diag_addr:
> auth_service:
> enabled: yes
> listen_addr: 0.0.0.0:3025
> proxy_listener_mode: multiplex
> ssh_service:
> enabled: yes
> labels:
> team: name
> owner: username
> env: dev
>
> commands:
> - name: hostname
> command: [hostname]
> period: 1m0s
> proxy_service:
> enabled: yes
> # https_keypairs: []
> https_keypairs_reload_interval: 0s

*)

module Test_teleport =

let conf ="version: v2
teleport:
data_dir: /path/
log:
output: /path/teleport.log
severity: INFO
format:
output: json
ca_pin: sha256:982e90087a02-0-0a9da76d54456
auth_servers:
- hostname:3030

join_params:
token_name: 111dd2f-0a0f-4444d-aa-s-f7-a825bb878db9
method: name

auth_service:
enabled: no
proxy_service:
enabled: no
ssh_service:
enabled: yes
disable_create_host_user: true
listen_addr: 1.1.1.1:1111
pam:
enabled: true
service_name: teleport
labels:
team: name
owner: ostapchuk.liana
env: production
project: may_be_empty
product: may_be_empty
cluster: may_be_empty

commands:
- name: name
command: [hostname]
period: 1m0s
"

(* Test: Teleport.lns *)

test Teleport.lns get conf = { "version" = "v2" }
{ "teleport"
{ "data_dir" = "/path/" }
}
{ "log"
{ "output" = "/path/teleport.log" }
{ "severity" = "INFO" }
}
{ "format"
{ "output" = "json" }
{ "ca_pin" = "sha256:982e90087a02-0-0a9da76d54456" }
}
{ "auth_servers"
{ = "hostname:3030" }
}
{ "join_params"
{ "token_name" = "111dd2f-0a0f-4444d-aa-s-f7-a825bb878db9" }
{ "method" = "name" }
}
{ "auth_service"
{ "enabled" = "no" }
}
{ "proxy_service"
{ "enabled" = "no" }
}
{ "ssh_service"
{ "enabled" = "yes" }
{ "disable_create_host_user" = "true" }
{ "listen_addr" = "1.1.1.1:1111" }
}
{ "pam"
{ "enabled" = "true" }
{ "service_name" = "teleport" }
}
{ "labels"
{ "team" = "name" }
{ "owner" = "ostapchuk.liana" }
{ "env" = "production" }
{ "project" = "may_be_empty" }
{ "product" = "may_be_empty" }
{ "cluster" = "may_be_empty" }
}
{ "commands"
{ = "name: name" }
{ "command" = "[hostname]" }
{ "period" = "1m0s" }
}
1 change: 1 addition & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ lens_tests = \
lens-syslog.sh \
lens-sysctl.sh \
lens-systemd.sh \
lens-teleport.sh \
lens-termcap.sh \
lens-thttpd.sh \
lens-tinc.sh \
Expand Down

0 comments on commit f146233

Please sign in to comment.