From b219b905367af4dba9936be9591065e76f86bea5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Tue, 3 Apr 2018 08:34:32 +0000 Subject: [PATCH] Revert "Convert role to use a common systemd service role" This reverts commit 2f78790cc28e135f1912a61d29571ad5d68e9788. This broke master due to a problem with cinder backup which can't reload (probably an issue with its systemd service file) See also [1], [2]. [1]: http://logs.openstack.org/periodic/git.openstack.org/openstack/openstack-ansible/master/openstack-ansible-deploy-ceph-ubuntu-xenial/e950b61/job-output.txt.gz#_2018-04-03_07_17_12_755695 [2]: http://logs.openstack.org/periodic/git.openstack.org/openstack/openstack-ansible/master/openstack-ansible-deploy-aio_lxc-ubuntu-xenial/fe598f2/job-output.txt.gz#_2018-04-03_07_17_29_341574 Change-Id: I930f7280bc668ee275d72be07d8a2c088322f653 --- defaults/main.yml | 9 ++--- tasks/cinder_init_systemd.yml | 59 ++++++++++++++++++++++++++++ tasks/main.yml | 25 +----------- templates/cinder-systemd-init.j2 | 37 +++++++++++++++++ templates/cinder-systemd-tmpfiles.j2 | 5 +++ 5 files changed, 105 insertions(+), 30 deletions(-) create mode 100644 tasks/cinder_init_systemd.yml create mode 100644 templates/cinder-systemd-init.j2 create mode 100644 templates/cinder-systemd-tmpfiles.j2 diff --git a/defaults/main.yml b/defaults/main.yml index fb95d00b..79cd5914 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -283,32 +283,29 @@ cinder_services: service_name: cinder-scheduler init_config_overrides: "{{ cinder_scheduler_init_overrides }}" start_order: 1 - execstarts: "{{ cinder_bin }}/cinder-scheduler" cinder-volume: group: cinder_volume service_name: cinder-volume init_config_overrides: "{{ cinder_volume_init_overrides }}" start_order: 2 - execstarts: "{{ cinder_bin }}/cinder-volume" cinder-backup: group: cinder_backup service_name: cinder-backup condition: "{{ cinder_service_backup_program_enabled | bool }}" init_config_overrides: "{{ cinder_backup_init_overrides }}" start_order: 3 - execstarts: "{{ cinder_bin }}/cinder-backup" cinder-api: group: cinder_api service_name: cinder-api init_config_overrides: "{{ cinder_api_init_overrides }}" - start_order: 4 wsgi_overrides: "{{ cinder_api_uwsgi_ini_overrides }}" wsgi_app: True + log_string: "--logto " wsgi_name: cinder-wsgi uwsgi_port: "{{ cinder_service_port }}" uwsgi_bind_address: "{{ cinder_uwsgi_bind_address }}" - execstarts: "{{ cinder_bin }}/uwsgi --ini /etc/uwsgi/cinder-api.ini" - execreloads: "{{ cinder_bin }}/uwsgi --reload /var/run/cinder-api/cinder-api.pid" + program_override: "{{ cinder_bin }}/uwsgi --ini /etc/uwsgi/cinder-api.ini" + start_order: 4 # Cinder uWSGI settings cinder_wsgi_processes_max: 16 diff --git a/tasks/cinder_init_systemd.yml b/tasks/cinder_init_systemd.yml new file mode 100644 index 00000000..55364b82 --- /dev/null +++ b/tasks/cinder_init_systemd.yml @@ -0,0 +1,59 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# Copyright 2016, IBM Corporation. +# +# 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. + +- name: Create TEMP run dir + file: + path: "/var/run/{{ item.service_name }}" + state: directory + owner: "{{ cinder_system_user_name }}" + group: "{{ cinder_system_group_name }}" + mode: "02755" + with_items: "{{ filtered_cinder_services }}" + +- name: Create TEMP lock dir + file: + path: "/var/lock/{{ item.service_name }}" + state: directory + owner: "{{ cinder_system_user_name }}" + group: "{{ cinder_system_group_name }}" + mode: "02755" + with_items: "{{ filtered_cinder_services }}" + +- name: Create tmpfiles.d entry + template: + src: "cinder-systemd-tmpfiles.j2" + dest: "/etc/tmpfiles.d/openstack-{{ item.service_name }}.conf" + mode: "0644" + owner: "root" + group: "root" + with_items: "{{ filtered_cinder_services }}" + notify: + - Manage LB + - Restart cinder services + +- name: Place the systemd init script + config_template: + src: "cinder-systemd-init.j2" + dest: "/etc/systemd/system/{{ item.service_name }}.service" + mode: "0644" + owner: "root" + group: "root" + config_overrides: "{{ item.init_config_overrides }}" + config_type: "ini" + with_items: "{{ filtered_cinder_services }}" + notify: + - Manage LB + - Restart cinder services diff --git a/tasks/main.yml b/tasks/main.yml index 047d5cb6..d9af9a5f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -72,30 +72,7 @@ tags: - cinder-config -- name: Run the systemd service role - include_role: - name: systemd_service - private: true - vars: - systemd_user_name: "{{ cinder_system_user_name }}" - systemd_group_name: "{{ cinder_system_group_name }}" - systemd_tempd_prefix: openstack - systemd_slice_name: cinder - system_lock_path: /var/lock/cinder - systemd_CPUAccounting: true - systemd_BlockIOAccounting: true - systemd_MemoryAccounting: true - systemd_TasksAccounting: true - systemd_services: - - service_name: "{{ service_var.service_name }}" - enabled: yes - state: started - execstarts: "{{ service_var.execstarts }}" - execreloads: "{{ service_var.execreloads | default([]) }}" - config_overrides: "{{ service_var.init_config_overrides }}" - with_items: "{{ filtered_cinder_services }}" - loop_control: - loop_var: service_var +- include: "cinder_init_{{ ansible_service_mgr }}.yml" tags: - cinder-config diff --git a/templates/cinder-systemd-init.j2 b/templates/cinder-systemd-init.j2 new file mode 100644 index 00000000..15c7d71e --- /dev/null +++ b/templates/cinder-systemd-init.j2 @@ -0,0 +1,37 @@ +# {{ ansible_managed }} + +[Unit] +Description=cinder openstack service +After=syslog.target +After=network.target + +[Service] +Type=simple +User={{ cinder_system_user_name }} +Group={{ cinder_system_group_name }} + +{% if item.program_override is defined %} +ExecStart={{ item.program_override }} {{ item.program_config_options|default('') }} {{ item.log_string | default('--log-file=') }}{{ cinder_log_dir }}/{{ item.service_name }}.log +{% else %} +ExecStart={{ cinder_bin }}/{{ item.service_name }} {{ item.program_config_options|default('') }} --log-file={{ cinder_log_dir }}/{{ item.service_name }}.log +{% endif %} +{% if item.service_name != cinder_services['cinder-api']['service_name'] or item.wsgi_app %} +ExecReload={{ (item.wsgi_app is defined and item.wsgi_app) | ternary(cinder_bin + '/uwsgi --reload /var/run/' + item.service_name + '/' + item.service_name +'.pid','/bin/kill -HUP $MAINPID') }} +{% endif %} + +# Give a reasonable amount of time for the server to start up/shut down +TimeoutSec=120 +Restart=on-failure +RestartSec=2 + +# This creates a specific slice which all services will operate from +# The accounting options give us the ability to see resource usage through +# the `systemd-cgtop` command. +Slice=cinder.slice +CPUAccounting=true +BlockIOAccounting=true +MemoryAccounting=false +TasksAccounting=true + +[Install] +WantedBy=multi-user.target diff --git a/templates/cinder-systemd-tmpfiles.j2 b/templates/cinder-systemd-tmpfiles.j2 new file mode 100644 index 00000000..ce057ba7 --- /dev/null +++ b/templates/cinder-systemd-tmpfiles.j2 @@ -0,0 +1,5 @@ +# {{ ansible_managed }} + +D /var/lock/{{ item.service_name }} 2755 {{ cinder_system_user_name }} {{ cinder_system_group_name }} +D /var/run/{{ item.service_name }} 2755 {{ cinder_system_user_name }} {{ cinder_system_group_name }} +D {{ cinder_lock_path }} 2755 {{ cinder_system_user_name }} {{ cinder_system_group_name }}