# command
The command collect plugin executes a command and returns the output, error and exit code as a map.
# Plugin fields
| Field | Description | Required | Default |
|---|---|---|---|
| cmd | The main command to run. | Yes | "" |
| args | A list of arguments to pass to the command. | No | [] |
| ignore-error | Whether to fail data collection if the command fails. | No | false |
# Common fields
| Field | Description | Required | Default |
|---|---|---|---|
| name | The name/identifier of the plugin - this is the yaml key in the config file when defining the fact. | Yes | - |
| connection | The connection to use for collecting the fact. | No | "" |
| input | A previous input to use when collecting the fact. | No | "" |
| additional-inputs | Additional previous inputs to use when collecting the fact. | No | [] |
# Return format
A map with the following fields:
| Field | Description |
|---|---|
| out | The command output. |
| err | The command error. |
| code | The command exit code. |
# Example
collect:
db-tfa-module:
command:
cmd: bash
args:
- -c
- |
set -o pipefail
drush pm:list --no-core --package=Security --fields=name,status --format=json | jq -r '.tfa.status'
db-tfa-config-enabled:
command:
cmd: bash
args:
- -c
- |
set -o pipefail
drush config:get tfa.settings enabled --include-overridden --format=json | jq -r ".[\"tfa.settings:enabled\"]"
db-tfa-config-required-roles:
command:
cmd: bash
args:
- -c
- |
set -o pipefail
drush config:get tfa.settings required_roles --include-overridden --format=json | jq -r ".[\"tfa.settings:required_roles\"]"
analyse:
tfa-module-absent:
equals:
description: tfa module not in codebase
input: db-tfa-module
key: stdout
value: 'null'
db-tfa-module-disabled:
equals:
description: tfa module is disabled
input: db-tfa-module
key: stdout
value: Disabled
remediation:
cmd: drush
args:
- pm:enable
- tfa
msg: tfa module has been successfully enabled
db-tfa-config-disabled:
equals:
description: tfa is disabled in config
input: db-tfa-config-enabled
key: stdout
value: false
remediation:
cmd: drush
args:
- config:set
- tfa.settings
- enabled
- '1'
msg: tfa config has been successfully enabled
db-tfa-no-role-required:
equals:
description: tfa has no required roles
input: db-tfa-config-required-roles
key: stdout
value: '[]'
remediation:
cmd: /path/to/tfa-role-remediation.sh
msg: tfa config has been updated to require a role