用法
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-access-token WEBSOCKET_ACCESS_TOKEN]
[--websocket-refresh-token WEBSOCKET_REFRESH_TOKEN]
[--websocket-token-url WEBSOCKET_TOKEN_URL] [--id ID] [-w] [-T PROJECT_TARBALL]
[--controller-url CONTROLLER_URL] [--controller-token CONTROLLER_TOKEN]
[--controller-username CONTROLLER_USERNAME] [--controller-password CONTROLLER_PASSWORD]
[--controller-ssl-verify CONTROLLER_SSL_VERIFY] [--print-events]
[--shutdown-delay SHUTDOWN_DELAY] [--gc-after GC_AFTER] [--heartbeat HEARTBEAT]
[--execution-strategy {sequential,parallel}] [--hot-reload] [--skip-audit-events]
[--vault-password-file VAULT_PASSWORD_FILE] [--vault-id VAULT_ID] [--ask-vault-pass]
[-F FILTER_DIR]
[--persistence-id PERSISTENCE_ID]
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
Local event source plugins dir for development.
-F FILTER_DIR, --filter-dir FILTER_DIR
Local event filters dir for development.
-i INVENTORY, --inventory INVENTORY
Path to an inventory file, can also be passed via the env var ANSIBLE_INVENTORY
-W WEBSOCKET_URL, --websocket-url WEBSOCKET_URL, --websocket-address WEBSOCKET_URL
Connect the event log to a websocket, can also be passed via the env var EDA_WEBSOCKET_URL.
--websocket-ssl-verify WEBSOCKET_SSL_VERIFY
How to verify SSL when connecting to the websocket: (yes|true) | (no|false) | <path to a CA bundle>, default to yes for wss connection, can also be passed via the env var EDA_WEBSOCKET_SSL_VERIFY.
--websocket-access-token WEBSOCKET_ACCESS_TOKEN
Token used to autheticate the websocket connection, can also be passed via the env var EDA_WEBSOCKET_ACCESS_TOKEN
--websocket-refresh-token WEBSOCKET_REFRESH_TOKEN
Token used to renew a websocket access token, can also be passed via the env var EDA_WEBSOCKET_REFRESH_TOKEN
--websocket-token-url WEBSOCKET_TOKEN_URL
Url to renew websocket access token, can also be passed via the env var EDA_WEBSOCKET_TOKEN_URL
--id ID Identifier, the activation_instance id which allows the results to be communicated back to the websocket.
-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 via the env var EDA_CONTROLLER_URL, if your URL has a path it should include api in it. api would only be appended if the URL only contains host, port.
--controller-token CONTROLLER_TOKEN
Controller API authentication token, can also be passed via env var EDA_CONTROLLER_TOKEN
--controller-username CONTROLLER_USERNAME
Controller API authentication username, can also be passed via env var EDA_CONTROLLER_USERNAME
--controller-password CONTROLLER_PASSWORD
Controller API authentication password, can also be passed via env var EDA_CONTROLLER_PASSWORD
--controller-ssl-verify CONTROLLER_SSL_VERIFY
How to verify SSL when connecting to the controller: (yes|true) | (no|false) | <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 SHUTDOWN_DELAY
Maximum number of seconds to wait after issuing a graceful shutdown, default: 60. The process will shutdown if all actions complete before this time period. Can also be passed via the env var EDA_SHUTDOWN_DELAY
--gc-after GC_AFTER Run the garbage collector after this number of events. It can be configured with the environment variable EDA_GC_AFTER
--heartbeat HEARTBEAT
Send heartbeat to the server after every n secondsDefault is 0, no heartbeat is sent
--execution-strategy {sequential,parallel}
Actions can be executed in sequential order or in parallel.Default is sequential, actions will be run only after the previous one ends
--hot-reload Will perform hot-reload on rulebook file changes (when running in non-worker mode).This option is ignored in worker mode.
--skip-audit-events Don't send audit events to the server
--vault-password-file VAULT_PASSWORD_FILE
The file containing one ansible vault password, can also be passed via the env var EDA_VAULT_PASSWORD_FILE.
--vault-id VAULT_ID label@filename pointing to an ansible vault password file
--ask-vault-pass Ask vault password interactively
--persistence-id PERSISTENCE_ID
The unique id, preferably a UUID to track persistent event data
若要获取 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 --inventory inventory.yml --rulebook rules.yml -S sources/ -F my_filters/
注意
此处 sources 是包含您的事件源插件的目录,my_filters 是包含您的事件过滤器的目录。
若要在启用工作模式(worker mode)下运行 ansible-rulebook,可以使用 –worker 选项。同时可以使用 –id 和 –websocket-url 选项来公开事件流数据
ansible-rulebook --rulebook rules.yml --inventory inventory.yml --websocket-url "ws://:8080/api/ws2" --id 1 --worker
注意
id 是 activation_instance ID,它允许将结果传回给 websocket。–project-tarball 选项在开发过程中也非常有用。
可以在上述任何命令中添加 -v 或 -vv 选项以增加日志输出。