From cc65640ef4646fb14f180f81c03cd522bea8838e Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 25 Oct 2019 12:06:37 +0900 Subject: [PATCH] Add replication config to gerrit ansible We need to configure replication. Change-Id: I1bb61969a5adf37b07e43701d9a867b409a5ccf0 --- playbooks/host_vars/review01.opendev.org.yaml | 72 +++++++++++++++++++ playbooks/roles/gerrit/tasks/main.yaml | 8 +++ .../gerrit/templates/replication.config.j2 | 32 +++++++++ 3 files changed, 112 insertions(+) create mode 100644 playbooks/host_vars/review01.opendev.org.yaml create mode 100644 playbooks/roles/gerrit/templates/replication.config.j2 diff --git a/playbooks/host_vars/review01.opendev.org.yaml b/playbooks/host_vars/review01.opendev.org.yaml new file mode 100644 index 0000000000..c469d29f69 --- /dev/null +++ b/playbooks/host_vars/review01.opendev.org.yaml @@ -0,0 +1,72 @@ +gerrit_replication: + - name: 'github' + url: 'git@github.com:' + authGroup: 'Anonymous Users' + replicationDelay: '1' + replicatePermissions: false + mirror: true + projects: + - '^openstack/(?!ara$|ara-web$|ara-infra$).*' + - 'openstack-dev/*' + - 'openstack-infra/*' + - name: 'gitea01' + url: 'ssh://git@gitea01.opendev.org:222/' + authGroup: 'Anonymous Users' + replicationDelay: '1' + replicatePermissions: false + mirror: true + threads: '4' + - name: 'gitea02' + url: 'ssh://git@gitea02.opendev.org:222/' + authGroup: 'Anonymous Users' + replicationDelay: '1' + replicatePermissions: false + mirror: true + threads: '4' + - name: 'gitea03' + url: 'ssh://git@gitea03.opendev.org:222/' + authGroup: 'Anonymous Users' + replicationDelay: '1' + replicatePermissions: false + mirror: true + threads: '4' + - name: 'gitea04' + url: 'ssh://git@gitea04.opendev.org:222/' + authGroup: 'Anonymous Users' + replicationDelay: '1' + replicatePermissions: false + mirror: true + threads: '4' + - name: 'gitea05' + url: 'ssh://git@gitea05.opendev.org:222/' + authGroup: 'Anonymous Users' + replicationDelay: '1' + replicatePermissions: false + mirror: true + threads: '4' + - name: 'gitea06' + url: 'ssh://git@gitea06.opendev.org:222/' + authGroup: 'Anonymous Users' + replicationDelay: '1' + replicatePermissions: false + mirror: true + threads: '4' + - name: 'gitea07' + url: 'ssh://git@gitea07.opendev.org:222/' + authGroup: 'Anonymous Users' + replicationDelay: '1' + replicatePermissions: false + mirror: true + threads: '4' + - name: 'gitea08' + url: 'ssh://git@gitea08.opendev.org:222/' + authGroup: 'Anonymous Users' + replicationDelay: '1' + replicatePermissions: false + mirror: true + threads: '4' + - name: 'local' + url: 'file:///opt/lib/git/' + replicationDelay: '1' + threads: '4' + mirror: true diff --git a/playbooks/roles/gerrit/tasks/main.yaml b/playbooks/roles/gerrit/tasks/main.yaml index be3c272978..45893076c3 100644 --- a/playbooks/roles/gerrit/tasks/main.yaml +++ b/playbooks/roles/gerrit/tasks/main.yaml @@ -64,6 +64,14 @@ group: "{{ gerrit_user_name }}" mode: 0644 +- name: Write Gerrit replication config + template: + src: replication.config.j2 + dest: "{{ gerrit_site_dir }}/etc/replication.config" + owner: "{{ gerrit_user_name }}" + group: "{{ gerrit_user_name }}" + when: gerrit_replication is defined + - name: Write Gerrit SSH private key copy: content: "{{ gerrit_ssh_rsa_key_contents }}" diff --git a/playbooks/roles/gerrit/templates/replication.config.j2 b/playbooks/roles/gerrit/templates/replication.config.j2 new file mode 100644 index 0000000000..d30a85788b --- /dev/null +++ b/playbooks/roles/gerrit/templates/replication.config.j2 @@ -0,0 +1,32 @@ +# This file is managed by ansible. +# https://opendev.org/opendev/system-config + +[gerrit] +defaultForceUpdate = true +autoReload = false +replicateOnStartup = false + +{% for replication in gerrit_replication %} +[remote "{{ replication.name }}"] + url = {{ replication.url }}${name}.git +{% if 'replicationDelay' in replication %} + replicationDelay = {{ replication.replicationDelay }} +{% endif %} +{% if 'threads' in replication %} + threads = {{ replication.threads }} +{% endif %} +{% if 'authGroup' in replication %} + authGroup = {{ replication.authGroup }} +{% endif %} +{% if 'replicatePermissions' in replication %} + replicatePermissions = {{ replication.replicatePermissions }} +{% endif %} +{% if 'mirror' in replication %} + mirror = {{ replication.mirror }} +{% endif %} +{% if 'projects' in replication %} +{% for project in replication.projects %} + projects = {{ project }} +{% endfor %} +{% endif %} +{% endfor %}