我想问你如何使用 Ansible 实现这种情况。
我的主要目标是 nit git 裸存储库并将其克隆到同一台机器 (/var/www)。 我通常的步骤是:
1) git init —bare (运行在/git/project-name)
2) git clone/git/project-name —no-hardlinks (在/var/www 中运行)
当我愿意使用 Ansible 来做这个案例时,我无法执行第一步——如果是一个空的 git 裸存储库则初始化。
Ansible git 模块要求“repo”参数应填写存储库地址,但如果我只是创建一个,我该如何定义它?
git: repo=?? dest=/git/project-name bare=yes
最佳答案
这是一个示例手册,用于使用新的裸仓库设置 git 服务器:
---
- 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
如果您已经在您的服务器上设置了一个 git
用户,那么您只需要关注 command
任务。享受吧!
关于git - Ansible:如何初始化 git 裸存储库并将其克隆到同一台机器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39204455/