From a086fb4333c6ece150150f2c3bffb5b2f09bf874 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Fri, 18 Sep 2020 19:50:52 +0000 Subject: [PATCH] ensure-zookeeper: add role to setup zookeeper This role is lifted from https://src.fedoraproject.org/rpms/zuul/blob/master/f/tests/setup_zookeeper.yml Co-Authored-By: Fabien Boucher Change-Id: Iec21d12baddf3de580d1941adade107c7e24fdd9 --- doc/source/system-roles.rst | 1 + roles/ensure-zookeeper/README.rst | 10 ++++++ roles/ensure-zookeeper/defaults/main.yaml | 3 ++ roles/ensure-zookeeper/tasks/main.yaml | 41 +++++++++++++++++++++++ test-playbooks/ensure-zookeeper.yaml | 8 +++++ zuul-tests.d/general-roles-jobs.yaml | 14 ++++++++ 6 files changed, 77 insertions(+) create mode 100644 roles/ensure-zookeeper/README.rst create mode 100644 roles/ensure-zookeeper/defaults/main.yaml create mode 100644 roles/ensure-zookeeper/tasks/main.yaml create mode 100644 test-playbooks/ensure-zookeeper.yaml diff --git a/doc/source/system-roles.rst b/doc/source/system-roles.rst index 2c6c0ceaf..e34828201 100644 --- a/doc/source/system-roles.rst +++ b/doc/source/system-roles.rst @@ -3,6 +3,7 @@ System Roles .. zuul:autorole:: ensure-package-repositories .. zuul:autorole:: ensure-phoronix-test-suite +.. zuul:autorole:: ensure-zookeeper .. zuul:autorole:: phoronix-test-suite .. zuul:autorole:: phoronix-combine-results .. zuul:autorole:: fetch-phoronix-results diff --git a/roles/ensure-zookeeper/README.rst b/roles/ensure-zookeeper/README.rst new file mode 100644 index 000000000..6cb380725 --- /dev/null +++ b/roles/ensure-zookeeper/README.rst @@ -0,0 +1,10 @@ +Ensure zookeeper is running + +Install and start zookeeper using the upsteam release. + +**Role Variables** + +.. zuul:rolevar:: zookeeper_version + :default: latest + + The zookeeper version. diff --git a/roles/ensure-zookeeper/defaults/main.yaml b/roles/ensure-zookeeper/defaults/main.yaml new file mode 100644 index 000000000..f22379d63 --- /dev/null +++ b/roles/ensure-zookeeper/defaults/main.yaml @@ -0,0 +1,3 @@ +zookeeper_version: "latest" +_zookeeper_latest_version: "3.6.1" +_zookeeper_install_version: "{% if zookeeper_version == 'latest' %}{{ _zookeeper_latest_version }}{% else %}{{ zookeeper_version }}{% endif %}" diff --git a/roles/ensure-zookeeper/tasks/main.yaml b/roles/ensure-zookeeper/tasks/main.yaml new file mode 100644 index 000000000..f5f53d229 --- /dev/null +++ b/roles/ensure-zookeeper/tasks/main.yaml @@ -0,0 +1,41 @@ +- name: Install JDK + package: + name: java-latest-openjdk + state: present + become: true + +- name: Create /tmp/zookeeper + file: + path: /tmp/zookeeper + state: directory + become: true + +- name: Get and extract Zookeeper + unarchive: + src: https://archive.apache.org/dist/zookeeper/zookeeper-{{ _zookeeper_install_version }}/apache-zookeeper-{{ _zookeeper_install_version }}-bin.tar.gz + dest: /tmp/zookeeper + remote_src: yes + become: true + +- name: Link install to a known location + file: + src: /tmp/zookeeper/apache-zookeeper-{{ _zookeeper_install_version }}-bin + dest: /opt/zookeeper + state: link + become: true + +- name: Setup Zookeeper config file + copy: + src: /opt/zookeeper/conf/zoo_sample.cfg + dest: /opt/zookeeper/conf/zoo.cfg + remote_src: true + become: true + +- name: Ensure Zookeeper not running + command: pkill -f zookeeper + ignore_errors: true + become: true + +- name: Start Zookeeper + command: /opt/zookeeper/bin/zkServer.sh start + become: true diff --git a/test-playbooks/ensure-zookeeper.yaml b/test-playbooks/ensure-zookeeper.yaml new file mode 100644 index 000000000..cca07ca9c --- /dev/null +++ b/test-playbooks/ensure-zookeeper.yaml @@ -0,0 +1,8 @@ +- hosts: all + tasks: + - name: Include ensure-zookeeper + include_role: + name: ensure-zookeeper + + - name: Test zookeeper is running + command: /opt/zookeeper/bin/zkCli.sh ls / diff --git a/zuul-tests.d/general-roles-jobs.yaml b/zuul-tests.d/general-roles-jobs.yaml index 4c639910c..4500fcdea 100644 --- a/zuul-tests.d/general-roles-jobs.yaml +++ b/zuul-tests.d/general-roles-jobs.yaml @@ -630,6 +630,18 @@ - name: fedora-32 label: fedora-32 +- job: + name: zuul-jobs-test-ensure-zookeeper + description: Test the ensure-zookeeper roles + files: + - roles/ensure-zookeeper/.* + - test-playbooks/ensure-zookeeper.yaml + run: test-playbooks/ensure-zookeeper.yaml + nodeset: + nodes: + - name: fedora-32 + label: fedora-32 + # -* AUTOGENERATED *- # The following project section is autogenerated by # tox -e update-test-platforms @@ -679,6 +691,7 @@ - zuul-jobs-test-upload-artifactory - zuul-jobs-test-upload-git-mirror - zuul-jobs-test-shake-build + - zuul-jobs-test-ensure-zookeeper gate: jobs: &id001 - zuul-jobs-test-add-authorized-keys @@ -718,5 +731,6 @@ - zuul-jobs-test-upload-artifactory - zuul-jobs-test-upload-git-mirror - zuul-jobs-test-shake-build + - zuul-jobs-test-ensure-zookeeper periodic-weekly: jobs: *id001