Why is the conditional check failed ?
My CSV file:
No.,OS,Information
1,**Linux**,CentOS 8.3
2,**Windows**,Windows 2016
---
- name: Test_CSV
hosts: localhost
gather_facts: True
tasks:
- read_csv:
path: test.csv
delimiter: ','
register: servers
- include_tasks: Linux.yml
when: vm.OS == "Linux"
- include_tasks: Windows.yml
when: vm.OS == "Windows"
loop: "{{ servers.list }}"
loop_control:
loop_var: vm
Linux.yml
---
- debug:
msg: "OS = Linux"
Windows.yml
---
- debug:
msg: "OS = Windows"
The error I get is this:
fatal: [localhost]: FAILED! => { "msg": "The conditional check 'vm.OS == "Linux"' failed. The error was: error while evaluating conditional (vm.OS == to be in '/itoa/condition/20210920/Test_CSV.yml': line 13, column 7, but may\nbe elsewhere in the file depending on the eto be:\n\n\n - include_tasks: Linux.yml\n ^ here\n" }
or is there another way Please help guide me.
Thanks,