From 3207d837cbf475f69854e08181206075320277b3 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Fri, 15 Sep 2017 16:03:49 +0200 Subject: [PATCH] etc-git: better commit author composition --- etc-git/tasks/commit.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/etc-git/tasks/commit.yml b/etc-git/tasks/commit.yml index e83d85c6..c11b453c 100644 --- a/etc-git/tasks/commit.yml +++ b/etc-git/tasks/commit.yml @@ -24,12 +24,13 @@ register: git_config_user_email ignore_errors: yes -- name: set commit author +- name: "set commit author" set_fact: - etc_git_commit_options: "{ --author \"{{ ansible_env.SUDO_USER |default(\"root\")}} <{{ git_config_user_email.config_value |default(\"root@localhost\")}}>\"" + commit_author: '{% if ansible_env.SUDO_USER == "" %}root{% else %}{{ ansible_env.SUDO_USER }}{% endif %}' + commit_email: '{% if git_config_user_email.config_value == "" %}root@localhost{% else %}{{ git_config_user_email.config_value }}{% endif %}' -- name: /etc modifications are committed - shell: "git add -A . && git commit -m \"{{ commit_message | mandatory }}\"{{ etc_git_commit_options }}" +- 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