-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
Description
mco applications were ruby plugins that was used to build CLI tools, primarily they were used to render results differently and less frequently about doing multiple chained requests (puppet runall)
For a large portion of things really all thats needed now is a way to construct complex choria req commands.
I imagine that:
someapp machine report check_load --lt 1.0.0
Would just do, and it would be enough:
choria req choria_util machine_state name=check_load --reply-filter 'ok() && semver(data("version"), "< 1.0.0")'
If there was a way to create dynamically a cli thats essentially just macros around rpc, kv, external commands etc it would allow them to make a local utility that has easy to discover features without that is just a wrapper.
$ ./myco --help
usage: ./myco [<flags>] <command> [<args> ...]
A thing that does Foo
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
Commands:
help [<command>...]
Show help.
machines [<flags>] <machine>
Query Autonomous Agents
$ ./myco machines --help
usage: ./myco machines [<flags>] <machine>
Query Autonomous Agents
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--not=VERSION Matches instances that are not this version
--le=VERSION Matches instances that are older than or same as
--lt=VERSION Matches instances that are older than
--ge=VERSION Matches instances that are newer than or same as
--gt=VERSION Matches instances that are older than
--eq=VERSION Matches instances that are same as
Args:
<machine> Autonomous Agent to report on
$ ./myco machines check_bacula_fd --eq 1.0.0
2022/05/09 14:40:35 choria req choria_util machine_state name=check_bacula_fd --filter-replies ok() && semver(data("version"), "= 1.0.0")
Discovering nodes using the choria method .... 29
29 / 29 0s [==============================================================================] 100%
...
Summary of Name:
check_bacula_fd: 16
Summary of State:
OK: 16
Summary of Version:
1.0.0: 16
Finished processing 29 / 29 hosts in 1.304s
This could be defined using a YAML file like this:
name: Foo Thing
description: A thing that does Foo
version: 0.0.1
author: R.I.Pienaar <[email protected]>
commands:
- name: machines
description: Query Autonomous Agents
std_filter: true
request:
agent: choria_util
action: machine_state
params:
name: "{{.Arguments.machine}}"
args:
- name: machine
description: Autonomous Agent to report on
required: true
flags:
- name: not
description: Matches instances that are not this version
place_holder: VERSION
filter: ok() && semver(data("version"), "!= {{.Flags.not}}")
- name: le
description: Matches instances that are older than or same as
place_holder: VERSION
filter: ok() && semver(data("version"), "<= {{.Flags.le}}")
- name: lt
description: Matches instances that are older than
place_holder: VERSION
filter: ok() && semver(data("version"), "< {{.Flags.lt}}")
- name: ge
description: Matches instances that are newer than or same as
place_holder: VERSION
filter: ok() && semver(data("version"), ">= {{.Flags.ge}}")
- name: gt
description: Matches instances that are older than
place_holder: VERSION
filter: ok() && semver(data("version"), "> {{.Flags.gt}}")
- name: eq
description: Matches instances that are same as
place_holder: VERSION
filter: ok() && semver(data("version"), "= {{.Flags.eq}}")