Skip to content

Instantly share code, notes, and snippets.

@maddymeows
Created June 10, 2024 15:10
Show Gist options
  • Save maddymeows/1e518fcccb94436b77bc3215050b4641 to your computer and use it in GitHub Desktop.
Save maddymeows/1e518fcccb94436b77bc3215050b4641 to your computer and use it in GitHub Desktop.
---
- hosts: all
become: true
tasks:
- name: no firewall
systemd_service:
name: firewalld.service
enabled: false
state: stopped
- name: install git daemon
dnf:
name: git-daemon
state: latest
- name: create git system user
user:
name: git
state: present
system: true
shell: /sbin/nologin
home: /var/lib/git
create_home: true
- name: copy systemd unit
copy:
content: |
[Unit]
Description=Git Daemon
[Service]
ExecStart=/usr/libexec/git-core/git-daemon --base-path=/var/lib/git --reuseaddr --export-all --verbose
Restart=always
User=git
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/git-daemon.service
owner: root
group: root
mode: "0644"
- name: start git daemon service
systemd_service:
daemon_reload: true
name: git-daemon.service
enabled: true
state: started
- name: set git config to trust all dirs
copy:
content: |
[safe]
directory = *
dest: /etc/gitconfig
owner: root
group: root
mode: "0644"
- name: create example.git repo
shell:
creates: /var/lib/git/example.git
cmd: |
set -xe
mkdir /var/lib/git/example.git
cd /var/lib/git/example.git
git init --bare
git config --global init.defaultBranch main
git config --global user.name test
git config --global user.email test@example.com
cd "$(mktemp -d)"
git init
echo test > test
git add test
git commit -m test
git remote add origin /var/lib/git/example.git
git push -u origin main
- name: run clone
shell:
cmd: |
git clone git://localhost/example.git "$(mktemp -d)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment