Ansible roles by Evolix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

  1. ---
  2. - name: is /etc clean?
  3. command: git status --porcelain
  4. args:
  5. chdir: /etc
  6. changed_when: False
  7. register: git_status
  8. when: not ansible_check_mode
  9. ignore_errors: yes
  10. tags:
  11. - commit-etc
  12. - debug:
  13. var: git_status
  14. verbosity: 3
  15. tags:
  16. - commit-etc
  17. - name: fetch current Git user.email
  18. git_config:
  19. name: user.email
  20. repo: /etc
  21. register: git_config_user_email
  22. ignore_errors: yes
  23. - name: "set commit author"
  24. set_fact:
  25. commit_author: '{% if ansible_env.SUDO_USER is not defined %}root{% else %}{{ ansible_env.SUDO_USER }}{% endif %}'
  26. commit_email: '{% if git_config_user_email.config_value == "" %}root@localhost{% else %}{{ git_config_user_email.config_value }}{% endif %}'
  27. - name: "/etc modifications are committed"
  28. shell: "git add -A . && git commit -m \"{{ commit_message | mandatory }}\" --author \"{{ commit_author | mandatory }} <{{ commit_email | mandatory }}>\""
  29. args:
  30. chdir: /etc
  31. register: etc_commit_end_run
  32. when: not ansible_check_mode and git_status.stdout != ""
  33. ignore_errors: yes
  34. tags:
  35. - commit-etc
  36. - debug:
  37. var: etc_commit_end_run
  38. verbosity: 4
  39. tags:
  40. - commit-etc