Ansible playbook does not work as expected, when using include_role with with_items to loop over multiple roles.

92 views
Skip to first unread message

uday shankar

unread,
May 23, 2017, 5:09:58 PM5/23/17
to Ansible Project
$ ansible --version
ansible 2.4.0 (devel 16d522cf2c) last updated 2017/05/22 14:49:05 (GMT -700)

# role/ServiceDeploy/tasks/main.yml
- name: SERVICE Deployment
  include_role:
    name: '{{item}}'
  with_items:
     - "{{ SERVICE_DEPLOY_LIST }}"

# Defaults/main.yml
SERVICE_DEPLOY_LIST:
  - 'MicroService1'
  - 'MicroService2'
  - 'MicroService3'
  - 'MicroService4'
  - 'MicroService5'

# roles/MicroService1/tasks/main.yml
- name: Initiating Service Deployment
  include_role:
    name: DEPLOY
  tags: MicroService1-Deploy
  
# roles/DEPLOY/tasks/main.yml
- Huge list of tasks

EXPECTED RESULTS
I should be able to call multiple roles, using include_role and with_items. So that I can deploy all the services at the same time.

ACTUAL RESULTS - When I list tasks (--list-tasks)

It does not call Nested Roles
      
playbook: deploy.yml

play #1 (all): SERVICE Deployment TAGS: []
tasks:
ServiceDeploy : Initiating Service Deployment TAGS: [ServiceDeploy]
Reply all
Reply to author
Forward
0 new messages