hilbert / hilbert-docker-images

Application with a dynamic choice of docker containers to run
Apache License 2.0
22 stars 8 forks source link

Designing new command line interface (hilbert) #28

Closed porst17 closed 7 years ago

porst17 commented 8 years ago

Please use this issue to create and discuss a specification for the new unified command line interface.

Never reference anything below this line in the comments. It may change at any time.


Sub-issues to solve:

malex984 commented 8 years ago

DRAFT (v.0.5):

General design ideas for hilbert CLI (what should it be able to do):

Notes:

Some global options:

Note about precedence rules for all possible config-related specifications:

Main top-level drivers:

NOTE: remote commands may differ for different remote stations, use hilbert remote REMOTE_STATION local --cmds to get them for a running prepared remote system REMOTE_STATION. Only basic local commands are available by default.

Basic local commands:

Possible local low-level* commands (e.g. on Linux systems with Docker Engine):

Possible local high-level commands (e.g. on Linux systems with Docker Engine + hilbert):

Note: the following actions should not run in parallel - they will require a locking mechanism

Standard local management-related commands:

Basic management-related (do something low-level w.r.t. remote system) commands:

NOTE: at least remote system access configuration is required to be in the local config. cache

Standard management-related (do something high-level w.r.t. remote system) commands:

NOTE: complete remote system configuration is required to be in the local config. cache + Docker Engine should be available on the remote system + Hilbert.

elondaits commented 8 years ago

Some comments:

malex984 commented 8 years ago

@elondaits, i am almost ready with my draft. Please wait a bit.

elondaits commented 8 years ago

Let me know... but consider I get an email message when new things are posted and none when you edit your previous messages.

malex984 commented 8 years ago

@elondaits Ok, i am mostly done.

I suggest we start discussing the use cases and usage scenarios.

malex984 commented 8 years ago

To make implementation in bash simpler the following looks promising:

The global subcommand utility: http://people.tuebingen.mpg.de/maan/gsu/

gsu is a small library of bash functions intended to ease the task of writing and documenting large shell scripts with multiple subcommands, each providing different functionality. gsu is known to work on Linux, FreeBSD, NetBSD and MacOS.

elondaits commented 8 years ago

General coments

Security

For example: deploy configs and hilbert tool to remote Linux systems using ssh-keys retrieved via rsync from the source specified in station config file (e.g. via SFTP URL)

If I understand this right this suggests placing the ssh key to the remote station somewhere it can be fetched through ftp so the system can then issue ssh commands. If that's the idea... This is a crazy backdoor! It's possible that I misunderstood but then the text should be clarified because that's what I read now.

shell [args] - run a single shell command specified by $args (no default working directory)

I don't think it's a good idea to have a generic backdoor. Our system should, if possible, only allow remote execution of "safe" commands. ssh already does this, as well.

shutdown [args] - run sudo -n -P /sbin/shutdown $args

allowed args should be explicitly documented, validated and never ever sent directly from the hilbert invocation to the sudoed command. Otherwise one could do something like

shutdown "; rm -rf /*"

(or some smarter / trickier way of escaping things in bash) and piggyback a command. All user input is evil and should be treated as such.

Semantics

Syntax / aesthetics

list_children, list known remote systems...

when the description of the command says something different than the name it's a good indication that the name should be changed (list_remote_systems in this case, for instance)

Other

Not covered

malex984 commented 8 years ago

Minimal hilbert interface: https://github.com/malex984/dockapp/blob/devel4_docs/mng/README.md#minimal-hilbert-interfaces

The purpose of actions that replace current scripts is the same as that of the superseded scripts. Same with semantics for now...

malex984 commented 7 years ago

@elondaits Could you please move your comments to the shared Google Document and attach them to relevant places in the draft design.

Let us continue the discussion there.

elondaits commented 7 years ago

I added them. Some were general comments that might be relevant to several parts or the document as a whole... so consider what they say and not only the place where I added them.

porst17 commented 7 years ago

Has to be moved to https://github.com/hilbert/hilbert-cli/issues

malex984 commented 7 years ago

I updates the google document:

malex984 commented 7 years ago

See also "Configuration Design (super issue)": hilbert/hilbert-cli#13

malex984 commented 7 years ago

More specifics on Hilbert-CLI-Station local configuration:

  1. All key/value pairs listed in Station::settings should added to some ${HOME}/.config/hilbert-cli-station/settings.cfg in some plain format, e.g. (%s=%s) % (key, value).
  2. Additionally there may be other settings defined elsewhere in general YAML config for this station: e.g. default_application & services & applications etc...
  3. ${HOME}/.config/hilbert-cli-station/settings.cfg is to be used by Hilbert-CLI-Station tool itself. The settings may influence the general operation: (e.g. autostart & autostart_delay & default_application / services etc.).
  4. The settings from ${HOME}/.config/hilbert-cli-station/settings.cfg are to be forwarded into containers created by Hilbert-CLI-Station:
    • ${HOME}/.config/hilbert-cli-station/ may be mounted (read-only) by each started container
    • or via environment variables (e.g. via env-file specification)

Note: prior to starting some services/applications Hilbert-CLI-Station may be required to run some special shell code on the host and set some environment variables before passing them into containers.

For instance: auto-detection of variables for using some currently running native services or device configurations: PULSE_SOCKET/PULSE_COOKIE (pulseaudion), DISPLAY/XAUTHORITY (x11), DOCKER_SOCKET (Docker Engine) etc.

Note: services started by Hilbert-CLI-Station (e.g. x11 / qrhandler) are to follow pre-defined schema to enable local access (e.g. share sockets via /tmp/ or by serving on localhost network address). They will also have to create individual temporary (single session only) config-files (e.g. in /tmp/) specifying corresponding access settings (e.g. with DISPLAY=... & XAUTHORITY=...).

Of course Hilbert-CLI-Station may provide some auto-detection for some standard services e.g. X11, pulseaudio, docker, but what about general case?

IMO in general Hilbert-CLI-Station should be able to run some custom script on the host system (which may create something in /tmp/) before creating a docker container with a service or an application.

NOTE: It has to be attached to service/application definition in general YAML configuration: Suggestion: Service::auto_detections.

porst17 commented 7 years ago

This issue is a super-issue again that needs to be split up. I already modified the issue description. @malex984 Please prepare the individual issues and add them to the list. A summary of the results should be added and updated on a regular basis, e.g. each time a sub-issue is closed (you can add commit-like comments to this issue and reference them in the description to make clear with state is reflected in the description).

malex984 commented 7 years ago

Note: this one is in hilbert-docker-images since it was inherited by default from dockapp repository.

@porst17 Q: What about using hilbert/hilbert-cli#14 as a super issue instead of this one?

malex984 commented 7 years ago

Please let me elaborate on the operation of Hilbert-CLI-Server:

According to https://github.com/hilbert/hilbert-docker-images/issues/28#issuecomment-257195798 ${SPECIAL_USERS_HOME}/.config/hilbert-cli-station will contain all local settings and resources (e.g. docker-compose.yml generated for this station) required for running Hilbert-CLI-Station on the host. In particular:

malex984 commented 7 years ago

Let me extend https://github.com/hilbert/hilbert-docker-images/issues/28#issuecomment-257339008 wrt Server specifics:

  1. Management Backend container running Hilbert-CLI-Server on the Server only may accept a local setting like HILBERT_SERVER_SYNC_URL (which is a part of Station::settings), which would enable Hilbert-CLI-Server to reload (sync?) the configuration-related files and docker-image tarballs from some external location using the predefined syncing mechanism (e.g. rsync over sFTP or SSH).
  2. The external resources should be persistently stored on the host system. For that, some predefined location will be mounted (read-write) into the Management Backend container when it is created. I imagine Server's Station::settings may explicitly specify that location, e.g. via a variable like HILBERT_SERVER_CONFIG_PATH, which may default to ${SPECIAL_USERS_HOME}/.config/hilbert-cli-server on the host system.
porst17 commented 7 years ago

I missed that this issue is still listed under hilbert-docker-images. Feel free to move relevant stuff over to hilbert/hilbert-cli#14 and then close this issue.

malex984 commented 7 years ago

For reference: the use of auto-detection for using anything located on a host or running there

malex984 commented 7 years ago

For reference: command aliases

malex984 commented 7 years ago

CLI server/client tools were initially implemented within https://github.com/hilbert/hilbert-cli/pull/34

Corresponding design is in the "Management Back-end" Document.

Current CLI: https://gist.github.com/malex984/59d2b62c5098eb1005100f9249719505

malex984 commented 7 years ago

Further implementation will be due to https://github.com/hilbert/hilbert-cli/issues/14