Skip to content

include_role does not work with with_items #17966

@trondhindenes

Description

@trondhindenes
ISSUE TYPE
  • Bug Report
COMPONENT NAME

include_role

ANSIBLE VERSION
2.3.0
SUMMARY

The new "include_role" task does not work with with_items

STEPS TO REPRODUCE

In the example playbook below, the role "myrole" is first run stand-alone, and then as a with_items loop.


---
- name: Do stuff to stuff
  hosts: localhost
  tasks:
    - name: set fact
      set_fact:
        thing: otherstuff
    - name: myrole
      include_role:
        name: myrole
      vars:
        thing: "asdf"
    - name: myrole
      with_items:
        - "aone"
        - "atwo"
      include_role:
        name: myrole
      vars:
        thing: "{{ item }}"
EXPECTED RESULTS

Success

ACTUAL RESULTS

Error part of the output

TASK [myrole] ******************************************************************
task path: /mnt/c/Users/trond/Documents/projects/ansibledev/rolestesting/main.yml:13
failed: [localhost] (item=aone) => {
    "failed": true,
    "item": "aone",
    "msg": "No role was specified to include"
}
failed: [localhost] (item=atwo) => {
    "failed": true,
    "item": "atwo",
    "msg": "No role was specified to include"
}
ERROR! Unexpected Exception: 'results'

Metadata

Metadata

Assignees

Labels

P2Priority 2 - Issue Blocks ReleasebugThis issue/PR relates to a bug.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions