用法
ansible-rulebook CLI 支持以下选项
usage: ansible-rulebook [-h] [-r RULEBOOK] [-e VARS] [-E ENV_VARS] [-v] [--version] [-S SOURCE_DIR] [-i INVENTORY] [-W WEBSOCKET_URL] [--websocket-ssl-verify WEBSOCKET_SSL_VERIFY]
[--websocket-token-url WEBSOCKET_TOKEN_URL] [--websocket-access-token WEBSOCKET_ACCESS_TOKEN] [--websocket-refresh-token WEBSOCKET_REFRESH_TOKEN]
[--id ID] [-w] [-T PROJECT_TARBALL] [--controller-url CONTROLLER_URL] [--controller-token CONTROLLER_TOKEN] [--controller-ssl-verify CONTROLLER_SSL_VERIFY]
[--print-events] [--heartbeat n] [--execution-strategy sequential|parallel] [--skip-audit-events]
optional arguments:
-h, --help show this help message and exit
-r RULEBOOK, --rulebook RULEBOOK
The rulebook file or rulebook from a collection
-e VARS, --vars VARS Variables file
-E ENV_VARS, --env-vars ENV_VARS
Comma separated list of variables to import from the environment
-v, --verbose Causes ansible-rulebook to print more debug messages. Adding multiple -v will increase the verbosity, the default value is 0. The maximum value is 2. Events debugging might require -vv.
--version Show the version and exit
-S SOURCE_DIR, --source-dir SOURCE_DIR
Source dir
-i INVENTORY, --inventory INVENTORY
Inventory can be a file or a directory
-W WEBSOCKET_URL, --websocket-url WEBSOCKET_URL
Connect the event log to a websocket
--websocket-ssl-verify WEBSOCKET_SSL_VERIFY
How to verify SSL when connecting to the websocket api. yes|no|<path to a CA bundle>, default to yes for wss connection.
Connect the event log to a websocket
--websocket-token-url WEBSOCKET_TOKEN_URL
Fetch a renewed token to authenticate websocket connection
--websocket-access-token WEBSOCKET_ACCESS_TOKEN
Initial token used to authenticate websocket connection
--websocket-refresh-token WEBSOCKET_REFRESH_TOKEN
A token needed to renew an authentication token
--id ID Identifier
-w, --worker Enable worker mode
-T PROJECT_TARBALL, --project-tarball PROJECT_TARBALL
A tarball of the project
--controller-url CONTROLLER_URL
Controller API base url, e.g. https://host1:8080, can also be passed in via env var EDA_CONTROLLER_URL
--controller-token CONTROLLER_TOKEN
Controller API authentication token, can also be passed in via env var EDA_CONTROLLER_TOKEN
--controller-ssl-verify CONTROLLER_SSL_VERIFY
How to verify SSL when connecting to the controller, yes|no|<path to a CA bundle>, default to yes for https connection. Can also be passed via env var EDA_CONTROLLER_SSL_VERIFY
--print-events Print events to stdout, redundant and disabled with -vv
--shutdown-delay Maximum number of seconds to wait after a graceful shutdown is issued, default is 60. Can also be set via an env var called EDA_SHUTDOWN_DELAY. The process will shutdown if all actions complete before this time period
--heartbeat <n> Send heartbeat to the server after every n seconds. Default is 0, no heartbeat is sent
--execution-strategy sequential|parallel. The default execution strategy is sequential.
--skip-audit-events Skip sending audit events to the EDA server, default is false
要从 ansible-rulebook 获取帮助,请运行以下命令:
ansible-rulebook --help
要检查 ansible-rulebook 的版本,请运行以下命令:
ansible-rulebook --version
运行 ansible-rulebook 的常用方法如下:
ansible-rulebook --inventory inventory.yml --rulebook rules.yml --vars vars.yml
注意
–rulebook 选项需要 –inventory 选项。 –vars 选项不是必需的。
如果您使用自定义事件源插件,请使用以下命令:
ansible-rulebook --inventory inventory.yml --rulebook rules.yml -S sources/
注意
此处 sources 是包含您的事件源插件的目录。
要使用启用工作模式的 ansible-rulebook,可以使用 –worker 选项。 –id 和 –websocket-url 选项也可以用来公开事件流数据。
ansible-rulebook --rulebook rules.yml --inventory inventory.yml --websocket-url "ws://127.0.0.1:8080/api/ws2" --id 1 --worker
注意
id 是 activation_instance ID,它允许将结果传回 websocket。 –project-tarball 选项在开发过程中也很有用。
可以在上述任何命令中添加 -v 或 -vv 选项来增加日志输出。