--- - name: is /etc clean? command: git status --porcelain args: chdir: /etc changed_when: False register: git_status # Use this with Ansible 2.1+ #when: not ansible_check_mod always_run: yes tags: - git - name: /etc modifications are committed shell: "git add -A . && git commit -m \"{{ commit_message | default('Ansible run') }}\"" args: chdir: /etc register: etc_commit_end_evolinux # Use this with Ansible 2.1+ #when: not ansible_check_mode and git_status.stdout != "" when: git_status.stdout != "" tags: - git