The default mco rpc
tool is a bit meh and probably contributes greatly to the difficulty in using mcollective.
It was written before DDLs even existed and was never revisited.
This should be revisited to focus more on the problem it should solve, towards that I have come to the following basic sketch:
Goals:
- Focus on what users will most often want to see by creating a dynamic interface
- Rethink some of the user facing terminology, removes
RPC
in favor of Request
etc
- Gradually expose the complexity inherent in a generic RPC client rather than by default produce a wall of text
- Have tab completion for every part of the cli, the
mco completion
can already do this
- Use
$PAGER
for things like --action-doc
if more than $LINES
of output
There is one possibility I also want to explore and that is to make a more interactive client that asks you client using the :prompt
defined in the DDL, you'd start it up like choria puppet --interactive
and it will start asking you questions via prompts, defaults etc and construct the request - and possibly show you what command would have produced the same outcome as a learning tool. This way people with almost no experience can interactively learn the system
Some future suggestions:
- Make some file where you can specify on a per agent/action basis defaults you always wish to apply, like say
--batch
or --noop
for the runonce agent or whatever via @trevor-vaughan
The code used to produce the output can be found here https://gist.github.com/ripienaar/f68d2a9031b35f9dc3d467c9d85886ee it just prints stuff doesnt actually make requests
Default action, show available agents
$ choria
Choria client version x.x.x
Usage: choria <agent> <action> [agent options] [request options]
Available agents:
package Install and uninstall software packages
puppet Run Puppet agent, get its status, and enable/disable it
rpcutil General helpful actions that expose stats and internals to SimpleRPC clients
service Start and stop system services
See choria <agent> --help for details about the agent
Per agent generated details
$ choria puppet
Puppet agent version 1.11.1
Usage: choria puppet <action> [agent options] [request options]
Run Puppet agent, get its status, and enable/disable it
Available actions:
disable Disable the Puppet agent
enable Enable the Puppet agent
last_run_summary Get the summary of the last Puppet run
resource Evaluate Puppet RAL resources
runonce Invoke a single Puppet run
status Get the current status of the Puppet agent
See choria puppet <action> --help for details about one of the actions
Per action view
Here we focus on showing the available inputs the action take and turn them into --foo
style flags and show them as options.
All the old RPC noise is hidden by default under --filter-help
and --request-help
, an additional --action-doc
exist to show the DDL produced doc for the action
Ideally these options would show as much as possible from the DDL things like data type and default but we have limited screen real estate
$ choria puppet runonce --help
Puppet agent version 1.11.1
Usage: choria puppet runonce [agent options] [request options]
Run Puppet agent, get its status, and enable/disable it
Options for the runonce action:
Use --action-doc to get details about these such as types, defaults and valid values
Optional options:
--force Will force a run immediately else subject to default splay time
--server Address and port of the Puppet Master in server:port format
--tags Restrict the Puppet run to a comma list of tags
--noop Do a Puppet dry run
--splay Sleep for a period before initiating the run
--splaylimit Maximum amount of time to sleep before run
--environment Which Puppet environment to run
--use_cached_catalog Determine if to use the cached catalog or not
Additional help:
--action-doc View the documentation for the runonce action
--filter-help Help on selecting which nodes to act on
--request-help View a full set of request options
Per action DDL doc
This needs some iteration it really is just to show the idea here:
$ choria puppet runonce --action-doc
Puppet agent version 1.11.1
Definition of the runonce action
Action inputs:
Optional options:
environment (String):
Description: Which Puppet environment to run
Prompt: Environment
Required: false
Default: nil
Max Length: 50
Validation: puppet_variable
force (Boolean):
Description: Will force a run immediately else subject to default splay time
Prompt: Force
Required: false
Default: nil
Max Length: 0
Validation: none
<snip>
Action outputs:
initiated_at:
Description: Timestamp of when the runonce command was issues
Display As: Initiated at
Default: 0
summary:
Description: Summary of command run
Display As: Summary
Default:
Host filters help
Supplying --filter-help
will add just the filter options. For demo purposes this is just a copy/paste from mco rpc
some refining will be needed to make this suck a bit less
$ choria puppet runonce --filter-help
Puppet agent version 1.11.1
Usage: choria puppet runonce [agent options] [request options]
Run Puppet agent, get its status, and enable/disable it
Options for the runonce action:
Use --action-doc to get details about these such as types, defaults and valid values
Optional options:
--force Will force a run immediately else subject to default splay time
--server Address and port of the Puppet Master in server:port format
--tags Restrict the Puppet run to a comma list of tags
--noop Do a Puppet dry run
--splay Sleep for a period before initiating the run
--splaylimit Maximum amount of time to sleep before run
--environment Which Puppet environment to run
--use_cached_catalog Determine if to use the cached catalog or not
Additional help:
--action-doc View the documentation for the runonce action
--filter-help Help on selecting which nodes to act on
--request-help View a full set of request options
Host Filters:
-W, --with FILTER Combined classes and facts filter
-S, --select FILTER Compound filter combining facts and classes
-F, --wf, --with-fact fact=val Match hosts with a certain fact
-C, --wc, --with-class CLASS Match hosts with a certain config management class
-A, --wa, --with-agent AGENT Match hosts with a certain agent
-I, --wi, --with-identity IDENT Match hosts with a certain configured identity
Full request help
For demo purposes this is just a copy/paste from mco rpc
some refining will be needed to make this suck a bit less
$ choria puppet runonce --request-help
Puppet agent version 1.11.1
Usage: choria puppet runonce [agent options] [request options]
Run Puppet agent, get its status, and enable/disable it
Options for the runonce action:
Use --action-doc to get details about these such as types, defaults and valid values
Optional options:
--force Will force a run immediately else subject to default splay time
--server Address and port of the Puppet Master in server:port format
--tags Restrict the Puppet run to a comma list of tags
--noop Do a Puppet dry run
--splay Sleep for a period before initiating the run
--splaylimit Maximum amount of time to sleep before run
--environment Which Puppet environment to run
--use_cached_catalog Determine if to use the cached catalog or not
Additional help:
--action-doc View the documentation for the runonce action
--filter-help Help on selecting which nodes to act on
--request-help View a full set of request options
Request Modifiers:
--no-results, --nr Do not process results, just send request
--np, --no-progress Do not show the progress bar
-1, --one Send request to only one discovered nodes
--batch SIZE Do requests in batches
--batch-sleep SECONDS Sleep time between batches
--limit-seed NUMBER Seed value for deterministic random batching
--limit-nodes, --ln, --limit COUNT
Send request to only a subset of nodes, can be a percentage
-j, --json Produce JSON output
--display MODE Influence how results are displayed. One of ok, all or failed
-c, --config FILE Load configuration from file rather than default
-v, --verbose Be verbose
-T, --target COLLECTIVE Target messages to a specific sub collective
--dt, --discovery-timeout SECONDS
Timeout for doing discovery
-t, --timeout SECONDS Timeout for calling remote agents
-q, --quiet Do not be verbose
--ttl TTL Set the message validity period
--reply-to TARGET Set a custom target for replies
--dm, --disc-method METHOD Which discovery method to use
--do, --disc-option OPTION Options to pass to the discovery method
--nodes FILE List of nodes to address
--publish_timeout TIMEOUT Timeout for publishing requests to remote agents.
--threaded Start publishing requests and receiving responses in threaded mode.
--sort Sort the output of an request before processing.
--connection-timeout TIMEOUT Set the timeout for establishing a connection to the middleware