commit 8b6973f8be4d9381386e85e3d8f43c5caf68fef1 Author: Timo Makinen Date: Thu Jun 24 19:31:55 2021 +0300 Add git client diff --git a/git/tasks/main.yml b/git/tasks/main.yml new file mode 100644 index 0000000..b14c78f --- /dev/null +++ b/git/tasks/main.yml @@ -0,0 +1,22 @@ +--- + +- name: install git packages + package: + name: git + state: installed + +- name: create git config for sh based shells + template: + dest: /etc/profile.d/git.sh + src: git.sh.j2 + mode: 0644 + owner: root + group: root + +- name: create git config for csh based shells + template: + dest: /etc/profile.d/git.csh + src: git.csh.j2 + mode: 0644 + owner: root + group: root diff --git a/git/templates/git.csh.j2 b/git/templates/git.csh.j2 new file mode 100644 index 0000000..107ce34 --- /dev/null +++ b/git/templates/git.csh.j2 @@ -0,0 +1,8 @@ +if ($uid > 3000 && "`/usr/bin/id -gn`" == "`/usr/bin/id -un`") then + if ( "`git config user.name`" == "" ) then + git config --global user.name "`getent passwd '${USER}' | cut -d : -f 5`" + endif + if ( "`git config user.email`" == "" ) then + git config --global user.email "${USER}@{{ mail_domain }}" + endif +endif diff --git a/git/templates/git.sh.j2 b/git/templates/git.sh.j2 new file mode 100644 index 0000000..6367672 --- /dev/null +++ b/git/templates/git.sh.j2 @@ -0,0 +1,8 @@ +if [ $UID -gt 3000 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then + if [ -z "$(git config user.name)" ]; then + git config --global user.name "$(getent passwd "$USER" | cut -d : -f 5)" + fi + if [ -z "$(git config user.email)" ]; then + git config --global user.email "${USER}@{{ mail_domain }}" + fi +fi