Convert systemd services to common role(s)

This removes the systemd service templates and tasks from this role and
leverages a common systemd service role instead. This change removes a
lot of code duplication across all roles all without sacrificing
features or functionality. The intention of this change is to ensure
uniformity and reduce the maintenance burden on the community when
sweeping changes are needed. The exterior role is built to be OSA
compatible and may be pulled into tree should we deem it necessary.

Change-Id: I404639ae7ebd349d4a11fc5ce1ef3d2805833217
This commit is contained in:
Dmitriy Rabotyagov 2019-07-16 18:14:38 +03:00
parent 1388c2abd0
commit 2f73f21e65
6 changed files with 32 additions and 98 deletions

View File

@ -67,11 +67,12 @@ ironic_services:
wsgi_name: ironic-api-wsgi
uwsgi_port: "{{ ironic_service_port }}"
uwsgi_bind_address: "{{ ironic_uwsgi_bind_address }}"
program_override: "{{ ironic_bin }}/uwsgi --ini /etc/uwsgi/ironic-api.ini"
execstarts: "{{ ironic_bin }}/uwsgi --ini /etc/uwsgi/ironic-api.ini"
ironic-conductor:
group: ironic_conductor
service_name: ironic-conductor
init_config_overrides: "{{ ironic_conductor_init_config_overrides }}"
execstarts: "{{ ironic_bin }}/ironic-conductor"
ironic_service_name: ironic

View File

@ -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: "{{ ironic_system_user_name }}"
group: "{{ ironic_system_group_name }}"
mode: "02755"
with_items: "{{ filtered_ironic_services }}"
- name: Create TEMP lock dir
file:
path: "/var/lock/{{ item.service_name }}"
state: directory
owner: "{{ ironic_system_user_name }}"
group: "{{ ironic_system_group_name }}"
mode: "02755"
with_items: "{{ filtered_ironic_services }}"
- name: Create tmpfiles.d entry
template:
src: "ironic-systemd-tmpfiles.j2"
dest: "/etc/tmpfiles.d/openstack-{{ item.service_name }}.conf"
mode: "0644"
owner: "root"
group: "root"
with_items: "{{ filtered_ironic_services }}"
notify:
- Restart ironic services
- name: Place the systemd init script
config_template:
src: "ironic-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_ironic_services }}"
notify:
- Restart ironic services

View File

@ -97,9 +97,23 @@
tags:
- ironic-config
- include_tasks: "ironic_init_{{ ansible_service_mgr }}.yml"
- name: Run the systemd service role
import_role:
name: systemd_service
vars:
systemd_user_name: "{{ ironic_system_user_name }}"
systemd_group_name: "{{ ironic_system_group_name }}"
systemd_tempd_prefix: openstack
systemd_slice_name: ironic
systemd_lock_path: /var/lock/ironic
systemd_CPUAccounting: true
systemd_BlockIOAccounting: true
systemd_MemoryAccounting: true
systemd_TasksAccounting: true
systemd_services: "{{ filtered_ironic_services }}"
tags:
- ironic-config
- systemd-service
- include_tasks: ironic_service_setup.yml
when: inventory_hostname == groups['ironic_api'][0]

View File

@ -1,34 +0,0 @@
# {{ ansible_managed }}
[Unit]
Description=ironic openstack service
After=syslog.target
After=network.target
[Service]
Type=simple
User={{ ironic_system_user_name }}
Group={{ ironic_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/ironic/{{ item.service_name }}.log
{% else %}
ExecStart={{ ironic_bin }}/{{ item.service_name }} {{ item.program_config_options|default('') }} --log-file=/var/log/ironic/{{ 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 services will operate from
# The accounting options give us the ability to see resource usage through
# the `systemd-cgtop` command.
Slice=ironic.slice
CPUAccounting=true
BlockIOAccounting=true
MemoryAccounting=false
TasksAccounting=true
[Install]
WantedBy=multi-user.target

View File

@ -1,5 +0,0 @@
# {{ ansible_managed }}
D /var/lock/{{ item.service_name }} 2755 {{ ironic_system_user_name }} {{ ironic_system_group_name }}
D /var/run/{{ item.service_name }} 2755 {{ ironic_system_user_name }} {{ ironic_system_group_name }}
D {{ ironic_lock_path }} 2755 {{ ironic_system_user_name }} {{ ironic_system_group_name }}

View File

@ -156,7 +156,21 @@ filtered_ironic_services: |-
{% if (value['group'] in group_names) and
(('service_en' not in value) or
('service_en' in value and value['service_en'])) %}
{% set _ = value.update({'service_key': key}) %}
{% set _ = value.update(
{
'service_key': key,
'enabled': 'yes',
'state': 'started',
'config_overrides': value.init_config_overrides
}
)
%}
{% set _ = value.pop('init_config_overrides') %}
{# Note (noonedeadpunk): The following if statement is added for backwards compatability #}
{# As up to train release ironic role didn't have 'execstarts' in ironic_services keys #}
{% if ('execstarts' not in value) %}
{% set _ = value.update({'execstarts': value.program_override | default(ironic_bin ~ '/' ~ value.service_name)}) %}
{% endif %}
{% set _ = services.append(value) %}
{% endif %}
{% endfor %}