Convert role to use a common systemd service role

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.

In converting this role to use the common systemd_service role a
keystone_service dictionary was created in the defaults main.yml file.
This change follows the pattern of other services.

Change-Id: I65902f2483ef2f18ac2d229c5ebd9d090b6ae040
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-03-27 10:32:44 -05:00
parent 98804461bf
commit 34da3d0eaa
6 changed files with 56 additions and 113 deletions

View File

@ -84,7 +84,30 @@
tags:
- neutron-config
- include_tasks: neutron_init_systemd.yml
- name: Run the systemd service role
include_role:
name: systemd_service
private: true
vars:
systemd_user_name: "{{ neutron_system_user_name }}"
systemd_group_name: "{{ neutron_system_group_name }}"
systemd_tempd_prefix: openstack
systemd_slice_name: neutron
system_lock_path: /var/lock/neutron
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_neutron_services }}"
loop_control:
loop_var: service_var
tags:
- neutron-config

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

View File

@ -97,3 +97,19 @@
when:
- ansible_pkg_mgr == 'zypper'
- ovs_nsh_support | bool
- name: Create ovs tempfiles directory
block:
- name: Create ovs tmpfiles file
lineinfile:
dest: "/etc/tmpfiles.d/openstack-openvswitch.conf"
line: "D /var/run/openvswitch 2755 root root"
create: true
- name: Create ovs tmp directory
file:
path: "/var/run/openvswitch"
state: directory
mode: "02755"
when:
- "'ovs' in neutron_plugin_type | lower"

View File

@ -1,34 +0,0 @@
# {{ ansible_managed }}
[Unit]
Description=neutron openstack service
After=syslog.target
After=network.target
[Service]
Type=simple
User={{ item.system_user | default(neutron_system_user_name) }}
Group={{ item.system_group | default(neutron_system_group_name) }}
{% if item.program_override is defined %}
ExecStart={{ item.program_override }} {{ item.config_options | default('') }}
{% else %}
ExecStart={{ neutron_bin }}/{{ item.program_binary | default(item.service_name) }} {{ item.config_options | default('') }}
{% 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=neutron.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.program_binary | default(item.service_name) }} 2755 {{ item.system_user | default(neutron_system_user_name) }} {{ item.system_group | default(neutron_system_group_name) }}
D /var/run/{{ item.program_binary | default(item.service_name) }} 2755 {{ item.system_user | default(neutron_system_user_name) }} {{ item.system_group | default(neutron_system_group_name) }}
D {{ neutron_lock_path }} 2755 {{ item.system_user | default(neutron_system_user_name) }} {{ item.system_group | default(neutron_system_group_name) }}

View File

@ -381,7 +381,7 @@ neutron_services:
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: dhcp_agent.ini
service_rootwrap: rootwrap.d/dhcp.filters
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/dhcp_agent.ini --log-file={{ neutron_log_dir }}/neutron-dhcp-agent.log"
execstarts: "{{ neutron_bin }}/neutron-dhcp-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/dhcp_agent.ini --log-file={{ neutron_log_dir }}/neutron-dhcp-agent.log"
config_overrides: "{{ neutron_dhcp_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_dhcp_agent_init_overrides }}"
@ -393,7 +393,7 @@ neutron_services:
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: plugins/ml2/openvswitch_agent.ini
service_rootwrap: rootwrap.d/openvswitch-plugin.filters
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/plugins/ml2/ml2_conf.ini --config-file {{ neutron_conf_dir }}/plugins/ml2/openvswitch_agent.ini --log-file={{ neutron_log_dir }}/neutron-openvswitch-agent.log"
execstarts: "{{ neutron_bin }}/neutron-openvswitch-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/plugins/ml2/ml2_conf.ini --config-file {{ neutron_conf_dir }}/plugins/ml2/openvswitch_agent.ini --log-file={{ neutron_log_dir }}/neutron-openvswitch-agent.log"
config_overrides: "{{ neutron_openvswitch_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_openvswitch_agent_init_overrides }}"
@ -405,7 +405,7 @@ neutron_services:
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: plugins/ml2/linuxbridge_agent.ini
service_rootwrap: rootwrap.d/linuxbridge-plugin.filters
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/plugins/ml2/ml2_conf.ini --config-file {{ neutron_conf_dir }}/plugins/ml2/linuxbridge_agent.ini --log-file={{ neutron_log_dir }}/neutron-linuxbridge-agent.log"
execstarts: "{{ neutron_bin }}/neutron-linuxbridge-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/plugins/ml2/ml2_conf.ini --config-file {{ neutron_conf_dir }}/plugins/ml2/linuxbridge_agent.ini --log-file={{ neutron_log_dir }}/neutron-linuxbridge-agent.log"
config_overrides: "{{ neutron_linuxbridge_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_linuxbridge_agent_init_overrides }}"
@ -416,7 +416,7 @@ neutron_services:
service_en: "{{ neutron_metadata | bool }}"
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: metadata_agent.ini
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/metadata_agent.ini --log-file={{ neutron_log_dir }}/neutron-metadata-agent.log"
execstarts: "{{ neutron_bin }}/neutron-metadata-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/metadata_agent.ini --log-file={{ neutron_log_dir }}/neutron-metadata-agent.log"
config_overrides: "{{ neutron_metadata_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_metadata_agent_init_overrides }}"
@ -427,7 +427,7 @@ neutron_services:
service_en: "{{ neutron_metering | bool }}"
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: metering_agent.ini
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/metering_agent.ini --log-file={{ neutron_log_dir }}/neutron-metering-agent.log"
execstarts: "{{ neutron_bin }}/neutron-metering-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/metering_agent.ini --log-file={{ neutron_log_dir }}/neutron-metering-agent.log"
config_overrides: "{{ neutron_metering_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_metering_agent_init_overrides }}"
@ -447,7 +447,7 @@ neutron_services:
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: l3_agent.ini
service_rootwrap: rootwrap.d/l3.filters
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/l3_agent.ini --log-file={{ neutron_log_dir }}/neutron-l3-agent.log"
execstarts: "{{ neutron_bin }}/neutron-l3-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/l3_agent.ini --log-file={{ neutron_log_dir }}/neutron-l3-agent.log"
config_overrides: "{{ neutron_l3_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_l3_agent_init_overrides }}"
@ -459,7 +459,7 @@ neutron_services:
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: lbaas_agent.ini
service_rootwrap: rootwrap.d/lbaas-haproxy.filters
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/lbaas_agent.ini --log-file={{ neutron_log_dir }}/neutron-lbaasv2-agent.log"
execstarts: "{{ neutron_bin }}/neutron-lbaasv2-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/lbaas_agent.ini --log-file={{ neutron_log_dir }}/neutron-lbaasv2-agent.log"
config_overrides: "{{ neutron_lbaas_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_lbaas_agent_init_overrides }}"
@ -470,7 +470,7 @@ neutron_services:
service_en: "{{ neutron_bgp | bool }}"
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: bgp_dragent.ini
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/bgp_dragent.ini --log-file={{ neutron_log_dir }}/neutron-bgp-dragent.log"
execstarts: "{{ neutron_bin }}/neutron-bgp-dragent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/bgp_dragent.ini --log-file={{ neutron_log_dir }}/neutron-bgp-dragent.log"
config_overrides: "{{ neutron_bgp_dragent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_bgp_dragent_init_overrides }}"
@ -482,7 +482,7 @@ neutron_services:
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: vpnaas_agent.ini
service_rootwrap: rootwrap.d/vpnaas.filters
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/vpnaas_agent.ini --log-file={{ neutron_log_dir }}/neutron-vpn-agent.log"
execstarts: "{{ neutron_bin }}/neutron-vpn-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/vpnaas_agent.ini --log-file={{ neutron_log_dir }}/neutron-vpn-agent.log"
config_overrides: "{{ neutron_vpnaas_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_vpn_agent_init_overrides }}"
@ -491,19 +491,18 @@ neutron_services:
group: neutron_server
service_name: neutron-server
service_en: True
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/{{ neutron_plugins[neutron_plugin_type].plugin_ini }} --log-file={{ neutron_log_dir }}/neutron-server.log {% if neutron_plugin_type == 'ml2.dragonflow' %}--config-file {{ neutron_conf_dir }}/dragonflow.ini{% endif %}"
execstarts: "{{ neutron_bin }}/neutron-server --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/{{ neutron_plugins[neutron_plugin_type].plugin_ini }} --log-file={{ neutron_log_dir }}/neutron-server.log {% if neutron_plugin_type == 'ml2.dragonflow' %}--config-file {{ neutron_conf_dir }}/dragonflow.ini{% endif %}"
init_config_overrides: "{{ neutron_server_init_overrides }}"
start_order: 1
calico-felix:
group: neutron_calico_dhcp_agent
system_user: root
system_group: root
program_override: "{{ calico_felix_bin }}"
service_name: calico-felix
service_en: "{{ neutron_plugin_type == 'ml2.calico' }}"
service_conf_path: /etc/calico
service_conf: felix.cfg
config_options: --config-file /etc/calico/felix.cfg
execstarts: "{{ calico_felix_bin }} --config-file /etc/calico/felix.cfg"
config_overrides: "{{ neutron_calico_felix_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_calico_felix_init_overrides }}"
@ -515,7 +514,7 @@ neutron_services:
service_name: calico-dhcp-agent
service_en: "{{ neutron_plugin_type == 'ml2.calico' }}"
service_rootwrap: rootwrap.d/dhcp.filters
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf"
execstarts: "{{ neutron_bin }}/calico-dhcp-agent --config-file {{ neutron_conf_dir }}/neutron.conf"
config_overrides: "{{ neutron_calico_dhcp_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_calico_dhcp_agent_init_overrides }}"
@ -526,7 +525,7 @@ neutron_services:
service_en: "{{ 'ml2.sriov' in neutron_plugin_types }}"
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: plugins/ml2/sriov_nic_agent.ini
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/plugins/ml2/ml2_conf.ini --config-file {{ neutron_conf_dir }}/plugins/ml2/sriov_nic_agent.ini --log-file={{ neutron_log_dir }}/neutron-sriov-nic-agent.log"
execstarts: "{{ neutron_bin }}/neutron-sriov-nic-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/plugins/ml2/ml2_conf.ini --config-file {{ neutron_conf_dir }}/plugins/ml2/sriov_nic_agent.ini --log-file={{ neutron_log_dir }}/neutron-sriov-nic-agent.log"
config_overrides: "{{ neutron_sriov_nic_agent_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_sriov_nic_agent_init_overrides }}"
@ -537,7 +536,7 @@ neutron_services:
system_group: root
service_name: df-local-controller
service_en: "{{ neutron_plugin_type == 'ml2.dragonflow' }}"
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/dragonflow.ini --log-file=/var/log/dragonflow/df-local-controller.log"
execstarts: "{{ neutron_bin }}/df-local-controller --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/dragonflow.ini --log-file=/var/log/dragonflow/df-local-controller.log"
config_overrides: "{{ neutron_dragonflow_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_dragonflow_controller_agent_init_overrides }}"
@ -551,7 +550,7 @@ neutron_services:
service_conf_path: "{{ neutron_conf_dir }}"
service_conf: l3_agent.ini
service_rootwrap: rootwrap.d/l3.filters
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/l3_agent.ini --log-file=/var/log/dragonflow/df-l3-agent.log"
execstarts: "{{ neutron_bin }}/df-l3-agent --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/l3_agent.ini --log-file=/var/log/dragonflow/df-l3-agent.log"
config_overrides: "{{ neutron_dragonflow_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_dragonflow_l3_agent_init_overrides }}"
@ -560,7 +559,7 @@ neutron_services:
group: dragonflow_pubsub_agent
service_name: df-publisher-service
service_en: "{{ neutron_plugin_type == 'ml2.dragonflow' }}"
config_options: "--config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/dragonflow.ini --log-file=/var/log/dragonflow/df-publisher-service.log"
execstarts: "{{ neutron_bin }}/df-publisher-service --config-file {{ neutron_conf_dir }}/neutron.conf --config-file {{ neutron_conf_dir }}/dragonflow.ini --log-file=/var/log/dragonflow/df-publisher-service.log"
config_overrides: "{{ neutron_dragonflow_ini_overrides }}"
config_type: "ini"
init_config_overrides: "{{ neutron_dragonflow_pubsub_agent_init_overrides }}"