From 26ff2beea91a4ec5a78623f19c7c1752bdbc325f Mon Sep 17 00:00:00 2001 From: DavHau Date: Fri, 5 Jul 2024 15:01:10 +0700 Subject: [PATCH] clan-cli: add vars command --- pkgs/clan-cli/clan_cli/__init__.py | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pkgs/clan-cli/clan_cli/__init__.py b/pkgs/clan-cli/clan_cli/__init__.py index 503a519d..dc481140 100644 --- a/pkgs/clan-cli/clan_cli/__init__.py +++ b/pkgs/clan-cli/clan_cli/__init__.py @@ -272,6 +272,43 @@ For more detailed information, visit: {help_hyperlink("secrets", "https://docs.c ) facts.register_parser(parser_facts) + # like facts but with vars instead of facts + parser_vars = subparsers.add_parser( + "vars", + help="manage vars", + description="manage vars", + epilog=( + f""" +This subcommand provides an interface to vars of clan machines. +Vars are variables that a service can generate. +There are public and secret vars. +Public vars can be referenced by other machines directly. +Public vars can include: ip addresses, public keys. +Secret vars can include: passwords, private keys. + +A service is an included clan-module that implements vars generation functionality. +For example the zerotier module will generate private and public vars. +In this case the public var will be the resulting zerotier-ip of the machine. +The secret var will be the zerotier-identity-secret, which is used by zerotier +to prove the machine has control of the zerotier-ip. + +Examples: + + $ clan vars generate + Will generate vars for all machines. + + $ clan vars generate --service [SERVICE] --regenerate + Will regenerate vars, if they are already generated for a specific service. + This is especially useful for resetting certain passwords while leaving the rest + of the vars for a machine in place. + +For more detailed information, visit: {help_hyperlink("secrets", "https://docs.clan.lol/getting-started/secrets")} + """ + ), + formatter_class=argparse.RawTextHelpFormatter, + ) + facts.register_parser(parser_vars) + parser_machine = subparsers.add_parser( "machines", help="manage machines and their configuration",