From ff864b50a1af434a6cc5bd58ebd684606c962195 Mon Sep 17 00:00:00 2001 From: Benjamin Graillot <graillot@crans.org> Date: Wed, 10 Feb 2021 19:18:04 +0100 Subject: [PATCH] Better header Updates according to file rather than repository --- group_vars/all/vars.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/group_vars/all/vars.yaml b/group_vars/all/vars.yaml index b1ef1c5a..edc8efa2 100644 --- a/group_vars/all/vars.yaml +++ b/group_vars/all/vars.yaml @@ -1,15 +1,19 @@ --- # Custom header -dirty: "{{lookup('pipe', 'git diff --quiet || echo dirty')}}" +dirty: "{% if template_path is defined %}{{ lookup('pipe', 'git diff --quiet -- ' + template_path | quote + ' || echo dirty') }}{% else %}{{ lookup('pipe', 'git diff --quiet || echo dirty') }}{% endif %}" ansible_header: | +++++++++++++++++++++++++++++++++++++++++++++++++++ Ansible managed, don't modify the file locally. See https://gitlab.crans.org/nounous/ansible. + {% if template_path is defined %}{% set _, rpath = template_path.split('roles/', 1) %}Commit: {% if dirty %}({{dirty}}) {% endif %}{{ lookup('pipe', 'git log -n 1 --pretty=format:%H -- ' + template_path | quote) }} + {% if dirty %}Run by: {{ ansible_env.SUDO_USER }} + {% else %}Author: {{ lookup('pipe', 'git log -n 1 --pretty=format:%an -- ' + template_path | quote) }} + {% endif %}Template: roles/{{ rpath }} + {% else %} Run by: {{ ansible_env.SUDO_USER }} Latest commit: {% if dirty %}({{dirty}}) {% endif %}{{ lookup('pipe', 'git rev-parse HEAD') }} - {% if template_path is defined %}{% set _, rpath = template_path.split('roles/') %}Template: roles/{{ rpath }} {% endif %} +++++++++++++++++++++++++++++++++++++++++++++++++++ -- GitLab