From b232b894c3cbe087c8d504e91637dcf62199eed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Thu, 29 Jul 2021 17:00:20 +0200 Subject: Bump to third revision of homelab --- roles/git/defaults/main.yml | 12 +++++++++ roles/git/tasks/main.yml | 53 +++++++++++++++++++--------------------- roles/git/templates/gitconfig.j2 | 2 ++ roles/git/vars/main.yml | 11 --------- 4 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 roles/git/defaults/main.yml create mode 100644 roles/git/templates/gitconfig.j2 delete mode 100644 roles/git/vars/main.yml (limited to 'roles/git') diff --git a/roles/git/defaults/main.yml b/roles/git/defaults/main.yml new file mode 100644 index 0000000..2128abb --- /dev/null +++ b/roles/git/defaults/main.yml @@ -0,0 +1,12 @@ + +# git ~~ roles/git/tasks/vars.yml +# default vars for git role + +--- + +git_user: "git" +git_group: "git" +git_dir: "/data/git" + +git_shell: "/bin/sh" +git_default_branch: "trunk" diff --git a/roles/git/tasks/main.yml b/roles/git/tasks/main.yml index 5600e2d..a421ad0 100644 --- a/roles/git/tasks/main.yml +++ b/roles/git/tasks/main.yml @@ -5,7 +5,9 @@ --- - name: ensure git package is present - package: name=git state=present + package: + name: git + state: present - name: ensure git group exists group: @@ -17,43 +19,38 @@ name: "{{ git_user }}" group: "{{ git_group }}" shell: "{{ git_shell }}" - home: "/home/{{ git_user }}" + home: "{{ git_dir }}" create_home: false -- name: ensure git home directory is not created - file: path="/home/{{ git_user }}" state=absent - -- name: ensure git-only directory exists - file: - path: "{{ git_dir }}" - owner: "{{ git_user }}" - group: "{{ git_group }}" - state: directory - mode: 0755 - -- name: link git user home directory with git root repository - file: - src: "{{ git_dir }}" - dest: "/home/{{ git_user }}" - owner: "{{ git_user }}" - group: "{{ git_group }}" - mode: 0750 - force: true - state: link - -- name: ensure git-shell-commands directory exists +- name: ensure git directories exist file: - path: "/home/{{ git_user }}/git-shell-commands" + path: "{{ item }}" owner: "{{ git_user }}" group: "{{ git_group }}" state: directory - mode: 0755 + mode: "0755" + loop: + - "{{ git_dir }}" + - "{{ git_dir }}/git-shell-commands" - name: generate git-shell no-login prompt template: src: no-interactive-login.j2 - dest: "/home/{{ git_user }}/git-shell-commands/no-interactive-login" + dest: "{{ git_dir }}/git-shell-commands/no-interactive-login" owner: "{{ git_user }}" group: "{{ git_group }}" - mode: 0744 + mode: "0744" when: git_nologin is defined and git_nologin + +- name: generate gitconfig + template: + src: gitconfig.j2 + dest: "{{ git_dir }}/.gitconfig" + owner: "{{ git_user }}" + group: "{{ git_group }}" + mode: "0644" + +- name: synchronize ssh key + include_role: + name: sshd + tasks_from: sync_keys 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/vars/main.yml b/roles/git/vars/main.yml deleted file mode 100644 index 6f7ffb8..0000000 --- a/roles/git/vars/main.yml +++ /dev/null @@ -1,11 +0,0 @@ - -# git ~~ roles/git/tasks/vars.yml -# default vars for git role - ---- - -git_user: "git" -git_group: "git" -git_dir: "/data/git" - -git_shell: "/bin/sh" -- cgit v1.2.3