Hi,
I encountered a problem and cannot figure it out. I have a Ansible task to 
install a web app. This web app task has a role dependency to install 
tomcat while tomcat has a role dependency to install java. In the java task 
I created two files under /role/java/var to define the different java 
version on Solaris and Linux. I used the following code to include the yml 
files under /role/java/var:

- name: Include variables for the appropriate OS family
  include_vars: "{{ ansible_os_family }}.yml"

After the code above the java task will include linux.yml and solaris.yml 
based on the OS:

- name: Include RedHat-specific tasks
  include: RedHat.yml
  when: ansible_os_family == "RedHat"

- name: Include Solaris-specific tasks
  include: Solaris.yml
  when: ansible_os_family == "Solaris"


Inside the RedHat.yml there are series tasks and one of those is looking 
for the java version to install:

- name: Install Oracle JDK (RedHat)
  yum: name="{{ item }}" state=present enablerepo=kdm
  with_items: "jdkversions[ jdkversion ]['pkgs']"
  register: yum_install
  ignore_errors: yes

The "jdkversions" is defined in the yml file under /role/java/var. 
Everything works fine if tomcat and java are installed.

If I gave a condition to the web app task not to run role dependency 
"tomcat" then problem is coming: it still goes to Java task and skips all 
the other tasks but "- name: Install Oracle JDK (RedHat)"; and then throws 
out error complaining that "with_items expects a list or a set" because the 
yml files under  /role/java/var were not loaded and thus no "jdkversions" 
is defined.

Can anyone please tell me the rule that which task will be skipped and 
which one will not be skipped if the role dependencies are told not to 
execute? I understand that Ansible will parse all tasks regardless even I 
told the role dependencies not to run but if some tasks are skipped while 
the others are not then how to resolve it?

Thanks in advance.


-- 
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/599f324e-9a33-4190-86e0-78444ffa4a59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to