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 exterior role is built to be OSA compatible and may be pulled
into tree should we deem it necessary.

Change-Id: Ie558875fcfbcd92c38d55e2d24087fce90889eaf
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-03-08 20:04:18 -06:00
parent 1ef4471ea5
commit 9eb319c22b
No known key found for this signature in database
GPG Key ID: 9443251A787B9FB3
4 changed files with 30 additions and 82 deletions

View File

@ -249,21 +249,26 @@ glance_services:
start_order: 1
wsgi_overrides: "{{ glance_api_uwsgi_ini_overrides }}"
wsgi_app: "{{ not glance_enable_v1_api }}"
log_string: "{{ glance_enable_v1_api | ternary('--log-file=', '--logto ') }}"
wsgi_name: glance-wsgi-api
uwsgi_bind_address: "{{ glance_api_bind_address }}"
uwsgi_port: "{{ glance_api_service_port }}"
program_override: >-
execstarts: >-
{{ glance_enable_v1_api | ternary(
glance_bin ~ '/glance-api',
glance_bin ~ '/uwsgi --ini /etc/uwsgi/glance-api.ini')
}}
execreloads: >-
{{ glance_enable_v1_api | ternary(
'/bin/kill -HUP $MAINPID',
glance_bin ~ '/uwsgi --reload /var/run/glance-api/glance-api.pid')
}}
glance-registry:
group: glance_registry
service_name: glance-registry
condition: "{{ glance_enable_v1_api | bool or glance_enable_v2_registry | bool }}"
init_config_overrides: "{{ glance_registry_init_overrides }}"
start_order: 2
execstarts: "{{ glance_bin }}/glance-registry"
# Glance uWSGI settings
glance_wsgi_processes_max: 16

View File

@ -211,49 +211,30 @@
option: venv_tag
value: "{{ glance_venv_tag }}"
- name: Create TEMP run dir
file:
path: "/var/run/{{ item.service_name }}"
state: directory
owner: "{{ glance_system_user_name }}"
group: "{{ glance_system_group_name }}"
mode: "02755"
- name: Run the systemd service role
include_role:
name: systemd_service
private: true
vars:
systemd_user_name: "{{ glance_system_user_name }}"
systemd_group_name: "{{ glance_system_group_name }}"
systemd_tempd_prefix: openstack
systemd_slice_name: glance
system_lock_path: /var/lock/glance
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_glance_services }}"
- name: Create TEMP lock dir
file:
path: "/var/lock/{{ item.service_name }}"
state: directory
owner: "{{ glance_system_user_name }}"
group: "{{ glance_system_group_name }}"
mode: "02755"
with_items: "{{ filtered_glance_services }}"
- name: Create tmpfiles.d entry
template:
src: "glance-systemd-tmpfiles.j2"
dest: "/etc/tmpfiles.d/openstack-{{ item.service_name }}.conf"
mode: "0644"
owner: "root"
group: "root"
with_items: "{{ filtered_glance_services }}"
notify:
- Manage LB
- Restart glance services
- name: Place the systemd init script
config_template:
src: "glance-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_glance_services }}"
notify:
- Manage LB
- Restart glance services
loop_control:
loop_var: service_var
- name: Ensure uWSGI directory exists
file:

View File

@ -1,34 +0,0 @@
# {{ ansible_managed }}
[Unit]
Description=glance openstack service
After=syslog.target
After=network.target
[Service]
Type=simple
User={{ glance_system_user_name }}
Group={{ glance_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/glance/{{ item.service_name }}.log
{% else %}
ExecStart={{ glance_bin }}/{{ item.service_name }} {{ item.program_config_options | default('') }} --log-file=/var/log/glance/{{ item.service_name }}.log
{% endif %}
# 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=glance.slice
CPUAccounting=true
BlockIOAccounting=true
MemoryAccounting=false
TasksAccounting=true
[Install]
WantedBy=multi-user.target

View File

@ -1,4 +0,0 @@
# {{ ansible_managed }}
D /var/lock/{{ item.service_name }} 2755 {{ glance_system_user_name }} {{ glance_system_group_name }}
D /var/run/{{ item.service_name }} 2755 {{ glance_system_user_name }} {{ glance_system_group_name }}