I am having an issue where I include a playbook based on a variable. However, it seems that when the playbook is “skipped” it is still trying to evaluate my “when” statements for the tasks in that playbook. I have seen this behavior on the latest 1.2 release as well as the most recent 1.3 dev branch.
The original issue I thought was this:
https://github.com/ansible/ansible/issues/3539
But I am told this may be unrelated. This is the ‘main.yml’ and playbook I am using:
main.yml:
- include: dbapp.yml
when: “‘{{ role }}’ == ‘dbapp’” - include: webapp.yml
when: “‘{{ role }}’ == ‘webapp’” - include: solr.yml
when: “‘{{ role }}’ == ‘SOLR’”
dbapp.yml:
-
name: Check if tomcat 7 is installed
stat: path=/opt/apache-tomcat-{{ tc_ver }}
register: t7 -
name: Fetch tomcat 7
s3: >
bucket=xxxxxxxx
object=/tomcat/apache-tomcat-{{ tc_ver }}.tar.gz
dest=/tmp/apache-tomcat-{{ tc_ver }}.tar.gz
mode=get
ec2_access_key={{ aws_creds.access_key }}
ec2_secret_key={{ aws_creds.secret_key }}
when: t7.stat.isdir is not defined
ignore_errors: yes
I am using this command to call it with the results:
ansible-playbook -i host, -e “role=‘webapp’” profile_test.yml
Results:
PLAY [Configure instance(s) profiles] *****************************************
GATHERING FACTS ***************************************************************
ok: [xxxxxxxxxxxxxxx]
TASK: [Check if tomcat 7 is installed] ****************************************
skipping: [xxxxxxxxxxxxxxx]
TASK: [Fetch tomcat 7] ********************************************************
fatal: [xxxxxxxxxxxxxxx] => unable to evaluate conditional: {% if t7.stat.isdir is not defined %} True {% else %} False {% endif %}
FATAL: all hosts have already failed – aborting
PLAY RECAP ********************************************************************
xxxxxxxxxxxxxxx : ok=1 changed=0 unreachable=1 failed=0
Any help/advice would be much appreciated.
Regards,
Nick