Conversation
497028d to
c645070
Compare
|
I added a README for this role explaining how it is used, and marked it ready for review |
|
I haven't tested this entire thing, but it has been in use with our hotfixing process for over a year now and has been working well. |
c645070 to
565abe6
Compare
|
@evgeni @ehelms this is a basic role that we've been making wide use of in our hotfix building process. I've been using it also in my devel box, and generally anywhere that I need to set up some repositories with multiple remotes and branches and optionally do a basic Do you have some time this week to take a look? |
|
Changes I've force pushed at https://github.com/wbclark/forklift/tree/git_repo_role actually aren't reflected here. I may need to re-open the PR. EDIT: Nevermind, it took several minutes but it did eventually update. |
565abe6 to
2f87781
Compare
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| - name: "Create local repository branch tracking specified remote branch" | |||
| ansible.builtin.command: | |||
There was a problem hiding this comment.
I've tried to use the git_config module for this sort of thing, which was suggested by the maintainers of the git module as that module doesn't support everything that we need to do here, but branch creation was the one area where I could never make git_config work.
Doing it with the command module smells somewhat hacky, but it's not only worked very reliably, it also ends up being quite a bit simpler.
ianballou
left a comment
There was a problem hiding this comment.
This is looking good to me! How I tested:
[ian@manicotto forklift]$ cat playbooks/repositories_test.yml
---
- hosts: all
tasks:
- name: "Setup git repositories"
ansible.builtin.include_role:
name: git_repo
loop: "{{ git_repositories }}"
loop_control:
loop_var: repo
vars:
git_repo_repository: "{{ repo }}"
fedora39:
box_name: 'fedora/39-cloud-base'
pty: true
ansible:
playbook: 'playbooks/repositories_test.yml'
variables:
git_repositories:
- name: 'foreman'
dir: '/home/vagrant'
remotes:
- name: 'origin'
url: 'https://github.com/theforeman/foreman.git'
branches:
- 'develop'
- name: 'katello'
dir: '/home/vagrant'
remotes:
- name: 'origin'
url: 'https://github.com/Katello/katello.git'
branches:
- 'master'
python_packages:
- 'ansible'
- 'obal'
- 'tito'
Only snag I hit was that git wasn't on my box. Should a role be responsible for ensuring certain dependencies are installed? I'm not sure if that's a usual Ansible expectation.
|
(For future reference, I took that playbook from here: wbclark@bb6de0d) |
This role accepts a single complex data structure to clone a git repository with multiple remotes and branches.
Good idea. I've added meta/main.yml with a dependency for the existing git role. |
ianballou
left a comment
There was a problem hiding this comment.
Looks good to me! In the future we can revamp the git role to use the generic package action so that other distros are supported.
evgeni
left a comment
There was a problem hiding this comment.
As said on Matrix: I think it's too complicated, but I don't mind having it if it's useful for y'all
Mergin.
This role uses a single ansible data structure to manage a set of git repositories with potentially multiple remotes and multiple branches per remote.