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. The systemd journal would normally be populated with the standard out of a service however with the use of uwsgi this is not actually happening resulting in us only capturing the logs from the uwsgi process instead of the service itself. This change implements journal logging in the service config, which is part of OSLO logging. OSLO logging docs found here: <https://docs.openstack.org/oslo.log/3.28.1/journal.html> Change-Id: I9764f557007d97cfcbe02abf7166cce423b39a31 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
41951f83cb
commit
49ea5b4ea9
@ -180,6 +180,7 @@ designate_pip_packages:
|
||||
- python-designateclient
|
||||
- PyMySQL
|
||||
- python-memcached
|
||||
- systemd-python
|
||||
- warlock
|
||||
|
||||
designate_central_init_overrides: {}
|
||||
@ -196,26 +197,43 @@ designate_services:
|
||||
group: designate_central
|
||||
service_name: designate-central
|
||||
init_config_overrides: "{{ designate_central_init_overrides }}"
|
||||
execstarts: "{{ designate_bin }}/designate-central"
|
||||
start_order: 3
|
||||
designate-worker:
|
||||
group: designate_worker
|
||||
service_name: designate-worker
|
||||
init_config_overrides: "{{ designate_worker_init_overrides }}"
|
||||
execstarts: "{{ designate_bin }}/designate-worker"
|
||||
start_order: 2
|
||||
designate-producer:
|
||||
group: designate_producer
|
||||
service_name: designate-producer
|
||||
init_config_overrides: "{{ designate_producer_init_overrides }}"
|
||||
execstarts: "{{ designate_bin }}/designate-producer"
|
||||
start_order: 5
|
||||
designate-mdns:
|
||||
group: designate_mdns
|
||||
service_name: designate-mdns
|
||||
init_config_overrides: "{{ designate_mdns_init_overrides }}"
|
||||
execstarts: "{{ designate_bin }}/designate-mdns"
|
||||
start_order: 4
|
||||
designate-sink:
|
||||
group: designate_sink
|
||||
service_name: designate-sink
|
||||
init_config_overrides: "{{ designate_sink_init_overrides }}"
|
||||
execstarts: "{{ designate_bin }}/designate-sink"
|
||||
start_order: 6
|
||||
designate-api:
|
||||
group: designate_api
|
||||
service_name: designate-api
|
||||
init_config_overrides: "{{ designate_api_init_overrides }}"
|
||||
execstarts: "{{ designate_bin }}/designate-api"
|
||||
start_order: 1
|
||||
|
||||
# List of unit files this role will "mask". These units, when found, are knonw
|
||||
# to conflict with running services for this given role. Any unit listed will be
|
||||
# stopped and masked.
|
||||
designate_mask_conflicting_units: "{{ _designate_mask_conflicting_units | default([]) }}"
|
||||
|
||||
# This variable is used by the repo_build process to determine
|
||||
# which host group to check for members of before building the
|
||||
|
@ -15,13 +15,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
- name: Stop services
|
||||
service:
|
||||
name: "{{ item.value.service_name }}"
|
||||
enabled: yes
|
||||
systemd:
|
||||
name: "{{ item.service_name }}"
|
||||
state: "stopped"
|
||||
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
|
||||
with_dict: "{{ designate_services }}"
|
||||
when: "item.value.group in group_names"
|
||||
with_items: "{{ filtered_designate_services }}"
|
||||
register: _stop
|
||||
until: _stop is success
|
||||
retries: 5
|
||||
@ -47,13 +44,10 @@
|
||||
listen: Restart designate services
|
||||
|
||||
- name: Start services
|
||||
service:
|
||||
name: "{{ item.value.service_name }}"
|
||||
enabled: yes
|
||||
systemd:
|
||||
name: "{{ item.service_name }}"
|
||||
state: "started"
|
||||
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
|
||||
with_dict: "{{ designate_services }}"
|
||||
when: "item.value.group in group_names"
|
||||
with_items: "{{ filtered_designate_services }}"
|
||||
register: _start
|
||||
until: _start is success
|
||||
retries: 5
|
||||
|
5
releasenotes/notes/journal-log-ycba504642b47619.yaml
Normal file
5
releasenotes/notes/journal-log-ycba504642b47619.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
deprecations:
|
||||
- The log path, ``/var/log/designate`` is no longer used to capture service
|
||||
logs. All logging for the designate service will now be sent directly to the
|
||||
systmed journal.
|
@ -1,60 +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.value.service_name }}"
|
||||
state: directory
|
||||
owner: "{{ designate_system_user_name }}"
|
||||
group: "{{ designate_system_group_name }}"
|
||||
mode: "02755"
|
||||
with_dict: "{{ designate_services }}"
|
||||
when: "item.value.group in group_names"
|
||||
|
||||
- name: Create TEMP lock dir
|
||||
file:
|
||||
path: "/var/lock/{{ item.value.service_name }}"
|
||||
state: directory
|
||||
owner: "{{ designate_system_user_name }}"
|
||||
group: "{{ designate_system_group_name }}"
|
||||
mode: "02755"
|
||||
with_dict: "{{ designate_services }}"
|
||||
when: "item.value.group in group_names"
|
||||
|
||||
- name: Create tempfile.d entry
|
||||
template:
|
||||
src: "designate-systemd-tempfiles.j2"
|
||||
dest: "/etc/tmpfiles.d/designate.conf"
|
||||
mode: "0644"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
with_dict: "{{ designate_services }}"
|
||||
when: "item.value.group in group_names"
|
||||
notify:
|
||||
- Restart designate services
|
||||
|
||||
- name: Place the systemd init script
|
||||
config_template:
|
||||
src: "designate-systemd-init.j2"
|
||||
dest: "/etc/systemd/system/{{ item.value.service_name }}.service"
|
||||
mode: "0644"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
config_overrides: "{{ item.value.init_config_overrides }}"
|
||||
config_type: "ini"
|
||||
with_dict: "{{ designate_services }}"
|
||||
when: "item.value.group in group_names"
|
||||
notify:
|
||||
- Restart designate services
|
@ -13,6 +13,18 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Install designate distro packages
|
||||
package:
|
||||
name: "{{ designate_developer_mode_distro_packages }}"
|
||||
state: "{{ designate_package_state }}"
|
||||
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
|
||||
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
|
||||
when: designate_developer_mode | bool
|
||||
register: install_packages
|
||||
until: install_packages|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
|
||||
- name: Create developer mode constraint file
|
||||
copy:
|
||||
dest: "/opt/developer-pip-constraints.txt"
|
||||
|
@ -68,3 +68,12 @@
|
||||
with_fileglob:
|
||||
- rootwrap.d/*
|
||||
notify: Restart designate services
|
||||
|
||||
- name: Mask any conflicting units
|
||||
systemd:
|
||||
name: "{{ item }}"
|
||||
state: stopped
|
||||
enabled: false
|
||||
masked: true
|
||||
failed_when: false
|
||||
with_items: "{{ designate_mask_conflicting_units }}"
|
||||
|
@ -45,27 +45,6 @@
|
||||
- { path: "{{ designate_system_user_home }}/.ssh", mode: "0700" }
|
||||
- { path: "/var/cache/designate", mode: "0700" }
|
||||
|
||||
- name: Test for log directory or link
|
||||
shell: |
|
||||
if [ -h "/var/log/designate" ]; then
|
||||
chown -h {{ designate_system_user_name }}:{{ designate_system_group_name }} "/var/log/designate"
|
||||
chown -R {{ designate_system_user_name }}:{{ designate_system_group_name }} "$(readlink /var/log/designate)"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
register: log_dir
|
||||
failed_when: false
|
||||
changed_when: log_dir.rc != 0
|
||||
|
||||
- name: Create designate log dir
|
||||
file:
|
||||
path: "/var/log/designate"
|
||||
state: directory
|
||||
owner: "{{ designate_system_user_name }}"
|
||||
group: "{{ designate_system_group_name }}"
|
||||
mode: "0755"
|
||||
when: log_dir.rc != 0
|
||||
|
||||
- name: Drop sudoers file
|
||||
template:
|
||||
src: "sudoers.j2"
|
||||
|
@ -52,9 +52,33 @@
|
||||
- designate-install
|
||||
- designate-config
|
||||
|
||||
- include: "designate_init_{{ ansible_service_mgr }}.yml"
|
||||
- name: Run the systemd service role
|
||||
include_role:
|
||||
name: systemd_service
|
||||
private: true
|
||||
vars:
|
||||
systemd_user_name: "{{ designate_system_user_name }}"
|
||||
systemd_group_name: "{{ designate_system_group_name }}"
|
||||
systemd_service_restart_changed: false
|
||||
systemd_tempd_prefix: openstack
|
||||
systemd_slice_name: designate
|
||||
systemd_lock_path: /var/lock/designate
|
||||
systemd_CPUAccounting: true
|
||||
systemd_BlockIOAccounting: true
|
||||
systemd_MemoryAccounting: true
|
||||
systemd_TasksAccounting: true
|
||||
systemd_services:
|
||||
- service_name: "{{ service_var.service_name }}"
|
||||
enabled: yes
|
||||
execstarts: "{{ service_var.execstarts }}"
|
||||
execreloads: "{{ service_var.execreloads | default([]) }}"
|
||||
config_overrides: "{{ service_var.init_config_overrides }}"
|
||||
with_items: "{{ filtered_designate_services }}"
|
||||
loop_control:
|
||||
loop_var: service_var
|
||||
tags:
|
||||
- designate-install
|
||||
- designate-config
|
||||
- systemd-service
|
||||
|
||||
- include_tasks: mq_setup.yml
|
||||
when:
|
||||
|
@ -1,34 +0,0 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=designate openstack service
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ designate_system_user_name }}
|
||||
Group={{ designate_system_group_name }}
|
||||
|
||||
{% if program_override is defined %}
|
||||
ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/designate/{{ item.value.service_name }}.log
|
||||
{% else %}
|
||||
ExecStart={{ designate_bin }}/{{ item.value.service_name }} {{ program_config_options|default('') }} --log-file=/var/log/designate/{{ item.value.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 designate services will operate from
|
||||
# The accounting options give us the ability to see resource usage through
|
||||
# the `systemd-cgtop` command.
|
||||
Slice=designate.slice
|
||||
CPUAccounting=true
|
||||
BlockIOAccounting=true
|
||||
MemoryAccounting=false
|
||||
TasksAccounting=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,4 +0,0 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
D /var/lock/{{ item.value.service_name }} 2755 {{ designate_system_user_name }} {{ designate_system_group_name }}
|
||||
D /var/run/{{ item.value.service_name }} 2755 {{ designate_system_user_name }} {{ designate_system_group_name }}
|
@ -1,4 +1,5 @@
|
||||
[DEFAULT]
|
||||
use_journal = True
|
||||
# Disable stderr logging
|
||||
use_stderr = False
|
||||
|
||||
@ -11,12 +12,6 @@ debug = {{ debug }}
|
||||
# Top-level directory for maintaining designate's state
|
||||
#state_path = /var/lib/designate
|
||||
|
||||
# Log Configuration
|
||||
#log_config = None
|
||||
|
||||
# Log directory
|
||||
#logdir = /var/log/designate
|
||||
|
||||
{% if designate_ceilometer_enabled | bool %}
|
||||
# Driver used for issuing notifications
|
||||
notification_driver = messagingv2
|
||||
|
31
vars/main.yml
Normal file
31
vars/main.yml
Normal file
@ -0,0 +1,31 @@
|
||||
---
|
||||
# Copyright 2018, 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.
|
||||
|
||||
#
|
||||
# Compile a list of the services on a host based on whether
|
||||
# the host is in the host group and the service is enabled.
|
||||
# The service list is provided in the defined start order.
|
||||
#
|
||||
filtered_designate_services: |-
|
||||
{% set services = [] %}
|
||||
{% for key, value in designate_services.items() %}
|
||||
{% if (value['group'] in group_names) and
|
||||
(('condition' not in value) or
|
||||
('condition' in value and value['condition'])) %}
|
||||
{% set _ = value.update({'service_key': key}) %}
|
||||
{% set _ = services.append(value) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ services | sort(attribute='start_order') }}
|
@ -27,6 +27,10 @@ designate_service_distro_packages:
|
||||
- openstack-designate-sink
|
||||
- openstack-designate-worker
|
||||
- openstack-designate-zone-manager
|
||||
- systemd-python
|
||||
|
||||
designate_rndc_packages:
|
||||
- bind
|
||||
|
||||
designate_developer_mode_distro_packages:
|
||||
- systemd-devel
|
||||
|
@ -25,6 +25,11 @@ designate_service_distro_packages:
|
||||
- openstack-designate-producer
|
||||
- openstack-designate-sink
|
||||
- openstack-designate-worker
|
||||
- python-systemd
|
||||
|
||||
designate_rndc_packages:
|
||||
- bind-utils
|
||||
|
||||
designate_developer_mode_distro_packages:
|
||||
- pkg-config
|
||||
- systemd-devel
|
||||
|
@ -29,6 +29,18 @@ designate_service_distro_packages:
|
||||
- designate-sink
|
||||
- designate-worker
|
||||
- designate-zone-manager
|
||||
- python-systemd
|
||||
- python3-systemd
|
||||
|
||||
designate_rndc_packages:
|
||||
- bind9utils
|
||||
|
||||
designate_developer_mode_distro_packages:
|
||||
- build-essential
|
||||
- libsystemd-dev
|
||||
- pkg-config
|
||||
|
||||
_designate_mask_conflicting_units:
|
||||
- designate-agent.service
|
||||
- designate-zone-manager.service
|
||||
- designate-pool-manager.service
|
||||
|
Loading…
x
Reference in New Issue
Block a user