Hello, I'm running in to an issue with conditional includes. I'm trying to create an automatic rollback procedure for one of my playbooks which attempts to deploy new versions of our company software. I'm using includes to abstract the common roll back tasks to separate YAML files in a directory called "rollback". I've included a small sample of the playbook below which includes "rollback/exit.yml" when the result of the previous task failed. What seems to happen is that ansible includes the tasks from the rollback/exit.yml file and applies the "when: result|failed" condition to every task in the included yaml file. This produces the desired result but does print out a bunch of "skipped" messages as shown below. Is there a way to tell ansible to only include the tasks if the previous task failed or to not show the skipped tasks? Is there a better way to accomplish what I'm trying to do?
I'm using a version of the command below to run the playbook (filename of playbook changed): ansible-playbook playbooks/company_app.yml -i playbooks/hosts --tags > "testing" > > playbooks/company_app.yml --- > - hosts: all > vars: > RPM_NAME: 'company_app_pacakge_name' > remote_user: ansible > sudo: yes > #accelerate: true > tasks: > - name: Installing new RPM > yum: "name={{ RPM_NAME }} state=present" > ignore_errors: true > tags: > - testing > register: result > - include: rollback/exit.yml > when: result|failed > <<snip>> > > playbooks/rollback/exit.yml --- - fail: msg="The company_app deployment failed." tags: - testing Ansible version: $ ansible-playbook --version ansible-playbook 1.6.3 Skipped message: [ansible@master01 ~]$ ansible-playbook playbooks/company_app.yml -i playbooks/hosts --tags "testing" PLAY [all] ******************************************************************** GATHERING FACTS *************************************************************** ok: [ansible_node] TASK: [Installing new RPM] **************************************************** ok: [ansible_node] TASK: [fail msg="The company_app deployment failed."] **************************** skipping: [ansible_node] Thanks for the help, Derrick -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7f43cbe3-58fc-4384-bc3f-64dd86e14714%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.