CU-eprjdn[complete] Merge pull request #8 from bdebyl/CU-eprjdn

CU-eprjdn added git server role
This commit is contained in:
bdebyl
2020-10-20 22:15:03 -04:00
committed by GitHub
8 changed files with 83 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
- vars/vault.yml - vars/vault.yml
roles: roles:
- role: common - role: common
- role: git
- role: ddns - role: ddns
- role: ssl - role: ssl
- role: http - role: http

View File

@@ -0,0 +1,3 @@
---
git_user: git
git_home: "/srv/{{ git_user }}"

View File

@@ -0,0 +1,8 @@
---
- name: start-gitdaemon
become: true
systemd:
name: git-daemon.service
state: started
enabled: true
daemon_reload: true

View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: common

View File

@@ -0,0 +1,3 @@
---
- import_tasks: user.yml
- import_tasks: systemd.yml

View File

@@ -0,0 +1,11 @@
---
- name: create the git daemon systemd service
become: true
template:
src: "templates/{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
mode: 0644
with_items:
- git-daemon.service
notify: start-gitdaemon
tags: git, git-systemd

View File

@@ -0,0 +1,36 @@
---
- name: create git user
become: true
user:
name: "{{ git_user }}"
comment: Git user for SSH remotes
shell: /usr/bin/git-shell
createhome: true
home: "{{ git_home }}"
tags: git
- name: create git's .ssh directory
become: true
become_user: git
file:
path: "{{ git_home }}/.ssh"
state: directory
mode: 0700
tags: git
- name: check git authorized_keys exists
become: true
stat:
path: "{{ git_home }}/.ssh/authorized_keys"
register: git_authfile
tags: git
- name: touch git authorized_keys
become: true
become_user: git
file:
path: "{{ git_home }}/.ssh/authorized_keys"
state: touch
mode: 0600
when: not git_authfile.stat.exists
tags: git

View File

@@ -0,0 +1,18 @@
[Unit]
Description=Start Git Daemon
[Service]
ExecStart=/usr/bin/git daemon --reuseaddr --base-path={{ git_home }} {{ git_home }}
Restart=always
RestartSec=500ms
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=git-daemon
User={{ git_user }}
Group={{ git_user }}
[Install]
WantedBy=multi-user.target