2018-12-28 11:23:49 +01:00
---
- name : is /etc clean?
command : git status --porcelain
args :
chdir : /etc
2020-06-01 11:37:15 +02:00
changed_when : false
2018-12-28 11:23:49 +01:00
register : git_status
when : not ansible_check_mode
2020-06-01 11:37:15 +02:00
ignore_errors : true
2018-12-28 11:23:49 +01:00
tags :
2020-06-01 11:37:15 +02:00
- etc-git
- commit-etc
2018-12-28 11:23:49 +01:00
- debug :
var : git_status
verbosity : 3
tags :
2020-06-01 11:37:15 +02:00
- etc-git
- commit-etc
2018-12-28 11:23:49 +01:00
- name : fetch current Git user.email
git_config :
name : user.email
repo : /etc
scope : local
register : git_config_user_email
2020-06-01 11:37:15 +02:00
ignore_errors : true
2018-12-28 11:23:49 +01:00
tags :
2020-06-01 11:37:15 +02:00
- etc-git
- commit-etc
2018-12-28 11:23:49 +01:00
2020-06-04 18:51:53 +02:00
# yamllint disable rule:line-length
2018-12-28 11:23:49 +01:00
- name : set commit author
set_fact :
commit_author : '{% if ansible_env.SUDO_USER is not defined %}root{% else %}{{ ansible_env.SUDO_USER }}{% endif %}'
2020-06-01 11:37:15 +02:00
commit_email : '{% if git_config_user_email.config_value is not defined or git_config_user_email.config_value == "" %}root@localhost{% else %}{{ git_config_user_email.config_value }}{% endif %}'
2018-12-28 11:23:49 +01:00
tags :
2020-06-01 11:37:15 +02:00
- etc-git
- commit-etc
2018-12-28 11:23:49 +01:00
- name : /etc modifications are committed
shell : "git add -A . && git commit -m \"{{ commit_message | mandatory }}\" --author \"{{ commit_author | mandatory }} <{{ commit_email | mandatory }}>\""
args :
chdir : /etc
register : etc_commit_end_run
when : not ansible_check_mode and git_status.stdout != ""
2020-06-01 11:37:15 +02:00
ignore_errors : true
2018-12-28 11:23:49 +01:00
tags :
2020-06-01 11:37:15 +02:00
- etc-git
- commit-etc
2020-06-04 18:51:53 +02:00
# yamllint enable rule:line-length
2018-12-28 11:23:49 +01:00
- debug :
var : etc_commit_end_run
verbosity : 4
tags :
2020-06-01 11:37:15 +02:00
- etc-git
- commit-etc