2017-04-25 10:06:42 +02:00
---
- name : is /etc clean?
command : git status --porcelain
args :
chdir : /etc
changed_when : False
register : git_status
when : not ansible_check_mode
ignore_errors : yes
tags :
2018-03-16 14:20:25 +01:00
- etc-git
- commit-etc
2017-04-25 10:06:42 +02:00
- debug :
var : git_status
verbosity : 3
tags :
2018-03-16 14:20:25 +01:00
- etc-git
- commit-etc
2017-04-25 10:06:42 +02:00
2017-07-27 22:49:14 +02:00
- name : fetch current Git user.email
git_config :
name : user.email
repo : /etc
register : git_config_user_email
2017-08-14 17:06:12 +02:00
ignore_errors : yes
2018-03-16 14:20:25 +01:00
tags :
- etc-git
- commit-etc
2017-07-27 22:49:14 +02:00
2017-09-15 16:03:49 +02:00
- name : "set commit author"
2017-07-27 22:49:14 +02:00
set_fact :
2017-09-29 01:42:38 +02:00
commit_author : '{% if ansible_env.SUDO_USER is not defined %}root{% else %}{{ ansible_env.SUDO_USER }}{% endif %}'
2020-01-08 17:19:36 +01:00
commit_email : '{% if git_config_user_email.config_value is not defined or not git_config_user_email.config_value %}root@localhost{% else %}{{ git_config_user_email.config_value }}{% endif %}' # noqa 204
2018-03-16 14:20:25 +01:00
tags :
- etc-git
- commit-etc
2017-07-27 22:49:14 +02:00
2017-09-15 16:03:49 +02:00
- name : "/etc modifications are committed"
shell : "git add -A . && git commit -m \"{{ commit_message | mandatory }}\" --author \"{{ commit_author | mandatory }} <{{ commit_email | mandatory }}>\""
2017-04-25 10:06:42 +02:00
args :
chdir : /etc
register : etc_commit_end_run
2020-01-08 17:19:36 +01:00
when :
- not ansible_check_mode
- git_status.stdout
2017-04-25 10:06:42 +02:00
ignore_errors : yes
tags :
2018-03-16 14:20:25 +01:00
- etc-git
- commit-etc
2017-04-25 10:06:42 +02:00
- debug :
var : etc_commit_end_run
verbosity : 4
tags :
2018-03-16 14:20:25 +01:00
- etc-git
- commit-etc