Filter services dictionary per host

To greatly reduce the amount of log noise from skipped tasks, set a
fact upfront in the role that filters the 'neutron_services' dict
to one that only contains services relevant for each host.

Change-Id: I66aadb8f75cbfdfd75dea6d9f96501072cf04d3c
This commit is contained in:
Jimmy McCrory 2017-04-15 23:42:09 -07:00
parent baed87967f
commit 0a0f082e2f
4 changed files with 21 additions and 19 deletions

View File

@ -41,6 +41,19 @@
tags:
- always
- name: Set filtered dictionary of neutron services
set_fact:
filtered_neutron_services: >
{%- set services = neutron_services.copy() %}
{%- for key,value in neutron_services.items() %}
{%- if value.group not in group_names or not value.service_en %}
{%- set _ = services.pop(key) %}
{%- endif %}
{%- endfor %}
{{- services -}}
tags:
- always
- include: neutron_ml2_ovs_powervm.yml
static: no
when:

View File

@ -22,9 +22,6 @@
service:
name: "{{ item.value.service_name }}"
enabled: "yes"
with_dict: "{{ neutron_services }}"
when:
- inventory_hostname in groups[item.value.group] | default([])
- "{{ item.value.service_en | default(true) }}"
with_dict: "{{ filtered_neutron_services }}"
notify:
- Restart neutron services

View File

@ -20,8 +20,7 @@
owner: "{{ neutron_system_user_name }}"
group: "{{ neutron_system_group_name }}"
mode: "02755"
with_dict: "{{ neutron_services }}"
when: inventory_hostname in groups[item.value.group] | default([])
with_dict: "{{ filtered_neutron_services }}"
- name: Create TEMP lock dir
file:
@ -30,8 +29,7 @@
owner: "{{ neutron_system_user_name }}"
group: "{{ neutron_system_group_name }}"
mode: "02755"
with_dict: "{{ neutron_services }}"
when: inventory_hostname in groups[item.value.group] | default([])
with_dict: "{{ filtered_neutron_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.service_name }}.conf"
state: absent
with_dict: "{{ neutron_services }}"
when: inventory_hostname in groups[item.value.group] | default([])
with_dict: "{{ filtered_neutron_services }}"
- name: Create tmpfiles.d entry
template:
@ -50,8 +47,7 @@
mode: "0644"
owner: "root"
group: "root"
with_dict: "{{ neutron_services }}"
when: inventory_hostname in groups[item.value.group] | default([])
with_dict: "{{ filtered_neutron_services }}"
- name: Place the systemd init script
config_template:
@ -62,7 +58,6 @@
group: "root"
config_overrides: "{{ item.value.init_config_overrides }}"
config_type: "ini"
with_dict: "{{ neutron_services }}"
when: inventory_hostname in groups[item.value.group] | default([])
with_dict: "{{ filtered_neutron_services }}"
notify:
- Reload systemd daemon

View File

@ -85,14 +85,12 @@
mode: "0640"
config_overrides: "{{ item.value.config_overrides }}"
config_type: "{{ item.value.config_type }}"
with_dict: "{{ neutron_services }}"
with_dict: "{{ filtered_neutron_services }}"
notify:
- Restart neutron services
when:
- item.value.service_en | bool
- item.value.service_conf_path is defined
- item.value.service_conf is defined
- item.value.group in group_names
- name: Copy neutron rootwrap filters
copy:
@ -111,9 +109,8 @@
dest: "{{ neutron_conf_dir }}/{{ item.value.service_rootwrap }}"
owner: "root"
group: "root"
with_dict: "{{ neutron_services }}"
with_dict: "{{ filtered_neutron_services }}"
when:
- item.value.service_en | bool
- item.value.service_rootwrap is defined
notify:
- Restart neutron services