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
|
|
|
|
|
|
|
- name: set commit author
|
|
|
|
set_fact:
|
2020-06-04 19:10:08 +02:00
|
|
|
commit_author: >
|
|
|
|
{% if ansible_env.SUDO_USER is not defined %}
|
|
|
|
root
|
|
|
|
{% else %}
|
|
|
|
{{ ansible_env.SUDO_USER }}
|
|
|
|
{% endif %}
|
|
|
|
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
|
2020-06-04 19:10:08 +02:00
|
|
|
shell: >
|
|
|
|
git add -A .
|
|
|
|
&& git commit
|
2020-07-02 16:40:17 +02:00
|
|
|
-m "{{ commit_message | mandatory }}"
|
|
|
|
--author
|
|
|
|
"{{ commit_author | mandatory }} <{{ commit_email | mandatory }}>"
|
2018-12-28 11:23:49 +01:00
|
|
|
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
|
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
|