I'm such an idiot, "result|failed" works like a charm. I kept reading the "|" as an "OR" statement. Ugh.
On Tuesday, June 23, 2015 at 11:48:42 AM UTC-4, Stephen Granger wrote: > > I'd use register for the first task and just use the when conditional. > > - name: Install rpm > yum: name= > sudo: true > ignore_errors; yes > register: yum_install > > - name: Notify Hipchat of success > hipchat: ... > color: green > when: yum_install|success > > - name: Notify Hipchat of failure > hipchat: ... > color: red > when: yum_install|failed > > https://docs.ansible.com/playbooks_conditionals.html > > There maybe other ways to do it though. > > On 23 June 2015 at 07:46, Samnang Sen <[email protected] <javascript:>> > wrote: > >> FYI, I'm running my Ansible playbook in "pull-mode" not push mode. >> Therefore, my nodes will publish the results of their task via Hipchat. >> >> With that said, I have a task that installs RPMs. When the installs are >> successful, the nodes notify via Hipchat that the task was successfully >> run. Now, in the event that a task fails, i force it to notify hipchat w/ >> the "--force-handlers" paramter. My question, is there a way to display a >> message according to whether it fails or runs successfully? >> >> If I had to, I don't mind having multiple handlers because I would need >> to modify the color for fail tasks to red as suppose to the default yellow >> or green for a successful run. >> >> This works great >> >> # Task >> - name: Install Perl modules >> command: sudo rpm -Uvh {{ rpm_repository }}/{{ item.key }}-{{ >> item.value.svn_tag }}.rpm --force >> with_dict: deploy_modules_perl >> notify: announce_hipchat >> >> # Handler >> >> - name: announce_hipchat >> local_action: hipchat >> from="deployment" >> token={{ hipchat_auth_token }} >> room={{ hipchat_room }} >> msg="[{{ ansible_hostname }}] Successfully installed RPMs!" >> validate_certs="no" >> >> >> >> -- >> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/9192b3db-e42d-4b2e-bd6a-b688a2f1aa3f%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/9192b3db-e42d-4b2e-bd6a-b688a2f1aa3f%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Steve > -- 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/b7c3bd32-829c-4d4c-b463-8825c70400b6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
