Variable to be selected from the options

Hi,

I have the below variable defined in my playbook.

reboot_option:

  • IfRequired
  • Never
  • Always

while calling the same variable from the playbook , the value "IfRequired’ must be the default.
“rebootSetting”: “{{ reboot_option | default(Ifrequired) }}”

While executing the playbook without extra-vars reboot_option then by "ifrequired " need to the default,.
If the playbook is executed with -e “reboot_option=Never” or “Always” then it should select the given option.

how to call the dictionary items with default as “Ifrequired”?
Or I have to declare the variables in a different way ?

Using ansible’s order of precedence you can set the default value in the playbook and override it with extra_vars.

override.yaml:

Thanks Walter