From 2659a1cc190a43c5bfcc7a56b03ae73e19ffa372 Mon Sep 17 00:00:00 2001 From: jdreichmann Date: Sun, 5 Jul 2020 11:38:49 +0200 Subject: [PATCH] git: template .gitconfig --- git.yml | 7 +++++++ group_vars/git.yml | 30 ++++++++++++++++++++++++++++ local.yml | 3 +++ roles/git/defaults/main.yml | 17 ++++++++++++++++ roles/git/tasks/main.yml | 9 +++++++++ roles/git/templates/gitconfig.j2 | 34 ++++++++++++++++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 git.yml create mode 100644 group_vars/git.yml create mode 100644 roles/git/defaults/main.yml create mode 100644 roles/git/tasks/main.yml create mode 100644 roles/git/templates/gitconfig.j2 diff --git a/git.yml b/git.yml new file mode 100644 index 0000000..323109e --- /dev/null +++ b/git.yml @@ -0,0 +1,7 @@ +--- + +- name: Install & template git configuration + hosts: git + become: true + roles: + - git diff --git a/group_vars/git.yml b/group_vars/git.yml new file mode 100644 index 0000000..8a0c006 --- /dev/null +++ b/group_vars/git.yml @@ -0,0 +1,30 @@ +$ANSIBLE_VAULT;1.1;AES256 +61636132613664626434323334356466303734666664616338633036343865313331623734306331 +3533333362613430633461333832363163323766323265370a643039643361666132386166396334 +33643330396433626238363738356438653534666465663462636635353434333862373933666334 +6134376464623233310a663833646336643665626335386335623337623538383765633337313065 +32626132346632336237353931666166343639353339303935343732393337333032643638626539 +35623239653438666665366539346136346235663537663961366662323333613631613066393365 +37636265373832303862326163656639663762653061636261303836613638306133383132306236 +33353731363230633536353030626236366465613062616434656431333961323634313163356266 +30363062376532323864643737316335366231633433663536383032636335326338663137366131 +61396161336365633861646266336663363863383231616364326233623435356339333237653430 +61313563373939363437313466356133376632643431316461376265373833313537633832656337 +34356536373533303862373262386661643938366363363062373766373664653461383039666136 +65323038346632373230626664316638663636626338373166343433386635613066636637613465 +37633034626236353130636533316339653162303938316637666461363739653736323830316561 +35393865346436623861653036616263343731626633353336303637643035663362653465656134 +38653262373864306462643937636539373665626139623138336334343130636262353162633338 +33636636333064633431613863363530613165323064383132623935666338303464373466313964 +63316630323336643936356362643331383733626161633264346265326533653163303561333130 +36343834616432353937623161373531383234626634303335393665623335306462393762376235 +38306666656266363664636431613339303365623832343137666232323964333531653933383266 +32663135633664383866313339666461303034303539613532306362353336346163306662396561 +33343361313834643033323065376466346236396364386436343034393431353930353537353139 +34356363313730303032336566303433323730623638623264383833363566356266313265343538 +35633861383637383331326634363966393638333235373034353161633665343330383165316632 +39613032356638383062373731633834643864663433323832396430646362626563373831643531 +64323165326262343935646466366136343531656661626434613563646430343261306461303437 +38303863303230613065643431663432653734616239626337303363643263316236383364383739 +63393539346137393237613430396438373933656130376136613563613134386265663565626337 +66353235383937646661643734323533643731313764373435383833393532363362 diff --git a/local.yml b/local.yml index 99ff4d7..bb64759 100644 --- a/local.yml +++ b/local.yml @@ -26,3 +26,6 @@ vim: hosts: xenon: +git: + hosts: + xenon: diff --git a/roles/git/defaults/main.yml b/roles/git/defaults/main.yml new file mode 100644 index 0000000..1fb408f --- /dev/null +++ b/roles/git/defaults/main.yml @@ -0,0 +1,17 @@ +--- + +git_user: your-username +git_email: your-email@example.com +git_signkey: +git_signingkey: +git_do_sign: false + +git_user_home: "/home/{{ git_system_user }}" +git_system_user: "{{ git_user }}" +git_system_group: "{{ git_system_user }}" + +git_gpg_program: ~ + +git_aliases: [] + +git_credentials: [] diff --git a/roles/git/tasks/main.yml b/roles/git/tasks/main.yml new file mode 100644 index 0000000..3146540 --- /dev/null +++ b/roles/git/tasks/main.yml @@ -0,0 +1,9 @@ +--- + +- name: Template .gitconfig + template: + src: gitconfig.j2 + dest: "{{ git_user_home }}/.gitconfig" + owner: "{{ git_system_user }}" + group: "{{ git_system_group }}" + mode: 0660 diff --git a/roles/git/templates/gitconfig.j2 b/roles/git/templates/gitconfig.j2 new file mode 100644 index 0000000..b7aede9 --- /dev/null +++ b/roles/git/templates/gitconfig.j2 @@ -0,0 +1,34 @@ +# This is Git's per-user configuration file. +[user] +# Please adapt and uncomment the following lines: + name = {{ git_user }} + email = {{ git_email }} +{% if git_do_sign %} + signkey = {{ git_signkey }} + signingkey = {{ git_signingkey }} +{% endif %} + +{% if git_do_sign %} +[gpg] + program = {{ git_gpg_program }} + +{% endif %} +[commit] + +{% if git_do_sign %} + gpgsign = true +{% endif %} + + +[alias] +{% for alias in git_aliases %} + {{ alias.name }} = {{ alias.cmd }} +{% endfor %} + +{% for cred in git_credentials %} +[credential "{{ cred.remote_url }}"] + username = {{ cred.username }} +{% if cred.helper is defined %} + helper = {{ cred.helper }} +{% endif %} +{% endfor %}