diff --git a/lenses/teleport.aug b/lenses/teleport.aug new file mode 100644 index 000000000..cc9b090be --- /dev/null +++ b/lenses/teleport.aug @@ -0,0 +1,84 @@ +(* +Module: Teleport + +Parses /etc/teleport.yaml configuration file + +Author: Ostapchuk Liana ssmgroll@gmail.com + +About: Reference + https://goteleport.com/docs/reference/config/ + +Example of teleport configuration file: + +> version: v3 +> teleport: +> nodename: nodename +> data_dir: +> 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 \ No newline at end of file diff --git a/lenses/tests/test_teleport.aug b/lenses/tests/test_teleport.aug new file mode 100644 index 000000000..58b137c69 --- /dev/null +++ b/lenses/tests/test_teleport.aug @@ -0,0 +1,139 @@ +(* +Module: Teleport + +Parses /etc/teleport.yaml configuration file + +Author: Ostapchuk Liana ssmgroll@gmail.com + +About: Reference + https://goteleport.com/docs/reference/config/ + +Example of teleport configuration file: + +> version: v3 +> teleport: +> nodename: nodename +> data_dir: +> 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" } + } diff --git a/tests/Makefile.am b/tests/Makefile.am index 112028182..f65f49ad0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \