diff --git a/defaults/main.yml b/defaults/main.yml index 558cc23..d041cef 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -134,6 +134,7 @@ magnum_services: magnum-conductor: group: magnum_all service_name: magnum-conductor + execstarts: "{{ magnum_bin }}/magnum-conductor" init_config_overrides: "{{ magnum_conductor_init_config_overrides }}" start_order: 1 magnum-api: @@ -143,11 +144,11 @@ magnum_services: start_order: 2 wsgi_overrides: "{{ magnum_api_uwsgi_ini_overrides }}" wsgi_app: True - log_string: "--logto " wsgi_name: lib/python2.7/site-packages/magnum/api/app.wsgi uwsgi_port: "{{ magnum_bind_port }}" uwsgi_bind_address: "{{ magnum_api_uwsgi_bind_address }}" - program_override: "{{ magnum_bin }}/uwsgi --ini /etc/uwsgi/magnum-api.ini" + execstarts: "{{ magnum_bin }}/uwsgi --ini /etc/uwsgi/magnum-api.ini" + execreloads: "{{ magnum_bin }}/uwsgi --reload /var/run/magnum-api/magnum-api.pid" # uWSGI Settings magnum_api_uwsgi_ini_overrides: {} diff --git a/tasks/magnum_init_systemd.yml b/tasks/magnum_init_systemd.yml deleted file mode 100644 index 49e64d6..0000000 --- a/tasks/magnum_init_systemd.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -# Copyright 2016, Rackspace US, 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. - -- name: Create TEMP run dir - file: - path: "/var/run/{{ item.service_name }}" - state: directory - owner: "{{ magnum_system_user_name }}" - group: "{{ magnum_system_group_name }}" - mode: "02755" - with_items: "{{ filtered_magnum_services }}" - -- name: Create TEMP lock dir - file: - path: "/var/lock/{{ item.service_name }}" - state: directory - owner: "{{ magnum_system_user_name }}" - group: "{{ magnum_system_group_name }}" - mode: "02755" - with_items: "{{ filtered_magnum_services }}" - -- name: Create tempfile.d entry - template: - src: "magnum-systemd-tempfiles.j2" - dest: "/etc/tmpfiles.d/openstack-{{ item.service_name }}.conf" - mode: "0644" - owner: "root" - group: "root" - with_items: "{{ filtered_magnum_services }}" - notify: - - Restart magnum services - -- name: Place the systemd init script - config_template: - src: "magnum-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_magnum_services }}" - notify: - - Restart magnum services diff --git a/tasks/main.yml b/tasks/main.yml index 69a5761..9a06832 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -35,7 +35,30 @@ tags: - magnum-config -- include: "magnum_init_{{ ansible_service_mgr }}.yml" +- name: Run the systemd service role + include_role: + name: systemd_service + private: true + vars: + systemd_user_name: "{{ magnum_system_user_name }}" + systemd_group_name: "{{ magnum_system_group_name }}" + systemd_tempd_prefix: openstack + systemd_slice_name: magnum + system_lock_path: /var/lock/magnum + 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_magnum_services }}" + loop_control: + loop_var: service_var tags: - magnum-config diff --git a/templates/magnum-systemd-init.j2 b/templates/magnum-systemd-init.j2 deleted file mode 100644 index 1f3741e..0000000 --- a/templates/magnum-systemd-init.j2 +++ /dev/null @@ -1,35 +0,0 @@ -# {{ ansible_managed }} - -[Unit] -Description=magnum openstack service -After=syslog.target -After=network.target - -[Service] -Type=simple -EnvironmentFile=/etc/environment -User={{ magnum_system_user_name }} -Group={{ magnum_system_group_name }} - -{% if item.program_override is defined %} -ExecStart={{ item.program_override }} {{ item.program_config_options|default('') }} {{ item.log_string | default('--log-file=') }}/var/log/magnum/{{ item.service_name }}.log -{% else %} -ExecStart={{ magnum_bin }}/{{ item.service_name }} {{ item.program_config_options|default('') }} --log-file=/var/log/magnum/{{ item.service_name }}.log -{% 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 magnum services will operate from. -# The accounting options give us the ability to see resource usage through -# the `systemd-cgtop` command. -Slice=magnum.slice -CPUAccounting=true -BlockIOAccounting=true -MemoryAccounting=false -TasksAccounting=true - -[Install] -WantedBy=multi-user.target diff --git a/templates/magnum-systemd-tempfiles.j2 b/templates/magnum-systemd-tempfiles.j2 deleted file mode 100644 index b05064c..0000000 --- a/templates/magnum-systemd-tempfiles.j2 +++ /dev/null @@ -1,4 +0,0 @@ -# {{ ansible_managed }} - -D /var/lock/{{ item.service_name }} 2755 {{ magnum_system_user_name }} {{ magnum_system_group_name }} -D /var/run/{{ item.service_name }} 2755 {{ magnum_system_user_name }} {{ magnum_system_group_name }}