I would like to ask you how it is possible to implement such a case using Ansible.
My main goal is to nit git bare repository and clone it to the same machine (/var/www). My usual steps were:
1) git init —bare (running in /git/project-name)
2) git clone /git/project-name —no-hardlinks (running in в /var/www)
When I am willing to do this case using Ansible, then I cant implement the first step -- initialization if an empty git bare repository.
Ansible git module requires that 'repo' param should be filled with repository address, but how I can define it if I am just creating one?
git: repo=?? dest=/git/project-name bare=yes
Here is a sample playbook for setting up a git server with a new bare repo:
---
- hosts: git.example.org
become: true
tasks:
- user:
name: git
shell: /usr/bin/git-shell
home: /srv/git
- authorized_key:
user: git
state: present
key: https://github.com/myuser.keys
- command: git init --bare /srv/git/myrepo.git
args:
creates: /srv/git/myrepo.git/HEAD
become_user: git
If you've already got a git
user set up on your server, then you only need to focus on the command
task. Enjoy!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With