From c6b7f7e9a2bd9227a6ee1687bd373fbc07f31868 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Aug 13 2020 08:52:25 +0000 Subject: Improve README.fedora --- diff --git a/0001-Replace-deprecated-Thread.isAlive-with-Thread.is_ali.patch b/0001-Replace-deprecated-Thread.isAlive-with-Thread.is_ali.patch new file mode 100644 index 0000000..da2689e --- /dev/null +++ b/0001-Replace-deprecated-Thread.isAlive-with-Thread.is_ali.patch @@ -0,0 +1,54 @@ +From b27dc5df5dc1617fc2f1d438611b87b3e63383c4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Mon, 1 Jun 2020 12:49:07 +0200 +Subject: [PATCH] Replace deprecated Thread.isAlive() with Thread.is_alive() + +The isAlive() method of threading.Thread has been removed in Python 3.9. +The is_alive() method is available on Python 2.6+. + +See https://bugs.python.org/issue37804 + +Change-Id: I951b1ae331c3101722fe34babf81d6f82d838380 +--- + zuul/ansible/base/library/command.py | 4 ++-- + zuul/lib/log_streamer.py | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/zuul/ansible/base/library/command.py b/zuul/ansible/base/library/command.py +index a3b969d9..0c461b3a 100755 +--- a/zuul/ansible/base/library/command.py ++++ b/zuul/ansible/base/library/command.py +@@ -474,7 +474,7 @@ def zuul_run_command(self, args, zuul_log_id, check_rc=False, close_fds=True, ex + if t: + t.join(10) + with Console(zuul_log_id) as console: +- if t.isAlive(): ++ if t.is_alive(): + console.addLine("[Zuul] standard output/error still open " + "after child exited") + # ZUUL: stdout and stderr are in the console log file +@@ -495,7 +495,7 @@ def zuul_run_command(self, args, zuul_log_id, check_rc=False, close_fds=True, ex + finally: + if t: + with Console(zuul_log_id) as console: +- if t.isAlive(): ++ if t.is_alive(): + console.addLine("[Zuul] standard output/error still open " + "after child exited") + if fail_json_kwargs: +diff --git a/zuul/lib/log_streamer.py b/zuul/lib/log_streamer.py +index 16b72227..9ed124c5 100644 +--- a/zuul/lib/log_streamer.py ++++ b/zuul/lib/log_streamer.py +@@ -181,7 +181,7 @@ class LogStreamer(object): + raise + + def stop(self): +- if self.thd.isAlive(): ++ if self.thd.is_alive(): + self.server.shutdown() + self.server.server_close() + self.thd.join() +-- +2.25.4 + diff --git a/README.fedora b/README.fedora index 4c4dacf..3fb0da4 100644 --- a/README.fedora +++ b/README.fedora @@ -1,79 +1,125 @@ -TODO(fbo) This is still a draft here. Will be improved once we are clear with runtime deps. +# Getting started with Zuul on Fedora -https://zuul-ci.org/docs/zuul/howtos/installation.html +## Upstream documentation -zuul-manage-ansible -------------------- +The upstream documentation is available at that page: https://zuul-ci.org/docs/zuul/index.html -Prepare Ansible Virtualenv for every supported Ansible versions for the executor service. +## Installation -sudo -u zuul bash -c "cd && zuul-manage-ansible -u -r /var/lib/zuul/ansible-bin" +This section describes the installation process of the minimal set of Zuul components to +get a working Zuul deployment. Please refer to the upstream documentation for advanced +setup. -zuul-web --------- +### Zookeeper -systemctl start zuul-web -curl http://localhost:9000/api/tenants +TODO -zuul-webui ----------- +### Install Zuul components -dnf install -y nodejs -curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo -sudo dnf install yarn -cd /usr/share/zuul-ui/ -yarn install -REACT_APP_ZUUL_API='http://zuul-web.example.com' yarn build +To install the packages run: -httpd ------ + $ sudo dnf install zuul-scheduler zuul-executor zuul-web zuul-webui -dnf install httpd -setsebool -P httpd_can_network_connect on -Add in /etc/httpd/conf.d/zuul.conf -RewriteEngine on -RewriteRule ^/api/tenant/(.*)/console-stream ws://localhost:9000/api/tenant/$1/console-stream [P] -RewriteRule ^/(.*)$ http://localhost:9000/$1 [P] +### Install and setup postgresql + $ sudo dnf install -y posgresql python3-psycopg2 + $ su - postgres + $ psql + ALTER USER postgres WITH PASSWORD 'mypassword'; + $ createdb --owner=postgres zuul + $ exit -zuul-scheduler --------------- +Update the local access setting: -Add in /etc/zuul/main.yaml: -- tenant: - name: demo-tenant - source: - local_git: - config-projects: - - zuul-config + $ sudo sed -i /var/lib/pgsql/data/pg_hba.conf 's/127.0.0.1/32 ident/127.0.0.1/32 md5/' + $ sudo systemctl restart posgreql -Install zookeeper with nodepool tests.yml -Comment MQTT section from zuul.conf -Comment Gerrit section -Comment the MySQL section +Validate server connection by running: -systemctl start zuul-scheduler + $ psql -h 127.0.0.1 -U postgres -W zuul -zuul-executor -------------- +### Update the zuul configuration to define the sql connection -systemctl start zuul-executor +In /etc/zuul/zuul.conf add the following: + [connection sqlreporter] + driver=sql + dburi=postgresql://postgres:mypassword@127.0.0.1:5432/zuul -prepare basic config --------------------- +### Setup Ansible virtual environment for the Zuul executor -In zuul.conf add: -[connection local_git] -driver=git -baseurl=http://localhost:8000/home/fedora -poll_delay=300 +The Zuul executor is the component in charge of running Zuul Job. A Zuul job is +a set of Ansible playbook. The Zuul executor support multiple version of Ansible. +Zuul provides a tool to manage the Ansible virtual environments. To initialize them +run: + $ sudo -u zuul bash -c "cd && zuul-manage-ansible -u -r /var/lib/zuul/ansible-bin" + +### Build the Zuul web UI + +The Zuul web UI is a React application. The Zuul packaging provide the source code of +the application. The following process describe how to compile the source to get a +production build: + + $ curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo + $ sudo dnf install yarn + $ cd /usr/share/zuul-ui/ + $ yarn install + $ REACT_APP_ZUUL_API='' yarn build + +Replace by the URL where the zuul-web API is listening. + +### Start the scheduler and executor + +To do so run: + + $ sudo -u zuul bash -c "ssh-keygen -t rsa -N '' -f /var/lib/zuul/.ssh/id_rsa" + $ sudo systemctl start zuul-scheduler + $ sudo systemctl start zuul-executor + +The services logs are available into /var/log/zuul/zuul.log. + +### Setup the web API + +Install Apache: + + $ sudo dnf install httpd + $ setsebool -P httpd_can_network_connect on + +Then setup the reverve proxy by adding to /etc/httpd/conf.d/zuul.conf the +following content: + + RewriteEngine on + RewriteRule ^/api/tenant/(.*)/console-stream ws://localhost:9000/api/tenant/$1/console-stream [P] + RewriteRule ^/(.*)$ http://localhost:9000/$1 [P] + +Reload Apache: + + $ sudo systemctl relead httpd + +Finally start the zuul-web process + + $ sudo systemctl start zuul-web + +Validate the direct access to the API by running: + + $ curl http://localhost:9000/api/tenants + +Validate the access to the API via the reverse proxy: + + $ curl http:///api/tenants + +## Run a first Zuul job + +### Prepare a Git repository to host the CI configuration + +We need to prepare a local Git repository to host the pipelines and jobs configuration. +Follow the process below: + + $ git init /home/fedora/zuul-config + +In /home/fedora/zuul-config/.zuul.yaml add the following content: -pip3 install --user dulwich -dulwich web-daemon -l 0.0.0.0 / -git init /home/fedora/zuul-config -vim /home/fedora/zuul-config/.zuul.yaml - pipeline: name: periodic post-review: true @@ -83,15 +129,72 @@ vim /home/fedora/zuul-config/.zuul.yaml trigger: timer: - time: '* * * * *' + success: + sqlreporter: + failure: + sqlreporter: + +- job: + name: my-noop + description: Minimal working job + parent: null + run: my-noop.yaml - project: periodic: jobs: - - noop -git config user.name "John Doe" -git config user.email "john@localhost" -git add .zuul.yaml -git commit -m"Init demo config" - -Dans les logs /var/log/zuul/zuul.log -zuul.ExecutorClient: [e: 3f6a0ad4b46f4a9aa23744e3e6b9eea5] Execute job noop + - my-noop + +Create the /home/fedora/zuul-config/my-noop.yaml and add the following content: + +--- +- hosts: localhost + tasks: + - name: List working directory + command: ls -al {{ ansible_user_dir }} + - name: Sleep 30 seconds + wait_for: + timeout: 30 + +Then commit the configuration by running: + + $ cd /home/fedora/zuul-config/ + $ git config user.name "John Doe" + $ git config user.email "john@localhost" + $ git add -A . + $ git commit -m"Init demo config" + + +### Run a simple Git deamon to serve the config repository + + $ dulwich web-daemon -l 0.0.0.0 / + +### Add the new connection in the Zuul configuration + +In /etc/zuul/zuul.conf add the following: + + [connection local_git] + driver=git + baseurl=http://localhost:8000/home/fedora + poll_delay=300 + +### Setup the Zuul tenant configuration file + +In /etc/zuul/main.yaml add the following: + + - tenant: + name: default + source: + local_git: + config-projects: + - zuul-config + +### Restart the Zuul services + + $ sudo systemctl restart zuul-* + +## Access the web ui + + Access the build page, where you should see the periodic job my-noop runs + + http:///t/default/builds diff --git a/zuul.conf b/zuul.conf index 13a2c38..b7d7d06 100644 --- a/zuul.conf +++ b/zuul.conf @@ -32,8 +32,8 @@ git_dir=/var/lib/zuul/git [executor] default_username=zuul log_config=/etc/zuul/logging.conf -trusted_ro_paths=/opt/zuul-scripts:/var/cache -trusted_rw_paths=/opt/zuul-logs +;trusted_ro_paths=/opt/zuul-scripts:/var/cache +;trusted_rw_paths=/opt/zuul-logs [web] log_config=/etc/zuul/logging.conf diff --git a/zuul.spec b/zuul.spec index 770bf81..500b619 100644 --- a/zuul.spec +++ b/zuul.spec @@ -21,6 +21,7 @@ Source10: main.yaml Patch01: 0001-Remove-another-shebang-and-remove-useless-exec-bits.patch Patch02: 0001-requirements-add-explicit-reference-to-dateutil.patch +Patch03: 0001-Replace-deprecated-Thread.isAlive-with-Thread.is_ali.patch BuildArch: noarch @@ -172,6 +173,7 @@ This component is optional (zero or more of these can be run). %package web Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: nodejs Summary: The Zuul web service %description web @@ -243,6 +245,11 @@ EOF install -m 0644 %{SOURCE7} README.fedora # Fix wrong-file-end-of-line-encoding sed -i 's/\r$//' LICENSE +# Fix 0001-Replace-deprecated-Thread.isAlive-with-Thread.is_ali.patch not fully apply +# due to pypi archive removing the symlinks +cp zuul/ansible/base/library/command.py zuul/ansible/2.7/library/ +cp zuul/ansible/base/library/command.py zuul/ansible/2.8/library/ +cp zuul/ansible/base/library/command.py zuul/ansible/2.9/library/ %build %py3_build @@ -330,7 +337,7 @@ exit 0 %dir %attr(0755,zuul,zuul) %{_sharedstatedir}/zuul %dir %attr(0755,zuul,zuul) %{_sharedstatedir}/zuul/.ssh %dir %attr(0755,zuul,zuul) %{_sharedstatedir}/zuul/ansible -%dir %attr(0755,zuul,zuul) %{_sharedstatedir}/zuul/keys +%dir %attr(0700,zuul,zuul) %{_sharedstatedir}/zuul/keys # Zuul runtime check # Project key directory /var/lib/zuul/keys must be mode 0700; current mode is 755 %dir %attr(0700,zuul,zuul) %{_localstatedir}/log/zuul