Ansible vars precendence

I have an Ansible playbook that I want to load custom variables for. I do not have access to the inventory but I wish to classify the variables by their host names which can be classified in groups. The jobs would be fired from Ansible Tower. Where should I put these variables such that they by default override the values in tower? I’ve tried putting them in the vars file in the role that’s supposed to run but the operation occurs as per the values in tower. I’ve tried putting them in the main play as well but it returns an error “<> should be a list or None.”

  • name: manage services

hosts: all
tasks:
include_vars:

  • “{{playbook_dir}}/…/roles/service_management/vars/s1s2grouping.yml”

A little test in the role shows that the file is being loaded.

  • name: include variables
    include_vars:
    file: s1s2grouping.yml
    register: checking

  • debug: “msg={{checking.ansible_included_var_files}}”

The above code results in a positive answer.

I fixed the error in the main play

  • name: manage services

hosts: all
tasks:

  • include_vars: “{{playbook_dir}}/…/roles/service_management/vars/s1s2grouping.yml”

But now it won’t read variables