Make it possible to set tasks_from to None in include_role

If you want to just include defaults, vars and handlers it would be nice to be able to not run any of the roles tasks.

I would not do this in include_role, this makes more sense in roles:
declaration (as a resource).

I dont quite get what you mean by as a resource.

I was thinking like this:

hosts: ahost
become: true
tasks:

  • name: get defaults
    include_role:
    name: geerlingguy.certbot
    tasks_from: none # no tasks just defaults and handlers
  • debug:
    msg: “This task requires {{ a_default_var_from_certbot }}”

How would you suggest how it should be done?

Or something like a lookup:

  • name: include_defaults from role
    include_vars:
    dir: “{{ lookup(‘role_dir’, ‘geerlingguy.certbot dir=defaults’ ) }}”

> I would not do this in include_role, this makes more sense in
> roles: declaration (as a resource).

I dont quite get what you mean by as a resource.

perhaps meaning, roles as a kind of resource container, to bring
in variables and things, rather than something executed. there's
a discussion of what to call it here:
https://github.com/ansible/proposals/pull/4

I didn't realize there was a difference between declaring something
in "roles:" and as an "include_role:" besides just when it was run.
Based on these comments, it seems that "include_role" is intended
more for "executing" roles i.e. running tasks/main.yml whereas
appearance in "roles" is intended for importing "resources" ?

  tasks:
      - name: get defaults
        include_role:
          name: geerlingguy.certbot
          tasks_from: none # no tasks just defaults and handlers
      - debug:
           msg: "This task requires {{ a_default_var_from_certbot }}"

your "tasks_from" appears to be the exact intention of "exec_main"
from the linked feature proposal.

Ah, did not know there was a proposal.

This proposal seems like a good solution.

A temporary (hopefully) solution to this issue for me.

In ansible.cfg

[defaults]
roles_path=required_roles/

ansible-galaxy install --roles-path required_roles geerlingguy.certbot

touch required_roles/geerlingguy.certbot/tasks/none.yml

  • name: certbot vars and defaults
    include_role:
    name: geerlingguy.certbot
    tasks_from: none