From 8ebb97e3e9903f0875af3f8c441e98ed9258c153 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Thu, 24 Nov 2016 14:49:27 -0500 Subject: [PATCH] Support systemd for centos-7 and ubuntu-xenial Because of a bug in ansible 2.2, it is easier for us to move to systemd for ubuntu-xenial. Change-Id: I0c4709f413b7beb131846b815a9e5c474b3221bb Signed-off-by: Paul Belanger --- ...service => zuul-launcher.service.centos-7} | 0 .../zuul-launcher.service.ubuntu-xenial | 13 ++ ...r.service => zuul-merger.service.centos-7} | 0 .../system/zuul-merger.service.ubuntu-xenial | 14 ++ ...r.service => zuul-server.service.centos-7} | 0 .../system/zuul-server.service.ubuntu-xenial | 14 ++ tasks/main.yaml | 7 +- tests/test.yaml | 126 ++++++++++-------- vars/{RedHat.yaml => centos-7.yaml} | 6 +- vars/{Debian.yaml => ubuntu-trusty.yaml} | 0 vars/ubuntu-xenial.yaml | 42 ++++++ 11 files changed, 164 insertions(+), 58 deletions(-) rename files/etc/systemd/system/{zuul-launcher.service => zuul-launcher.service.centos-7} (100%) create mode 100644 files/etc/systemd/system/zuul-launcher.service.ubuntu-xenial rename files/etc/systemd/system/{zuul-merger.service => zuul-merger.service.centos-7} (100%) create mode 100644 files/etc/systemd/system/zuul-merger.service.ubuntu-xenial rename files/etc/systemd/system/{zuul-server.service => zuul-server.service.centos-7} (100%) create mode 100644 files/etc/systemd/system/zuul-server.service.ubuntu-xenial rename vars/{RedHat.yaml => centos-7.yaml} (96%) rename vars/{Debian.yaml => ubuntu-trusty.yaml} (100%) create mode 100644 vars/ubuntu-xenial.yaml diff --git a/files/etc/systemd/system/zuul-launcher.service b/files/etc/systemd/system/zuul-launcher.service.centos-7 similarity index 100% rename from files/etc/systemd/system/zuul-launcher.service rename to files/etc/systemd/system/zuul-launcher.service.centos-7 diff --git a/files/etc/systemd/system/zuul-launcher.service.ubuntu-xenial b/files/etc/systemd/system/zuul-launcher.service.ubuntu-xenial new file mode 100644 index 0000000..7d1457a --- /dev/null +++ b/files/etc/systemd/system/zuul-launcher.service.ubuntu-xenial @@ -0,0 +1,13 @@ +[Unit] +Description=Zuul Launcher Service +After=syslog.target network.target + +[Service] +Type=simple +User=zuul +Group=zuul +EnvironmentFile=-/etc/default/zuul-launcher +ExecStart=/bin/sh -c "${PREFIX}/bin/zuul-launcher -d" + +[Install] +WantedBy=multi-user.target diff --git a/files/etc/systemd/system/zuul-merger.service b/files/etc/systemd/system/zuul-merger.service.centos-7 similarity index 100% rename from files/etc/systemd/system/zuul-merger.service rename to files/etc/systemd/system/zuul-merger.service.centos-7 diff --git a/files/etc/systemd/system/zuul-merger.service.ubuntu-xenial b/files/etc/systemd/system/zuul-merger.service.ubuntu-xenial new file mode 100644 index 0000000..b88c464 --- /dev/null +++ b/files/etc/systemd/system/zuul-merger.service.ubuntu-xenial @@ -0,0 +1,14 @@ +[Unit] +Description=Zuul Merger Service +After=syslog.target network.target + +[Service] +Type=simple +User=zuul +Group=zuul +LimitNOFILE=8192 +EnvironmentFile=-/etc/default/zuul-merger +ExecStart=/bin/sh -c "${PREFIX}/bin/zuul-merger -d" + +[Install] +WantedBy=multi-user.target diff --git a/files/etc/systemd/system/zuul-server.service b/files/etc/systemd/system/zuul-server.service.centos-7 similarity index 100% rename from files/etc/systemd/system/zuul-server.service rename to files/etc/systemd/system/zuul-server.service.centos-7 diff --git a/files/etc/systemd/system/zuul-server.service.ubuntu-xenial b/files/etc/systemd/system/zuul-server.service.ubuntu-xenial new file mode 100644 index 0000000..9843bf4 --- /dev/null +++ b/files/etc/systemd/system/zuul-server.service.ubuntu-xenial @@ -0,0 +1,14 @@ +[Unit] +Description=Zuul Server Service +After=syslog.target network.target + +[Service] +Type=simple +User=zuul +Group=zuul +EnvironmentFile=-/etc/default/zuul-server +ExecStart=/bin/sh -c "${PREFIX}/bin/zuul-server -d" +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/tasks/main.yaml b/tasks/main.yaml index cf32793..4c22a1d 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -13,7 +13,12 @@ # under the License. --- - name: Include OS-specific variables. - include_vars: "{{ ansible_os_family }}.yaml" + include_vars: "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yaml" + when: ansible_os_family == 'Debian' + +- name: Include OS-specific variables. + include_vars: "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version }}.yaml" + when: ansible_os_family == 'RedHat' - include: "{{ zuul_task }}.yaml" with_items: "{{ zuul_task_manager }}" diff --git a/tests/test.yaml b/tests/test.yaml index 78bf749..b6b9092 100644 --- a/tests/test.yaml +++ b/tests/test.yaml @@ -129,18 +129,22 @@ - name: Register /etc/init.d/zuul-launcher stat: path: /etc/init.d/zuul-launcher - register: debian_zuul_launcher_service_stat - when: ansible_os_family == 'Debian' + register: _zuul_launcher_service_initd_stat + when: + - ansible_distribution == 'Ubuntu' + - ansible_distribution_release == 'trusty' - - name: Assert debian_zuul_launcher_service_stat tests. + - name: Assert _zuul_launcher_service_initd_stat tests. assert: that: - - debian_zuul_launcher_service_stat.stat.exists - - debian_zuul_launcher_service_stat.stat.isreg - - debian_zuul_launcher_service_stat.stat.pw_name == 'root' - - debian_zuul_launcher_service_stat.stat.gr_name == 'root' - - debian_zuul_launcher_service_stat.stat.mode == '0755' - when: ansible_os_family == 'Debian' + - _zuul_launcher_service_initd_stat.stat.exists + - _zuul_launcher_service_initd_stat.stat.isreg + - _zuul_launcher_service_initd_stat.stat.pw_name == 'root' + - _zuul_launcher_service_initd_stat.stat.gr_name == 'root' + - _zuul_launcher_service_initd_stat.stat.mode == '0755' + when: + - ansible_distribution == 'Ubuntu' + - ansible_distribution_release == 'trusty' - name: Register /etc/default/zuul-launcher stat: @@ -161,18 +165,22 @@ - name: Register /etc/init.d/zuul-merger stat: path: /etc/init.d/zuul-merger - register: debian_zuul_merger_service_stat - when: ansible_os_family == 'Debian' + register: _zuul_merger_service_initd_stat + when: + - ansible_distribution == 'Ubuntu' + - ansible_distribution_release == 'trusty' - - name: Assert debian_zuul_merger_service_stat tests. + - name: Assert _zuul_merger_service_initd_stat tests. assert: that: - - debian_zuul_merger_service_stat.stat.exists - - debian_zuul_merger_service_stat.stat.isreg - - debian_zuul_merger_service_stat.stat.pw_name == 'root' - - debian_zuul_merger_service_stat.stat.gr_name == 'root' - - debian_zuul_merger_service_stat.stat.mode == '0755' - when: ansible_os_family == 'Debian' + - _zuul_merger_service_initd_stat.stat.exists + - _zuul_merger_service_initd_stat.stat.isreg + - _zuul_merger_service_initd_stat.stat.pw_name == 'root' + - _zuul_merger_service_initd_stat.stat.gr_name == 'root' + - _zuul_merger_service_initd_stat.stat.mode == '0755' + when: + - ansible_distribution == 'Ubuntu' + - ansible_distribution_release == 'trusty' - name: Register /etc/default/zuul-merger stat: @@ -193,18 +201,22 @@ - name: Register /etc/init.d/zuul-server stat: path: /etc/init.d/zuul-server - register: debian_zuul_server_service_stat - when: ansible_os_family == 'Debian' + register: _zuul_server_service_initd_stat + when: + - ansible_distribution == 'Ubuntu' + - ansible_distribution_release == 'trusty' - - name: Assert debian_zuul_server_service_stat tests. + - name: Assert _zuul_server_service_initd_stat tests. assert: that: - - debian_zuul_server_service_stat.stat.exists - - debian_zuul_server_service_stat.stat.isreg - - debian_zuul_server_service_stat.stat.pw_name == 'root' - - debian_zuul_server_service_stat.stat.gr_name == 'root' - - debian_zuul_server_service_stat.stat.mode == '0755' - when: ansible_os_family == 'Debian' + - _zuul_server_service_initd_stat.stat.exists + - _zuul_server_service_initd_stat.stat.isreg + - _zuul_server_service_initd_stat.stat.pw_name == 'root' + - _zuul_server_service_initd_stat.stat.gr_name == 'root' + - _zuul_server_service_initd_stat.stat.mode == '0755' + when: + - ansible_distribution == 'Ubuntu' + - ansible_distribution_release == 'trusty' - name: Register /etc/default/zuul-server stat: @@ -225,18 +237,20 @@ - name: Register /etc/systemd/system/zuul-launcher.service stat: path: /etc/systemd/system/zuul-launcher.service - register: redhat_zuul_launcher_service_stat - when: ansible_os_family == 'RedHat' + register: _zuul_launcher_service_systemd_stat + when: (ansible_os_family == 'RedHat') or + (ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial') - - name: Assert redhat_zuul_launcher_service_stat tests. + - name: Assert _zuul_launcher_service_systemd_stat tests. assert: that: - - redhat_zuul_launcher_service_stat.stat.exists - - redhat_zuul_launcher_service_stat.stat.isreg - - redhat_zuul_launcher_service_stat.stat.pw_name == 'root' - - redhat_zuul_launcher_service_stat.stat.gr_name == 'root' - - redhat_zuul_launcher_service_stat.stat.mode == '0644' - when: ansible_os_family == 'RedHat' + - _zuul_launcher_service_systemd_stat.stat.exists + - _zuul_launcher_service_systemd_stat.stat.isreg + - _zuul_launcher_service_systemd_stat.stat.pw_name == 'root' + - _zuul_launcher_service_systemd_stat.stat.gr_name == 'root' + - _zuul_launcher_service_systemd_stat.stat.mode == '0644' + when: (ansible_os_family == 'RedHat') or + (ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial') - name: Register /etc/sysconfig/zuul-launcher stat: @@ -257,18 +271,20 @@ - name: Register /etc/systemd/system/zuul-merger.service stat: path: /etc/systemd/system/zuul-merger.service - register: redhat_zuul_merger_service_stat - when: ansible_os_family == 'RedHat' + register: _zuul_merger_service_systemd_stat + when: (ansible_os_family == 'RedHat') or + (ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial') - - name: Assert redhat_zuul_merger_service_stat tests. + - name: Assert _zuul_merger_service_systemd_stat tests. assert: that: - - redhat_zuul_merger_service_stat.stat.exists - - redhat_zuul_merger_service_stat.stat.isreg - - redhat_zuul_merger_service_stat.stat.pw_name == 'root' - - redhat_zuul_merger_service_stat.stat.gr_name == 'root' - - redhat_zuul_merger_service_stat.stat.mode == '0644' - when: ansible_os_family == 'RedHat' + - _zuul_merger_service_systemd_stat.stat.exists + - _zuul_merger_service_systemd_stat.stat.isreg + - _zuul_merger_service_systemd_stat.stat.pw_name == 'root' + - _zuul_merger_service_systemd_stat.stat.gr_name == 'root' + - _zuul_merger_service_systemd_stat.stat.mode == '0644' + when: (ansible_os_family == 'RedHat') or + (ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial') - name: Register /etc/sysconfig/zuul-merger stat: @@ -289,18 +305,20 @@ - name: Register /etc/systemd/system/zuul-server.service stat: path: /etc/systemd/system/zuul-server.service - register: redhat_zuul_server_service_stat - when: ansible_os_family == 'RedHat' + register: _zuul_server_service_systemd_stat + when: (ansible_os_family == 'RedHat') or + (ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial') - - name: Assert redhat_zuul_server_service_stat tests. + - name: Assert _zuul_server_service_systemd_stat tests. assert: that: - - redhat_zuul_server_service_stat.stat.exists - - redhat_zuul_server_service_stat.stat.isreg - - redhat_zuul_server_service_stat.stat.pw_name == 'root' - - redhat_zuul_server_service_stat.stat.gr_name == 'root' - - redhat_zuul_server_service_stat.stat.mode == '0644' - when: ansible_os_family == 'RedHat' + - _zuul_server_service_systemd_stat.stat.exists + - _zuul_server_service_systemd_stat.stat.isreg + - _zuul_server_service_systemd_stat.stat.pw_name == 'root' + - _zuul_server_service_systemd_stat.stat.gr_name == 'root' + - _zuul_server_service_systemd_stat.stat.mode == '0644' + when: (ansible_os_family == 'RedHat') or + (ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial') - name: Register /etc/sysconfig/zuul-server stat: diff --git a/vars/RedHat.yaml b/vars/centos-7.yaml similarity index 96% rename from vars/RedHat.yaml rename to vars/centos-7.yaml index eebe756..d5df2e8 100644 --- a/vars/RedHat.yaml +++ b/vars/centos-7.yaml @@ -20,7 +20,7 @@ __zuul_build_depends: __zuul_file_zuul_launcher_service_dest: /etc/systemd/system/zuul-launcher.service __zuul_file_zuul_launcher_service_mode: 0644 -__zuul_file_zuul_launcher_service_src: etc/systemd/system/zuul-launcher.service +__zuul_file_zuul_launcher_service_src: etc/systemd/system/zuul-launcher.service.centos-7 __zuul_file_zuul_launcher_service_config_dest: /etc/sysconfig/zuul-launcher __zuul_file_zuul_launcher_service_config_mode: 0644 @@ -28,7 +28,7 @@ __zuul_file_zuul_launcher_service_config_src: etc/sysconfig/zuul-launcher __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 +__zuul_file_zuul_merger_service_src: etc/systemd/system/zuul-merger.service.centos-7 __zuul_file_zuul_merger_service_config_dest: /etc/sysconfig/zuul-merger __zuul_file_zuul_merger_service_config_mode: 0644 @@ -36,7 +36,7 @@ __zuul_file_zuul_merger_service_config_src: etc/sysconfig/zuul-merger __zuul_file_zuul_server_service_dest: /etc/systemd/system/zuul-server.service __zuul_file_zuul_server_service_mode: 0644 -__zuul_file_zuul_server_service_src: etc/systemd/system/zuul-server.service +__zuul_file_zuul_server_service_src: etc/systemd/system/zuul-server.service.centos-7 __zuul_file_zuul_server_service_config_dest: /etc/sysconfig/zuul-server __zuul_file_zuul_server_service_config_mode: 0644 diff --git a/vars/Debian.yaml b/vars/ubuntu-trusty.yaml similarity index 100% rename from vars/Debian.yaml rename to vars/ubuntu-trusty.yaml diff --git a/vars/ubuntu-xenial.yaml b/vars/ubuntu-xenial.yaml new file mode 100644 index 0000000..9606db9 --- /dev/null +++ b/vars/ubuntu-xenial.yaml @@ -0,0 +1,42 @@ +# Copyright 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +--- +__zuul_build_depends: + - build-essential + - git + - python-dev + +__zuul_file_zuul_launcher_service_dest: /etc/systemd/system/zuul-launcher.service +__zuul_file_zuul_launcher_service_mode: 0644 +__zuul_file_zuul_launcher_service_src: etc/systemd/system/zuul-launcher.service.ubuntu-xenial + +__zuul_file_zuul_launcher_service_config_dest: /etc/default/zuul-launcher +__zuul_file_zuul_launcher_service_config_mode: 0644 +__zuul_file_zuul_launcher_service_config_src: etc/default/zuul-launcher + +__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.ubuntu-xenial + +__zuul_file_zuul_merger_service_config_dest: /etc/default/zuul-merger +__zuul_file_zuul_merger_service_config_mode: 0644 +__zuul_file_zuul_merger_service_config_src: etc/default/zuul-merger + +__zuul_file_zuul_server_service_dest: /etc/systemd/system/zuul-server.service +__zuul_file_zuul_server_service_mode: 0644 +__zuul_file_zuul_server_service_src: etc/systemd/system/zuul-server.service.ubuntu-xenial + +__zuul_file_zuul_server_service_config_dest: /etc/default/zuul-server +__zuul_file_zuul_server_service_config_mode: 0644 +__zuul_file_zuul_server_service_config_src: etc/default/zuul-server