From e60e99796111ee6d43080b4e48971c08886c0570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sat, 11 Dec 2021 13:54:22 +0000 Subject: roles: Add git and cgit roles --- roles/git/defaults/main.yml | 7 +++++ roles/git/tasks/main.yml | 45 +++++++++++++++++++++++++++++ roles/git/templates/gitconfig.j2 | 2 ++ roles/git/templates/no-interactive-login.j2 | 7 +++++ 4 files changed, 61 insertions(+) create mode 100644 roles/git/defaults/main.yml create mode 100644 roles/git/tasks/main.yml create mode 100644 roles/git/templates/gitconfig.j2 create mode 100644 roles/git/templates/no-interactive-login.j2 (limited to 'roles/git') diff --git a/roles/git/defaults/main.yml b/roles/git/defaults/main.yml new file mode 100644 index 0000000..f99dec3 --- /dev/null +++ b/roles/git/defaults/main.yml @@ -0,0 +1,7 @@ +git_user: git +git_group: git +git_dir: /data/git + +git_shell: /bin/sh +git_default_branch: trunk +git_allow_ssh_login: true diff --git a/roles/git/tasks/main.yml b/roles/git/tasks/main.yml new file mode 100644 index 0000000..4d2b74e --- /dev/null +++ b/roles/git/tasks/main.yml @@ -0,0 +1,45 @@ +- name: install git package + package: + name: git + state: present + +- name: create git group + group: + name: "{{ git_group }}" + state: present + +- name: create git user + user: + name: "{{ git_user }}" + group: "{{ git_group }}" + shell: "{{ git_shell }}" + home: "{{ git_dir }}" + create_home: false + +- name: create git directories + file: + path: "{{ item }}" + owner: "{{ git_user }}" + group: "{{ git_group }}" + state: directory + mode: 0755 + loop: + - "{{ git_dir }}" + - "{{ git_dir }}/git-shell-commands" + +- name: generate git-shell no-login prompt + template: + src: no-interactive-login.j2 + dest: "{{ git_dir }}/git-shell-commands/no-interactive-login" + owner: "{{ git_user }}" + group: "{{ git_group }}" + mode: "0744" + when: not git_allow_ssh_login + +- name: generate gitconfig + template: + src: gitconfig.j2 + dest: "{{ git_dir }}/.gitconfig" + owner: "{{ git_user }}" + group: "{{ git_group }}" + mode: 0644 diff --git a/roles/git/templates/gitconfig.j2 b/roles/git/templates/gitconfig.j2 new file mode 100644 index 0000000..b9923a2 --- /dev/null +++ b/roles/git/templates/gitconfig.j2 @@ -0,0 +1,2 @@ +[init] + defaultBranch = {{ git_default_branch }} diff --git a/roles/git/templates/no-interactive-login.j2 b/roles/git/templates/no-interactive-login.j2 new file mode 100644 index 0000000..bfe6011 --- /dev/null +++ b/roles/git/templates/no-interactive-login.j2 @@ -0,0 +1,7 @@ +#!/bin/sh + +cat <