Merge "Convert role to use a common systemd service role"
This commit is contained in:
commit
76bb5307b7
@ -47,11 +47,20 @@ congress_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/congress.tgz
|
||||
|
||||
## Common PIP packages
|
||||
congress_pip_packages:
|
||||
- congress
|
||||
- osprofiler
|
||||
- pymysql
|
||||
- python-congressclient
|
||||
- python-heatclient
|
||||
- congress
|
||||
- osprofiler
|
||||
- pymysql
|
||||
- python-congressclient
|
||||
- python-heatclient
|
||||
- systemd-python
|
||||
|
||||
congress_services:
|
||||
congress-server:
|
||||
group: congress_all
|
||||
service_name: congress-server
|
||||
execstarts: "{{ congress_bin }}/congress-server --config-file={{ congress_etc_dir }}/congress.conf"
|
||||
init_config_overrides: "{{ congress_server_init_overrides }}"
|
||||
start_order: 1
|
||||
|
||||
## System info
|
||||
congress_system_user_name: congress
|
||||
@ -59,7 +68,6 @@ congress_system_group_name: congress
|
||||
congress_system_shell: /bin/false
|
||||
congress_system_comment: congress system user
|
||||
congress_system_user_home: "/var/lib/{{ congress_system_user_name }}"
|
||||
congress_config_options: "--config-file={{ congress_etc_dir }}/congress.conf --logfile /var/log/congress/{{ congress_program_name }}.log"
|
||||
|
||||
## Service Type and Data
|
||||
congress_service_region: RegionOne
|
||||
@ -139,3 +147,4 @@ congress_role_project_group: congress_all
|
||||
## Tunable overrides
|
||||
congress_congress_api_paste_ini_overrides: {}
|
||||
congress_congress_conf_overrides: {}
|
||||
congress_server_init_overrides: {}
|
||||
|
@ -16,10 +16,11 @@
|
||||
|
||||
- name: Stop services
|
||||
service:
|
||||
name: "{{ congress_program_name }}"
|
||||
name: "{{ item.service_name }}"
|
||||
enabled: yes
|
||||
state: "started"
|
||||
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
|
||||
with_items: "{{ filtered_congress_services }}"
|
||||
register: _stop
|
||||
until: _stop is success
|
||||
retries: 5
|
||||
@ -28,10 +29,11 @@
|
||||
|
||||
- name: Start services
|
||||
service:
|
||||
name: "{{ congress_program_name }}"
|
||||
name: "{{ item.service_name }}"
|
||||
enabled: yes
|
||||
state: "started"
|
||||
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
|
||||
with_items: "{{ filtered_congress_services }}"
|
||||
register: _start
|
||||
until: _start is success
|
||||
retries: 5
|
||||
@ -47,4 +49,3 @@
|
||||
until: _wait_check is success
|
||||
retries: 5
|
||||
listen: "Restart congress services"
|
||||
|
||||
|
5
releasenotes/notes/journal-log-ccbb504642b49614.yaml
Normal file
5
releasenotes/notes/journal-log-ccbb504642b49614.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
deprecations:
|
||||
- The log path, ``/var/log/congress`` is no longer used to capture service
|
||||
logs. All logging for the congress service will now be sent directly to the
|
||||
systmed journal.
|
@ -1,52 +0,0 @@
|
||||
---
|
||||
# Copyright 2017, taseer94@gmail.com
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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/{{ congress_program_name }}"
|
||||
state: directory
|
||||
owner: "{{ congress_system_user_name }}"
|
||||
group: "{{ congress_system_group_name }}"
|
||||
mode: "02755"
|
||||
|
||||
- name: Create TEMP lock dir
|
||||
file:
|
||||
path: "/var/lock/{{ congress_program_name }}"
|
||||
state: directory
|
||||
owner: "{{ congress_system_user_name }}"
|
||||
group: "{{ congress_system_group_name }}"
|
||||
mode: "02755"
|
||||
|
||||
- name: Create tmpfiles.d entry
|
||||
template:
|
||||
src: "congress-systemd-tmpfiles.j2"
|
||||
dest: "/etc/tmpfiles.d/openstack-{{ congress_program_name }}.conf"
|
||||
mode: "0644"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
notify:
|
||||
- Restart congress services
|
||||
|
||||
- name: Place the systemd init script
|
||||
config_template:
|
||||
src: "congress-systemd-init.j2"
|
||||
dest: "/etc/systemd/system/{{ congress_program_name }}.service"
|
||||
mode: "0644"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
config_type: "ini"
|
||||
notify:
|
||||
- Restart congress services
|
@ -25,6 +25,18 @@
|
||||
retries: 5
|
||||
delay: 2
|
||||
|
||||
- name: Install developer distro packages
|
||||
package:
|
||||
name: "{{ congress_developer_mode_distro_packages }}"
|
||||
state: "{{ congress_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: congress_developer_mode | bool
|
||||
register: install_packages
|
||||
until: install_packages is success
|
||||
retries: 5
|
||||
delay: 2
|
||||
|
||||
- name: Create developer mode constraint file
|
||||
copy:
|
||||
dest: "/opt/developer-pip-constraints.txt"
|
||||
|
@ -46,24 +46,3 @@
|
||||
owner: "{{ congress_system_user_name }}"
|
||||
- path: "/var/cache/congress"
|
||||
- path: "{{ congress_system_user_home }}"
|
||||
|
||||
- name: test for log directory or link
|
||||
shell: |
|
||||
if [ -h "/var/log/congress" ]; then
|
||||
chown -h {{ congress_system_user_name }}:{{ congress_system_group_name }} "/var/log/congress"
|
||||
chown -R {{ congress_system_user_name }}:{{ congress_system_group_name }} "$(readlink /var/log/congress)"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
register: log_dir
|
||||
failed_when: false
|
||||
changed_when: log_dir.rc != 0
|
||||
|
||||
- name: Create congress log dir
|
||||
file:
|
||||
path: "/var/log/congress/"
|
||||
state: directory
|
||||
owner: "{{ congress_system_user_name }}"
|
||||
group: "{{ congress_system_group_name }}"
|
||||
mode: "0755"
|
||||
when: log_dir.rc != 0
|
||||
|
@ -38,9 +38,33 @@
|
||||
tags:
|
||||
- congress-config
|
||||
|
||||
- include: "congress_init_{{ ansible_service_mgr }}.yml"
|
||||
- name: Run the systemd service role
|
||||
include_role:
|
||||
name: systemd_service
|
||||
private: true
|
||||
vars:
|
||||
systemd_user_name: "{{ congress_system_user_name }}"
|
||||
systemd_group_name: "{{ congress_system_group_name }}"
|
||||
systemd_tempd_prefix: openstack
|
||||
systemd_slice_name: congress
|
||||
systemd_lock_path: /var/lock/congress
|
||||
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_congress_services }}"
|
||||
loop_control:
|
||||
loop_var: service_var
|
||||
tags:
|
||||
- congress-config
|
||||
- systemd-service
|
||||
|
||||
- include_tasks: mq_setup.yml
|
||||
when:
|
||||
|
@ -1,31 +0,0 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=congress openstack service
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ congress_system_user_name }}
|
||||
Group={{ congress_system_group_name }}
|
||||
|
||||
ExecStart={{ congress_bin }}/{{ congress_program_name }} {{ congress_config_options }}
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
|
||||
# Give a reasonable amount of time for the server to start up/shut down
|
||||
TimeoutSec=300
|
||||
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=congress.slice
|
||||
CPUAccounting=true
|
||||
BlockIOAccounting=true
|
||||
MemoryAccounting=false
|
||||
TasksAccounting=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,4 +0,0 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
D /var/lock/{{ congress_program_name }} 2755 {{ congress_system_user_name }} {{ congress_system_group_name }}
|
||||
D /var/run/{{ congress_program_name }} 2755 {{ congress_system_user_name }} {{ congress_system_group_name }}
|
@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
[DEFAULT]
|
||||
use_journal = True
|
||||
# Print more verbose output (set logging level to INFO instead of default WARNING level).
|
||||
|
||||
# Print debugging output (set logging level to DEBUG instead of default WARNING level).
|
||||
@ -32,8 +33,6 @@
|
||||
# syslog_log_facility = LOG_USER
|
||||
|
||||
# use_stderr = True
|
||||
log_file = congress-server.log
|
||||
log_dir = /var/log/congress
|
||||
|
||||
# publish_errors = False
|
||||
|
||||
|
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_congress_services: |-
|
||||
{% set services = [] %}
|
||||
{% for key, value in congress_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') }}
|
@ -16,15 +16,21 @@
|
||||
|
||||
congress_distro_packages:
|
||||
- git
|
||||
- gcc
|
||||
- python-dev
|
||||
- python-antlr3
|
||||
- libffi-dev
|
||||
- libssl-dev
|
||||
- libsystemd-dev
|
||||
- libxml2
|
||||
- libxslt1-dev
|
||||
- libzip-dev
|
||||
- build-essential
|
||||
- build-essential
|
||||
- libssl-dev
|
||||
- libffi-dev
|
||||
- python-antlr3
|
||||
- python-dev
|
||||
- python-setuptools
|
||||
- python-mysqldb
|
||||
- python-systemd
|
||||
- python3-systemd
|
||||
- pkg-config
|
||||
|
||||
congress_developer_mode_distro_packages:
|
||||
- build-essential
|
||||
- libsystemd-dev
|
||||
- pkg-config
|
||||
|
Loading…
Reference in New Issue
Block a user