From a3d91d4df31c2ed3fcdc3f33a4b1ade1f2b865dd Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 30 Oct 2019 08:37:55 +0900 Subject: [PATCH] Clean up review comments Make image and volume list in compose file templated. Rename the gerrit-podman directory to not be based on tool. Make sure we run the job on changes to the playbooks. Update the job name - it's not just review-dev anymore. Change-Id: I0341fa95caff656a2176cc2026ec0ac8903fb24e --- .zuul.yaml | 7 ++-- playbooks/roles/gerrit/defaults/main.yaml | 11 ++++++ .../files/gerrit-podman/docker-compose.yaml | 17 --------- playbooks/roles/gerrit/tasks/main.yaml | 35 +++++++++++-------- .../gerrit/templates/docker-compose.yaml.j2 | 11 ++++++ 5 files changed, 47 insertions(+), 34 deletions(-) delete mode 100644 playbooks/roles/gerrit/files/gerrit-podman/docker-compose.yaml create mode 100644 playbooks/roles/gerrit/templates/docker-compose.yaml.j2 diff --git a/.zuul.yaml b/.zuul.yaml index 9a97db9468..f57d08fcd5 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1012,7 +1012,7 @@ - testinfra/test_zuul_preview.py - job: - name: system-config-run-review-dev + name: system-config-run-review parent: system-config-run description: | Run the playbook for gerrit (in a container). @@ -1042,6 +1042,7 @@ - ^playbooks/host_vars/review\d+.opendev.org.yaml - playbooks/group_vars/review-dev.yaml - ^playbooks/host_vars/review-dev\d+.opendev.org.yaml + - ^playbooks/service-review.*.yaml - playbooks/zuul/templates/group_vars/review-dev.yaml.j2 - playbooks/zuul/templates/group_vars/review.yaml.j2 - playbooks/roles/gerrit/ @@ -1104,7 +1105,7 @@ soft: true - name: system-config-build-image-haproxy-statsd soft: true - - system-config-run-review-dev + - system-config-run-review - system-config-run-zuul-preview - system-config-run-letsencrypt - system-config-build-image-bazel @@ -1164,7 +1165,7 @@ soft: true - name: system-config-upload-image-haproxy-statsd soft: true - - system-config-run-review-dev + - system-config-run-review - system-config-run-zuul-preview - system-config-run-letsencrypt - system-config-upload-image-bazel diff --git a/playbooks/roles/gerrit/defaults/main.yaml b/playbooks/roles/gerrit/defaults/main.yaml index 2136969cf7..0560ca6f00 100644 --- a/playbooks/roles/gerrit/defaults/main.yaml +++ b/playbooks/roles/gerrit/defaults/main.yaml @@ -3,3 +3,14 @@ gerrit_user_name: gerrit2 gerrit_home_dir: /home/gerrit2 gerrit_site_dir: "{{ gerrit_home_dir }}/review_site" gerrit_run_init: false +gerrit_container_image: docker.io/opendevorg/gerrit:2.13 +gerrit_container_volumes: + - /home/gerrit2/review_site/cache:/var/gerrit/cache + - /home/gerrit2/review_site/etc:/var/gerrit/etc + - /home/gerrit2/review_site/git:/var/gerrit/git + - /home/gerrit2/review_site/tmp:/var/gerrit/tmp + - /home/gerrit2/review_site/hooks:/var/gerrit/hooks + - /home/gerrit2/review_site/index:/var/gerrit/index + - /home/gerrit2/review_site/logs:/var/log/gerrit + - /home/gerrit2/review_site/static:/var/gerrit/static + - /home/gerrit2/.launchpadlib:/var/gerrit/.launchpadlib diff --git a/playbooks/roles/gerrit/files/gerrit-podman/docker-compose.yaml b/playbooks/roles/gerrit/files/gerrit-podman/docker-compose.yaml deleted file mode 100644 index 8faf28bea5..0000000000 --- a/playbooks/roles/gerrit/files/gerrit-podman/docker-compose.yaml +++ /dev/null @@ -1,17 +0,0 @@ -version: '3' - -services: - gerrit: - image: docker.io/opendevorg/gerrit:2.13 - network_mode: host - user: gerrit - volumes: - - /home/gerrit2/review_site/cache:/var/gerrit/cache - - /home/gerrit2/review_site/etc:/var/gerrit/etc - - /home/gerrit2/review_site/git:/var/gerrit/git - - /home/gerrit2/review_site/tmp:/var/gerrit/tmp - - /home/gerrit2/review_site/hooks:/var/gerrit/hooks - - /home/gerrit2/review_site/index:/var/gerrit/index - - /home/gerrit2/review_site/logs:/var/log/gerrit - - /home/gerrit2/review_site/static:/var/gerrit/static - - /home/gerrit2/.launchpadlib:/var/gerrit/.launchpadlib diff --git a/playbooks/roles/gerrit/tasks/main.yaml b/playbooks/roles/gerrit/tasks/main.yaml index 45893076c3..836aaeb876 100644 --- a/playbooks/roles/gerrit/tasks/main.yaml +++ b/playbooks/roles/gerrit/tasks/main.yaml @@ -9,10 +9,22 @@ dest: /opt/project-config force: yes -- name: Synchronize podman-compose directory - synchronize: - src: gerrit-podman/ - dest: /etc/gerrit-podman/ +- name: Ensure /etc/gerrit-compose directory + file: + state: directory + path: /etc/gerrit-compose + mode: 0755 + +- name: Put docker-compose file in place + template: + src: docker-compose.yaml.j2 + dest: /etc/gerrit-compose/docker-compose.yaml + mode: 0644 + +- name: Clean up old directory + file: + state: absent + path: /etc/gerrit-podman - name: Create Gerrit Group group: @@ -180,18 +192,13 @@ when: gerrit_run_init | bool command: > podman run -it --rm --net=host -u gerrit - -v /home/gerrit2/review_site/cache:/var/gerrit/cache - -v /home/gerrit2/review_site/etc:/var/gerrit/etc - -v /home/gerrit2/review_site/git:/var/gerrit/git - -v /home/gerrit2/review_site/tmp:/var/gerrit/tmp - -v /home/gerrit2/review_site/hooks:/var/gerrit/hooks - -v /home/gerrit2/review_site/index:/var/gerrit/index - -v /home/gerrit2/review_site/logs:/var/log/gerrit - -v /home/gerrit2/review_site/static:/var/gerrit/static - docker.io/opendevorg/gerrit:2.13 + {% for volume in gerrit_container_volumes %} + -v {{ volume }} + {% endfor %} + {{ gerrit_container_image }} /usr/local/openjdk-8/bin/java -jar /var/gerrit/bin/gerrit.war init -d /var/gerrit -b --no-auto-start --install-all-plugins - name: Run podman-compose up shell: cmd: podman-compose up -d - chdir: /etc/gerrit-podman/ + chdir: /etc/gerrit-compose/ diff --git a/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 b/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 new file mode 100644 index 0000000000..2f3e32acea --- /dev/null +++ b/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 @@ -0,0 +1,11 @@ +version: '3' + +services: + gerrit: + image: {{ gerrit_container_image }} + network_mode: host + user: gerrit + volumes: +{% for volume in gerrit_container_volumes %} + - {{ volume }} +{% endfor %}