From 9b999423b75bd0da2756b1fbc31d908407c8f994 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 20 Mar 2020 08:29:02 -0500 Subject: [PATCH] Add an use a utility service for gerrit commands We have a need to run ad-hoc commands with the various things mounted, such as the gerrit init, as well as our friends like manage-projects. Make a second "service" that doesn't do anything, but allows us to run "docker-compose run". Change-Id: Ic9bafe85b90af413c891b969273437be9df6a79f --- playbooks/roles/gerrit/tasks/start.yaml | 14 +++++--------- .../roles/gerrit/templates/docker-compose.yaml.j2 | 11 +++++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/playbooks/roles/gerrit/tasks/start.yaml b/playbooks/roles/gerrit/tasks/start.yaml index 806be27efe..c0bd1ee5f3 100644 --- a/playbooks/roles/gerrit/tasks/start.yaml +++ b/playbooks/roles/gerrit/tasks/start.yaml @@ -1,14 +1,10 @@ -# TODO(mordred) Make this suck less, like if we could do an init container -# or something just generally less gross. - name: Run gerrit init + shell: + cmd: > + docker-compose run shell + java -jar /var/gerrit/bin/gerrit.war init -d /var/gerrit -b --no-auto-start --install-all-plugins + chdir: /etc/gerrit-compose/ when: gerrit_run_init | bool - command: > - docker run --rm --net=host -u gerrit - {% 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 docker-compose up shell: diff --git a/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 b/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 index 8753e6d591..c9d8cb49c5 100644 --- a/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 +++ b/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 @@ -8,4 +8,15 @@ services: volumes: {% for volume in gerrit_container_volumes %} - {{ volume }} +{% endfor %} + # Utility "service" to allow us to run ad-hoc commands + shell: + image: {{ gerrit_container_image }} + restart: 'no' + command: /bin/true + network_mode: host + user: gerrit + volumes: +{% for volume in gerrit_container_volumes %} + - {{ volume }} {% endfor %}