Filter services dictionary per host
To greatly reduce the amount of log noise from skipped tasks, set a var in the role that filters the 'swift_services' dict to one that only contains services relevant for each host. Change-Id: Ib4e7d398ce2b34e560520d0266dc67bed653cc5c
This commit is contained in:
parent
49c3e0b727
commit
acdbf6bc38
|
@ -22,9 +22,6 @@
|
|||
service:
|
||||
name: "{{ item.value.program_name }}"
|
||||
enabled: "yes"
|
||||
with_dict: "{{ swift_services }}"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- "{{ item.value.service_en | default(true) }}"
|
||||
with_dict: "{{ filtered_swift_services }}"
|
||||
notify:
|
||||
- Restart swift services
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
owner: "{{ swift_system_user_name }}"
|
||||
group: "{{ swift_system_group_name }}"
|
||||
mode: "02755"
|
||||
with_dict: "{{ swift_services }}"
|
||||
when: inventory_hostname in groups[item.value.group]
|
||||
with_dict: "{{ filtered_swift_services }}"
|
||||
|
||||
- name: Create TEMP lock dir
|
||||
file:
|
||||
|
@ -30,8 +29,7 @@
|
|||
owner: "{{ swift_system_user_name }}"
|
||||
group: "{{ swift_system_group_name }}"
|
||||
mode: "02755"
|
||||
with_dict: "{{ swift_services }}"
|
||||
when: inventory_hostname in groups[item.value.group]
|
||||
with_dict: "{{ filtered_swift_services }}"
|
||||
|
||||
# TODO(mgariepy):
|
||||
# Remove this in Pike as it only needed to handle upgrades
|
||||
|
@ -40,8 +38,7 @@
|
|||
file:
|
||||
path: "/etc/tmpfiles.d/{{ item.value.program_name }}.conf"
|
||||
state: absent
|
||||
with_dict: "{{ swift_services }}"
|
||||
when: inventory_hostname in groups[item.value.group]
|
||||
with_dict: "{{ filtered_swift_services }}"
|
||||
|
||||
- name: Create tmpfiles.d entry
|
||||
template:
|
||||
|
@ -50,8 +47,7 @@
|
|||
mode: "0644"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
with_dict: "{{ swift_services }}"
|
||||
when: inventory_hostname in groups[item.value.group]
|
||||
with_dict: "{{ filtered_swift_services }}"
|
||||
|
||||
- name: Place the systemd init script
|
||||
config_template:
|
||||
|
@ -62,8 +58,7 @@
|
|||
group: "root"
|
||||
config_overrides: "{{ item.value.init_config_overrides }}"
|
||||
config_type: "ini"
|
||||
with_dict: "{{ swift_services }}"
|
||||
when: inventory_hostname in groups[item.value.group]
|
||||
with_dict: "{{ filtered_swift_services }}"
|
||||
notify:
|
||||
- Reload systemd daemon
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
# Copyright 2017, 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.
|
||||
|
||||
filtered_swift_services: >
|
||||
{%- set services = swift_services.copy() %}
|
||||
{%- for key,value in swift_services.items() %}
|
||||
{%- if value.group not in group_names or
|
||||
(not value.service_en | default(True) | bool) %}
|
||||
{%- set _ = services.pop(key) %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{{- services -}}
|
Loading…
Reference in New Issue