This is being copied from the bug that just got closed:


ANSIBLE VERSION 

ansible 2.2.1.0
 

CONFIGURATION 

Nothing weird here


OS / ENVIRONMENT 

MAC Sierra 10.12.3
Destination: CentOS 7


SUMMARY 

Using a conditional with the include for a task include is ignored.
I have run it using static: no and without - the results are the same.


I am running this play for a web server which is defined as modef-prod-web.
There are alert servers which run as mozdef-prod-alert.


Running this for mozdef-prod-web should essentially only include the 
mozdef-web.yml - and no other includes. But it doesn't seem to check the 
conditional.


Inventory List

Inventory list:
[mozdef-prod-web]
192.168.250.134


[mozdef-prod-alert]

192.168.250.135




mozdef-update.yml:

   - hosts: mozdef-prod-web
   remote_user: phrozyn
   become: yes
   become_user: someuser
   roles: 
      - mozdef-update
   

- include: mozdef-alert.yml
  static: no
  when: ("'mozdef-prod-alert' in group_names") or ("'mozdef-dev' in 
group_names") or ("'mozdef-gen2-qa' in group_names")

- include: mozdef-consumer.yml
  static: no
  when: ("'mozdef-prod-ingest' in group_names") or ("'mozdef-dev' in 
group_names") or ("'mozdef-gen2-qa' in group_names")

- include: mozdef-web.yml
  static: no
  when: ("'mozdef-prod-web' in group_names") or ("'mozdef-dev' in group_names") 
or ("'mozdef-gen2-qa' in group_names")

- include: mozdef-qa.yml
  static: no
  when: ("'mozdef-gen2-qa' in group_names") or ("'mozdef-dev' in group_names")

 

EXPECTED RESULTS 

TASK [mozdef-update : include] 
*************************************************
task path: 
/Users/Phrozyn/Projects/mozdef-dev/QA/ansible-eis/roles/mozdef-update/tasks/main.yml:45
included: 
/Users/Phrozyn/Projects/mozdef-dev/QA/ansible-eis/roles/mozdef-update/tasks/mozdef-web.yml
 
for 192.168.250.134


ACTUAL RESULTS 

TASK [mozdef-update : include] 
*************************************************
task path: 
/Users/Phrozyn/Projects/mozdef-dev/QA/ansible-eis/roles/mozdef-update/tasks/main.yml:45
included: 
/Users/Phrozyn/Projects/mozdef-dev/QA/ansible-eis/roles/mozdef-update/tasks/mozdef-alert.yml
 
for 192.168.250.134



It of course dies when it runs because the webserver's group_vars don't 
include variables for the alert tasks.

So any help would be appreciated!

Keep in mind, this fails whether or not static: no is designated

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/994365b7-9a1f-4023-b617-f5b472775b02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to