From 3a9c8632128b911f3c840a38fc7dc7522a046322 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Wed, 7 Mar 2018 12:49:06 -0500 Subject: [PATCH] Add fingergw support In zuulv3 we added the fingergw process, update our role to support that. Change-Id: I2978bb3c53c2f0ed56a6536be110cb471f157ab2 Depends-On: https://review.openstack.org/551015 Signed-off-by: Paul Belanger --- defaults/main.yaml | 20 ++++++ .../etc/systemd/system/zuul-fingergw.service | 13 ++++ handlers/main.yaml | 9 +++ tasks/config.yaml | 12 ++++ tasks/service.yaml | 71 +++++++++++++++++++ .../zuul-fingergw.service.d/centos-7.conf | 3 + .../ubuntu-xenial.conf | 3 + templates/etc/zuul/fingergw-logging.conf | 44 ++++++++++++ templates/etc/zuul/zuul.conf | 5 ++ tests/test.yaml | 37 ++++++++++ vars/redhat.yaml | 8 +++ vars/ubuntu.yaml | 8 +++ 12 files changed, 233 insertions(+) create mode 100644 files/etc/systemd/system/zuul-fingergw.service create mode 100644 templates/etc/systemd/system/zuul-fingergw.service.d/centos-7.conf create mode 100644 templates/etc/systemd/system/zuul-fingergw.service.d/ubuntu-xenial.conf create mode 100644 templates/etc/zuul/fingergw-logging.conf diff --git a/defaults/main.yaml b/defaults/main.yaml index 816815a..8125cd3 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -42,6 +42,12 @@ zuul_file_executor_logging_conf_mode: 0644 zuul_file_executor_logging_conf_owner: "{{ zuul_user_name }}" zuul_file_executor_logging_conf_src: etc/zuul/executor-logging.conf +zuul_file_fingergw_logging_conf_dest: /etc/zuul/fingergw-logging.conf +zuul_file_fingergw_logging_conf_group: "{{ zuul_user_group }}" +zuul_file_fingergw_logging_conf_mode: 0644 +zuul_file_fingergw_logging_conf_owner: "{{ zuul_user_name }}" +zuul_file_fingergw_logging_conf_src: etc/zuul/fingergw-logging.conf + zuul_file_merger_logging_conf_dest: /etc/zuul/merger-logging.conf zuul_file_merger_logging_conf_group: "{{ zuul_user_group }}" zuul_file_merger_logging_conf_mode: 0644 @@ -90,6 +96,14 @@ zuul_file_zuul_executor_service_config_manage: true zuul_file_zuul_executor_service_config_group: root zuul_file_zuul_executor_service_config_owner: root +zuul_file_zuul_fingergw_service_manage: true +zuul_file_zuul_fingergw_service_group: root +zuul_file_zuul_fingergw_service_owner: root + +zuul_file_zuul_fingergw_service_config_manage: true +zuul_file_zuul_fingergw_service_config_group: root +zuul_file_zuul_fingergw_service_config_owner: root + zuul_file_zuul_merger_service_manage: true zuul_file_zuul_merger_service_group: root zuul_file_zuul_merger_service_owner: root @@ -120,6 +134,12 @@ zuul_service_zuul_executor_manage: true zuul_service_zuul_executor_name: zuul-executor.service zuul_service_zuul_executor_state: started +zuul_service_zuul_fingergw_daemon_reload: yes +zuul_service_zuul_fingergw_enabled: yes +zuul_service_zuul_fingergw_manage: true +zuul_service_zuul_fingergw_name: zuul-fingergw.service +zuul_service_zuul_fingergw_state: started + zuul_service_zuul_merger_daemon_reload: yes zuul_service_zuul_merger_enabled: yes zuul_service_zuul_merger_manage: true diff --git a/files/etc/systemd/system/zuul-fingergw.service b/files/etc/systemd/system/zuul-fingergw.service new file mode 100644 index 0000000..989e440 --- /dev/null +++ b/files/etc/systemd/system/zuul-fingergw.service @@ -0,0 +1,13 @@ +[Unit] +Description=Zuul Finger Gateway Service +After=syslog.target network.target + +[Service] +Type=simple +Environment="PREFIX=/usr/local" +Group=root +User=root +ExecStart=/bin/sh -c "${PREFIX}/bin/zuul-fingergw -d" + +[Install] +WantedBy=multi-user.target diff --git a/handlers/main.yaml b/handlers/main.yaml index 78a6782..b9e216c 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -21,6 +21,15 @@ zuul_service_zuul_executor_state == "started" and not zuul_service_zuul_executor.changed +- name: Reload zuul-fingergw + become: yes + service: + name: zuul-fingergw + state: reloaded + when: zuul_service_zuul_fingergw_manage and + zuul_service_zuul_fingergw_state == "started" and not + zuul_service_zuul_fingergw.changed + - name: Reload zuul-merger become: yes service: diff --git a/tasks/config.yaml b/tasks/config.yaml index 0d8e907..8fa76c5 100644 --- a/tasks/config.yaml +++ b/tasks/config.yaml @@ -45,6 +45,17 @@ register: zuul_file_executor_logging_conf notify: Reload zuul-executor +- name: Install fingergw logging file. + become: yes + template: + dest: "{{ zuul_file_fingergw_logging_conf_dest }}" + group: "{{ zuul_file_fingergw_logging_conf_group }}" + mode: "{{ zuul_file_fingergw_logging_conf_mode }}" + owner: "{{ zuul_file_fingergw_logging_conf_owner }}" + src: "{{ zuul_file_fingergw_logging_conf_src }}" + register: zuul_file_fingergw_logging_conf + notify: Reload zuul-fingergw + - name: Install merger logging file. become: yes template: @@ -100,5 +111,6 @@ register: zuul_file_zuul_conf notify: - Reload zuul-executor + - Reload zuul-fingergw - Reload zuul-merger - Reload zuul-scheduler diff --git a/tasks/service.yaml b/tasks/service.yaml index 1c27723..f394f46 100644 --- a/tasks/service.yaml +++ b/tasks/service.yaml @@ -42,6 +42,36 @@ zuul_file_zuul_executor_service_config_src: "{{ __zuul_file_zuul_executor_service_config_src }}" when: zuul_file_zuul_executor_service_config_src is not defined +- name: Define zuul_file_zuul_fingergw_service_dest. + set_fact: + zuul_file_zuul_fingergw_service_dest: "{{ __zuul_file_zuul_fingergw_service_dest }}" + when: zuul_file_zuul_fingergw_service_dest is not defined + +- name: Define zuul_file_zuul_fingergw_service_mode. + set_fact: + zuul_file_zuul_fingergw_service_mode: "{{ __zuul_file_zuul_fingergw_service_mode }}" + when: zuul_file_zuul_fingergw_service_mode is not defined + +- name: Define zuul_file_zuul_fingergw_service_src. + set_fact: + zuul_file_zuul_fingergw_service_src: "{{ __zuul_file_zuul_fingergw_service_src }}" + when: zuul_file_zuul_fingergw_service_src is not defined + +- name: Define zuul_file_zuul_fingergw_service_config_dest. + set_fact: + zuul_file_zuul_fingergw_service_config_dest: "{{ __zuul_file_zuul_fingergw_service_config_dest }}" + when: zuul_file_zuul_fingergw_service_config_dest is not defined + +- name: Define zuul_file_zuul_fingergw_service_config_mode. + set_fact: + zuul_file_zuul_fingergw_service_config_mode: "{{ __zuul_file_zuul_fingergw_service_config_mode }}" + when: zuul_file_zuul_fingergw_service_config_mode is not defined + +- name: Define zuul_file_zuul_fingergw_service_config_src. + set_fact: + zuul_file_zuul_fingergw_service_config_src: "{{ __zuul_file_zuul_fingergw_service_config_src }}" + when: zuul_file_zuul_fingergw_service_config_src is not defined + - name: Define zuul_file_zuul_merger_service_dest. set_fact: zuul_file_zuul_merger_service_dest: "{{ __zuul_file_zuul_merger_service_dest }}" @@ -163,6 +193,37 @@ register: zuul_file_zuul_executor_service_config when: zuul_file_zuul_executor_service_config_manage +- name: Copy zuul-fingergw service into place. + become: yes + copy: + dest: "{{ zuul_file_zuul_fingergw_service_dest }}" + group: "{{ zuul_file_zuul_fingergw_service_group }}" + mode: "{{ zuul_file_zuul_fingergw_service_mode }}" + owner: "{{ zuul_file_zuul_fingergw_service_owner }}" + src: "{{ zuul_file_zuul_fingergw_service_src }}" + register: zuul_file_zuul_fingergw_service + when: zuul_file_zuul_fingergw_service_manage + +- name: Create zuul-fingergw service config directory. + become: yes + file: + group: "{{ zuul_file_zuul_fingergw_service_config_group }}" + owner: "{{ zuul_file_zuul_fingergw_service_config_owner }}" + path: "{{ zuul_file_zuul_fingergw_service_dest }}.d" + state: directory + when: zuul_file_zuul_fingergw_service_config_manage + +- name: Copy zuul-fingergw service config into place. + become: yes + template: + dest: "{{ zuul_file_zuul_fingergw_service_config_dest }}" + group: "{{ zuul_file_zuul_fingergw_service_config_group }}" + mode: "{{ zuul_file_zuul_fingergw_service_config_mode }}" + owner: "{{ zuul_file_zuul_fingergw_service_config_owner }}" + src: "{{ zuul_file_zuul_fingergw_service_config_src }}" + register: zuul_file_zuul_fingergw_service_config + when: zuul_file_zuul_fingergw_service_config_manage + - name: Copy zuul-merger service into place. become: yes copy: @@ -266,6 +327,16 @@ register: zuul_service_zuul_executor when: zuul_service_zuul_executor_manage +- name: Enable zuul-fingergw service. + become: yes + systemd: + daemon_reload: "{{ zuul_service_zuul_fingergw_daemon_reload }}" + enabled: "{{ zuul_service_zuul_fingergw_enabled }}" + name: "{{ zuul_service_zuul_fingergw_name }}" + state: "{{ zuul_service_zuul_fingergw_state }}" + register: zuul_service_zuul_fingergw + when: zuul_service_zuul_fingergw_manage + - name: Enable zuul-merger service. become: yes systemd: diff --git a/templates/etc/systemd/system/zuul-fingergw.service.d/centos-7.conf b/templates/etc/systemd/system/zuul-fingergw.service.d/centos-7.conf new file mode 100644 index 0000000..602ac8e --- /dev/null +++ b/templates/etc/systemd/system/zuul-fingergw.service.d/centos-7.conf @@ -0,0 +1,3 @@ +# This file is generated by Ansible +# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN +# diff --git a/templates/etc/systemd/system/zuul-fingergw.service.d/ubuntu-xenial.conf b/templates/etc/systemd/system/zuul-fingergw.service.d/ubuntu-xenial.conf new file mode 100644 index 0000000..602ac8e --- /dev/null +++ b/templates/etc/systemd/system/zuul-fingergw.service.d/ubuntu-xenial.conf @@ -0,0 +1,3 @@ +# This file is generated by Ansible +# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN +# diff --git a/templates/etc/zuul/fingergw-logging.conf b/templates/etc/zuul/fingergw-logging.conf new file mode 100644 index 0000000..9c0e291 --- /dev/null +++ b/templates/etc/zuul/fingergw-logging.conf @@ -0,0 +1,44 @@ +[loggers] +keys=root,zuul,gear + +[handlers] +keys=console,debug,normal + +[formatters] +keys=simple + +[logger_root] +level=WARNING +handlers=console + +[logger_zuul] +level=DEBUG +handlers=debug,normal +qualname=zuul + +[logger_gear] +level=WARNING +handlers=debug,normal +qualname=gear + +[handler_console] +level=WARNING +class=StreamHandler +formatter=simple +args=(sys.stdout,) + +[handler_debug] +level=DEBUG +class=logging.handlers.WatchedFileHandler +formatter=simple +args=('/var/log/zuul/fingergw-debug.log',) + +[handler_normal] +level=INFO +class=logging.handlers.WatchedFileHandler +formatter=simple +args=('/var/log/zuul/fingergw.log',) + +[formatter_simple] +format=%(asctime)s %(levelname)s %(name)s: %(message)s +datefmt= diff --git a/templates/etc/zuul/zuul.conf b/templates/etc/zuul/zuul.conf index 9a812ba..46dfc47 100644 --- a/templates/etc/zuul/zuul.conf +++ b/templates/etc/zuul/zuul.conf @@ -27,6 +27,11 @@ finger_port = 17979 log_config = /etc/zuul/executor-logging.conf workspace_root = /var/lib/zuul/workspace +[fingergw] +listen_address = 127.0.0.1 +log_config = /etc/zuul/fingergw-logging.conf +user = {{ zuul_user_name }} + [merger] git_dir = /var/lib/zuul/git log_config = /etc/zuul/merger-logging.conf diff --git a/tests/test.yaml b/tests/test.yaml index 9fb1f2a..52fdec2 100644 --- a/tests/test.yaml +++ b/tests/test.yaml @@ -33,6 +33,7 @@ that: - zuul_file_gearman_logging_conf - zuul_file_executor_logging_conf + - zuul_file_fingergw_logging_conf - zuul_file_merger_logging_conf - zuul_file_scheduler_logging_conf - zuul_file_web_logging_conf @@ -40,6 +41,8 @@ - zuul_file_zuul_conf - zuul_file_zuul_executor_service - zuul_file_zuul_executor_service_config + - zuul_file_zuul_fingergw_service + - zuul_file_zuul_fingergw_service_config - zuul_file_zuul_merger_service - zuul_file_zuul_merger_service_config - zuul_file_zuul_scheduler_service @@ -47,6 +50,7 @@ - zuul_file_zuul_web_service - zuul_file_zuul_web_service_config - zuul_service_zuul_executor + - zuul_service_zuul_fingergw - zuul_service_zuul_merger - zuul_service_zuul_scheduler - zuul_service_zuul_web @@ -145,6 +149,20 @@ - zuul_executor_service_config_stat.stat.gr_name == 'root' - zuul_executor_service_config_stat.stat.mode == '0644' + - name: Register /etc/systemd/system/zuul-fingergw.service.d/override.conf + stat: + path: /etc/systemd/system/zuul-fingergw.service.d/override.conf + register: zuul_fingergw_service_config_stat + + - name: Assert zuul_fingergw_service_config_stat tests. + assert: + that: + - zuul_fingergw_service_config_stat.stat.exists + - zuul_fingergw_service_config_stat.stat.isreg + - zuul_fingergw_service_config_stat.stat.pw_name == 'root' + - zuul_fingergw_service_config_stat.stat.gr_name == 'root' + - zuul_fingergw_service_config_stat.stat.mode == '0644' + - name: Register /etc/systemd/system/zuul-merger.service.d/override.conf stat: path: /etc/systemd/system/zuul-merger.service.d/override.conf @@ -201,6 +219,20 @@ - _zuul_executor_service_systemd_stat.stat.gr_name == 'root' - _zuul_executor_service_systemd_stat.stat.mode == '0644' + - name: Register /etc/systemd/system/zuul-fingergw.service + stat: + path: /etc/systemd/system/zuul-fingergw.service + register: _zuul_fingergw_service_systemd_stat + + - name: Assert _zuul_fingergw_service_systemd_stat tests. + assert: + that: + - _zuul_fingergw_service_systemd_stat.stat.exists + - _zuul_fingergw_service_systemd_stat.stat.isreg + - _zuul_fingergw_service_systemd_stat.stat.pw_name == 'root' + - _zuul_fingergw_service_systemd_stat.stat.gr_name == 'root' + - _zuul_fingergw_service_systemd_stat.stat.mode == '0644' + - name: Register /etc/systemd/system/zuul-merger.service stat: path: /etc/systemd/system/zuul-merger.service @@ -248,6 +280,11 @@ shell: /usr/sbin/service zuul-executor status tags: skip_ansible_lint + - name: Ensure zuul-fingergw is running. + become: yes + shell: /usr/sbin/service zuul-fingergw status + tags: skip_ansible_lint + - name: Ensure zuul-merger is running. become: yes shell: /usr/sbin/service zuul-merger status diff --git a/vars/redhat.yaml b/vars/redhat.yaml index 950c0b3..d03a2ff 100644 --- a/vars/redhat.yaml +++ b/vars/redhat.yaml @@ -28,6 +28,14 @@ __zuul_file_zuul_executor_service_config_dest: /etc/systemd/system/zuul-executor __zuul_file_zuul_executor_service_config_mode: 0644 __zuul_file_zuul_executor_service_config_src: etc/systemd/system/zuul-executor.service.d/centos-7.conf +__zuul_file_zuul_fingergw_service_dest: /etc/systemd/system/zuul-fingergw.service +__zuul_file_zuul_fingergw_service_mode: 0644 +__zuul_file_zuul_fingergw_service_src: etc/systemd/system/zuul-fingergw.service + +__zuul_file_zuul_fingergw_service_config_dest: /etc/systemd/system/zuul-fingergw.service.d/override.conf +__zuul_file_zuul_fingergw_service_config_mode: 0644 +__zuul_file_zuul_fingergw_service_config_src: etc/systemd/system/zuul-fingergw.service.d/centos-7.conf + __zuul_file_zuul_merger_service_dest: /etc/systemd/system/zuul-merger.service __zuul_file_zuul_merger_service_mode: 0644 __zuul_file_zuul_merger_service_src: etc/systemd/system/zuul-merger.service diff --git a/vars/ubuntu.yaml b/vars/ubuntu.yaml index c636b4d..c075b46 100644 --- a/vars/ubuntu.yaml +++ b/vars/ubuntu.yaml @@ -27,6 +27,14 @@ __zuul_file_zuul_executor_service_config_dest: /etc/systemd/system/zuul-executor __zuul_file_zuul_executor_service_config_mode: 0644 __zuul_file_zuul_executor_service_config_src: etc/systemd/system/zuul-executor.service.d/ubuntu-xenial.conf +__zuul_file_zuul_fingergw_service_dest: /etc/systemd/system/zuul-fingergw.service +__zuul_file_zuul_fingergw_service_mode: 0644 +__zuul_file_zuul_fingergw_service_src: etc/systemd/system/zuul-fingergw.service + +__zuul_file_zuul_fingergw_service_config_dest: /etc/systemd/system/zuul-fingergw.service.d/override.conf +__zuul_file_zuul_fingergw_service_config_mode: 0644 +__zuul_file_zuul_fingergw_service_config_src: etc/systemd/system/zuul-fingergw.service.d/ubuntu-xenial.conf + __zuul_file_zuul_merger_service_dest: /etc/systemd/system/zuul-merger.service __zuul_file_zuul_merger_service_mode: 0644 __zuul_file_zuul_merger_service_src: etc/systemd/system/zuul-merger.service