-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
liana
committed
Jul 19, 2023
1 parent
b993ce9
commit f146233
Showing
3 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters