Using group vars and vars from vars prompt

19 views
Skip to first unread message

Sarvani Vadali

unread,
Aug 13, 2020, 2:00:10 PM8/13/20
to Ansible Development
I am trying to get a value through vars prompt in my playbook and writing a task in a role to see if the value == foo or if value == bar
if the value == foo ,i want to get values from the vars.yaml file which has a section for foo .
The section for foo in vars.yaml file has source path and destination path for copying.

 I am struggling to see how to use loops in this case,any help is appreciated.

Pushparaj Gothandam

unread,
Aug 24, 2020, 2:04:05 AM8/24/20
to Ansible Development
Can you try something like this

- name: Conditionally decide to load in variables into 'plans' when x is 0, otherwise do not. (2.2)
include_vars:
file: contingency_plan.yaml
name: plans
when: x == 0

Reply all
Reply to author
Forward
0 new messages