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 'nova_services' dict to one that only
contains services relevant for each host.

Change-Id: I17650de0ce516e3ad855e8c4bc41f48cf310b828
This commit is contained in:
Jimmy McCrory 2017-04-17 16:30:41 -07:00
parent e56ad5b188
commit 5e30aa98d9
3 changed files with 16 additions and 24 deletions

View File

@ -22,9 +22,6 @@
name: "{{ item.value.service_name }}"
enabled: "yes"
state: "started"
with_dict: "{{ nova_services }}"
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.condition | default(true) }}"
with_dict: "{{ filtered_nova_services }}"
notify:
- Restart nova services

View File

@ -20,10 +20,7 @@
owner: "{{ nova_system_user_name }}"
group: "{{ nova_system_group_name }}"
mode: "02755"
with_dict: "{{ nova_services }}"
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.condition | default(true) }}"
with_dict: "{{ filtered_nova_services }}"
- name: Create TEMP lock dir
file:
@ -32,10 +29,7 @@
owner: "{{ nova_system_user_name }}"
group: "{{ nova_system_group_name }}"
mode: "02755"
with_dict: "{{ nova_services }}"
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.condition | default(true) }}"
with_dict: "{{ filtered_nova_services }}"
# TODO(mgariepy):
# Remove this in Pike as it only needed to handle upgrades
@ -44,10 +38,7 @@
file:
path: "/etc/tmpfiles.d/{{ item.value.service_name }}.conf"
state: absent
with_dict: "{{ nova_services }}"
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.condition | default(true) }}"
with_dict: "{{ filtered_nova_services }}"
- name: Create tmpfiles.d entry
template:
@ -56,10 +47,7 @@
mode: "0644"
owner: "root"
group: "root"
with_dict: "{{ nova_services }}"
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.condition | default(true) }}"
with_dict: "{{ filtered_nova_services }}"
- name: Place the systemd init script
config_template:
@ -70,9 +58,6 @@
group: "root"
config_overrides: "{{ item.value.init_config_overrides }}"
config_type: "ini"
with_dict: "{{ nova_services }}"
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.condition | default(true) }}"
with_dict: "{{ filtered_nova_services }}"
notify:
- Restart nova services

View File

@ -28,3 +28,13 @@ nova_packages_list:
enabled: "{{ 'nova_compute' in group_names and nova_virt_type == 'powervm' }}"
- packages: "{{ nova_nginx_distro_packages }}"
enabled: "{{ 'nova_api_placement' in group_names }}"
filtered_nova_services: >
{%- set services = nova_services.copy() %}
{%- for key,value in nova_services.items() %}
{%- if value.group not in group_names or
(value.condition is defined and not value.condition) %}
{%- set _ = services.pop(key) %}
{%- endif %}
{%- endfor %}
{{- services -}}