When ansible do not load the file host_vars/{{ ansible_hostname }}.yml and host_vars/default.yml it will show syntactic err, so add keyword "skip" to fix it.
Exit the playbook if the user not define devices in both host_vars/{{ ansible_hostname }}.yml and host_vars/default.yml
host_vars/default.yml
- name: load a variable file for devices partition
include_vars: "{{ item }}"
with_first_found:
- - "host_vars/{{ ansible_hostname }}.yml"
- - "host_vars/default.yml"
+ - files:
+ - "host_vars/{{ ansible_hostname }}.yml"
+ - "host_vars/default.yml"
+ skip: true
+
+ - name: exit playbook, if devices not defined
+ fail:
+ msg: "devices must be define in host_vars/default.yml or host_vars/{{ ansible_hostname }}.yml"
+ when: devices is not defined
- name: install sgdisk(gdisk)
package: