Pass Ansible parameters to include_role
Q: &quot;Override certain parameters that pass them into the include_role task.&quot;
A: The parameter tasks_from serves this use-case. For example, create the task file
shell&gt; cat roles/git_cached/tasks/git.yml
- git:
    repo: &quot;{{ params.repo }}&quot;
    dest: &quot;{{ params.dest }}&quot;
    recursive: &quot;{{ params.recursive|default(ommit) }}&quot;
    depth: &quot;{{ params.depth|default('1') }}&quot;

Then &quot;call&quot; this task
    - name: Download something via Git
      include_role:
        name: git_cached
        tasks_from: git.yml
      vars:
        params:
          repo: https://somerepo
          dest: /some/path

You might want to complete the task with all git parameters:

The parameters repo and dest are required.

In some parameters, like recursive, the default values are defined. You can either omit the parameter, in which case the default value will be used, or define your own default.

Some parameters, like depth, don't have defaults.  Also here you can either omit the parameter, in which case the parameter won't be used or define your own default.

It's a good idea to &quot;namespace&quot; the variables.

It's a good idea to put the default variables into roles/git_cached/defaults/main.yml