From 27dfd250afc63415383a8e3c7303bf998249fba7 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 10 Apr 2020 11:58:04 -0500 Subject: [PATCH] Set env vars pointing to correct file locations Files are bind-mounted into the container in different locations. Set envvars pointing to the right places. Also - we need to bind-mount the projects.yaml and projects.ini files into the container. While we're at it, move patchset-created to be a regular file. Change-Id: Iacd3e921464b24479db13bbf7ae998b8d8e2103d --- playbooks/roles/gerrit/defaults/main.yaml | 2 ++ playbooks/roles/gerrit/files/hooks/change-abandoned | 5 +++++ playbooks/roles/gerrit/files/hooks/change-merged | 5 +++++ .../hooks/patchset-created} | 10 ++++++++-- playbooks/roles/gerrit/tasks/main.yaml | 8 -------- 5 files changed, 20 insertions(+), 10 deletions(-) rename playbooks/roles/gerrit/{templates/patchset-created.j2 => files/hooks/patchset-created} (63%) diff --git a/playbooks/roles/gerrit/defaults/main.yaml b/playbooks/roles/gerrit/defaults/main.yaml index 3dd08027c3..336ca3debf 100644 --- a/playbooks/roles/gerrit/defaults/main.yaml +++ b/playbooks/roles/gerrit/defaults/main.yaml @@ -17,6 +17,8 @@ gerrit_container_volumes: - /home/gerrit2/review_site/static:/var/gerrit/static - /home/gerrit2/.launchpadlib:/var/gerrit/.launchpadlib - /home/gerrit2/.ssh:/var/gerrit/.ssh + - '{{ gerrit_project_config_base }}/gerrit/projects.yaml:/var/gerrit/etc/projects.yaml' + - '{{ gerrit_project_config_base }}/gerrit/projects.ini:/var/gerrit/etc/projects.ini' gerrit_database_type: MYSQL gerrit_project_config_base: /opt/project-config gerrit_project_creator_user: openstack-project-creator diff --git a/playbooks/roles/gerrit/files/hooks/change-abandoned b/playbooks/roles/gerrit/files/hooks/change-abandoned index 5761951eca..2f98f87f5d 100755 --- a/playbooks/roles/gerrit/files/hooks/change-abandoned +++ b/playbooks/roles/gerrit/files/hooks/change-abandoned @@ -1,4 +1,9 @@ #!/bin/sh +export GERRIT_GIT_DIR=/var/gerrit/git +export GERRIT_CONFIG=/var/gerrit/etc/gerrit.config +export GERRIT_SECURE_CONFIG=/var/gerrit/etc/secure.config +export PROJECTS_YAML=/var/gerrit/etc/projects.yaml +export PROJECTS_INI=/var/gerrit/etc/projects.ini # Use timeout to kill any process running longer than 10 minutes. timeout -k 2m 10m /usr/local/bin/update-bug change-abandoned "$@" diff --git a/playbooks/roles/gerrit/files/hooks/change-merged b/playbooks/roles/gerrit/files/hooks/change-merged index a35424f302..4a85174974 100755 --- a/playbooks/roles/gerrit/files/hooks/change-merged +++ b/playbooks/roles/gerrit/files/hooks/change-merged @@ -1,4 +1,9 @@ #!/bin/sh +export GERRIT_GIT_DIR=/var/gerrit/git +export GERRIT_CONFIG=/var/gerrit/etc/gerrit.config +export GERRIT_SECURE_CONFIG=/var/gerrit/etc/secure.config +export PROJECTS_YAML=/var/gerrit/etc/projects.yaml +export PROJECTS_INI=/var/gerrit/etc/projects.ini # Use timeout to kill any process running longer than 10 minutes. timeout -k 2m 10m /usr/local/bin/update-bug change-merged "$@" diff --git a/playbooks/roles/gerrit/templates/patchset-created.j2 b/playbooks/roles/gerrit/files/hooks/patchset-created similarity index 63% rename from playbooks/roles/gerrit/templates/patchset-created.j2 rename to playbooks/roles/gerrit/files/hooks/patchset-created index 59147b0810..a7b6e29313 100755 --- a/playbooks/roles/gerrit/templates/patchset-created.j2 +++ b/playbooks/roles/gerrit/files/hooks/patchset-created @@ -1,11 +1,17 @@ #!/bin/sh +export GERRIT_GIT_DIR=/var/gerrit/git +export GERRIT_CONFIG=/var/gerrit/etc/gerrit.config +export GERRIT_SECURE_CONFIG=/var/gerrit/etc/secure.config +export PROJECTS_YAML=/var/gerrit/etc/projects.yaml +export PROJECTS_INI=/var/gerrit/etc/projects.ini + # Use timeout to kill any process running longer than 10 minutes. timeout -k 2m 10m /usr/local/bin/update-blueprint patchset-created "$@" timeout -k 2m 10m /usr/local/bin/update-bug patchset-created "$@" timeout -k 2m 10m /usr/local/bin/notify-impact patchset-created "$@" --impact SecurityImpact --dest-address 'openstack-security@lists.openstack.org' -{% if welcome_message_gerrit_ssh_private_key is defined %} +if [ -f /var/gerrit/etc/ssh_welcome_rsa_key ] ; then timeout -k 2m 10m /usr/local/bin/welcome-message patchset-created \ --verbose --ssh-user=welcome-message \ --ssh-key=/var/gerrit/etc/ssh_welcome_rsa_key "$@" -{% endif %} +fi diff --git a/playbooks/roles/gerrit/tasks/main.yaml b/playbooks/roles/gerrit/tasks/main.yaml index a8069b5b93..1959975554 100644 --- a/playbooks/roles/gerrit/tasks/main.yaml +++ b/playbooks/roles/gerrit/tasks/main.yaml @@ -209,14 +209,6 @@ group: "{{ gerrit_user_name }}" mode: 0444 -- name: Install patchset-created hook - template: - src: patchset-created.j2 - dest: "{{ gerrit_site_dir }}/hooks/patchset-created" - owner: "{{ gerrit_user_name }}" - group: "{{ gerrit_user_name }}" - mode: 0555 - # TODO(mordred) These things should really go into the image instead. - name: Copy static and etc copy: