summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/filter/mandatory.yml
blob: 14058845a7435d1a9ac26a0a77ed1a6f81ab36fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
DOCUMENTATION:
  name: mandatory
  version_added: "historical"
  short_description: make a variable's existance mandatory
  description:
    - Depending on context undefined variables can be ignored or skipped, this ensures they force an error.
  positional: _input
  options:
    _input:
      description: Mandatory expression.
      type: raw
      required: true
    msg:
      description: The customized message that is printed when the given variable is not defined.
      type: str
      required: false
EXAMPLES: |

    # results in a Filter Error
    {{ notdefined | mandatory }}

    # print a custom error message
    {{ notdefined | mandatory(msg='This variable is required.') }}

RETURN:
  _value:
    description: The input if defined, otherwise an error.
    type: raw