Variable registration step, ignore_errors, and idempotency

41 views
Skip to first unread message

Synaesthete

unread,
Jul 23, 2014, 1:14:35 PM7/23/14
to ansible...@googlegroups.com
I'm writing a playbook that runs an initial git commit on a folder if there has not yet been a commit. I check this using:

- name: Get commit count
  command: git rev-list HEAD --count chdir={{ project_path }}
  ignore_errors: yes
  register: git_commit_count

If there have been no commits, this command returns an error, in which case I then conditionally run a few other git-related steps. I have two issues with this:
  1. Even if the error is ignored, it is still reported in the log display even if I have not enabled verbose mode
  2. This step always reports "changed" which breaks my idempotency check that ensures changed=0 on a second run
Is there a good way to work around this? Can I take this step "off the record"?

Michael DeHaan

unread,
Jul 23, 2014, 6:15:36 PM7/23/14
to ansible...@googlegroups.com
Instead of ignore_errors: True, consider:

failed_when: False

The reporting of changed always can be fixed with

changed_when: False




--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e7a16351-f652-4d12-96a9-5be523b32aad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Synaesthete

unread,
Jul 24, 2014, 1:25:17 PM7/24/14
to ansible...@googlegroups.com
Perfect, exactly what I needed. Thanks!
Reply all
Reply to author
Forward
0 new messages