From 3bd180f857bdab8edf1ea0c98934eb817df22f73 Mon Sep 17 00:00:00 2001 From: Eduardo Gonzalez Date: Fri, 16 Sep 2016 18:01:47 +0200 Subject: [PATCH] Only enabled services log files Only enabled services logs should be added to cron container and be inclued in cron.json. This PS adds logic to only copy enabled services cron files. Change-Id: Id6303a4c77a0230599e11be165489ba46dba65e0 Closes-bug: #1623712 --- ansible/roles/common/tasks/config.yml | 51 +++++++++++---------- ansible/roles/common/templates/cron.json.j2 | 46 +++++++++---------- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index f28aced813..426760502e 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -65,29 +65,30 @@ - name: Copying over cron logrotate config files template: - src: "cron-logrotate-{{ item }}.conf.j2" - dest: "{{ node_config_directory }}/cron/logrotate/{{ item }}.conf" + src: "cron-logrotate-{{ item.name }}.conf.j2" + dest: "{{ node_config_directory }}/cron/logrotate/{{ item.name }}.conf" + when: item.enabled | bool with_items: - - "ansible" - - "aodh" - - "barbican" - - "cinder" - - "cloudkitty" - - "glance" - - "global" - - "gnocchi" - - "haproxy" - - "heat" - - "keepalived" - - "keystone" - - "magnum" - - "manila" - - "mariadb" - - "mistral" - - "murano" - - "neutron" - - "nova" - - "rabbitmq" - - "senlin" - - "swift" - - "watcher" + - { name: "ansible", enabled: "yes" } + - { name: "aodh", enabled: "{{ enable_aodh }}" } + - { name: "barbican", enabled: "{{ enable_barbican }}" } + - { name: "cinder", enabled: "{{ enable_cinder }}" } + - { name: "cloudkitty", enabled: "{{ enable_cloudkitty }}" } + - { name: "glance", enabled: "{{ enable_glance }}" } + - { name: "global", enabled: "yes" } + - { name: "gnocchi", enabled: "{{ enable_gnocchi }}" } + - { name: "haproxy", enabled: "{{ enable_haproxy }}" } + - { name: "heat", enabled: "{{ enable_heat }}" } + - { name: "keepalived", enabled: "{{ enable_haproxy }}" } + - { name: "keystone", enabled: "{{ enable_keystone }}" } + - { name: "magnum", enabled: "{{ enable_magnum }}" } + - { name: "manila", enabled: "{{ enable_manila }}" } + - { name: "mariadb", enabled: "{{ enable_mariadb }}" } + - { name: "mistral", enabled: "{{ enable_mistral }}" } + - { name: "murano", enabled: "{{ enable_murano }}" } + - { name: "neutron", enabled: "{{ enable_neutron }}" } + - { name: "nova", enabled: "{{ enable_nova }}" } + - { name: "rabbitmq", enabled: "{{ enable_rabbitmq }}" } + - { name: "senlin", enabled: "{{ enable_senlin }}" } + - { name: "swift", enabled: "{{ enable_swift }}" } + - { name: "watcher", enabled: "{{ enable_watcher }}" } diff --git a/ansible/roles/common/templates/cron.json.j2 b/ansible/roles/common/templates/cron.json.j2 index 26b8a47ebc..85d0a1a4ff 100644 --- a/ansible/roles/common/templates/cron.json.j2 +++ b/ansible/roles/common/templates/cron.json.j2 @@ -1,26 +1,26 @@ {% set cron_cmd = 'cron -f' if kolla_base_distro in ['ubuntu', 'debian'] else 'crond -s -n' %} {% set services = [ - "ansible", - "aodh", - "barbican", - "cinder", - "cloudkitty", - "glance", - "gnocchi", - "haproxy", - "heat", - "keepalived", - "keystone", - "magnum", - "manila", - "mariadb", - "mistral", - "murano", - "neutron", - "nova", - "rabbitmq", - "senlin", - "swift" + ( 'ansible', 'yes' ), + ( 'aodh', enable_aodh ), + ( 'barbican', enable_barbican ), + ( 'cinder', enable_cinder ), + ( 'cloudkitty', enable_cloudkitty ), + ( 'glance', enable_glance ), + ( 'gnocchi', enable_gnocchi ), + ( 'haproxy', enable_haproxy ), + ( 'heat', enable_heat ), + ( 'keepalived', enable_haproxy ), + ( 'keystone', enable_keystone ), + ( 'magnum', enable_magnum ), + ( 'manila', enable_manila ), + ( 'mariadb', enable_mariadb ), + ( 'mistral', enable_mistral ), + ( 'murano', enable_murano ), + ( 'neutron', enable_neutron ), + ( 'nova', enable_nova ), + ( 'rabbitmq', enable_rabbitmq ), + ( 'senlin', enable_senlin ), + ( 'swift', enable_swift ) ] %} { "command": "{{ cron_cmd }}", @@ -31,13 +31,13 @@ "owner": "root", "perm": "0644" }, -{% for service in services %} +{% for service, enabled in services if enabled | bool %} { "source": "{{ container_config_directory }}/logrotate/{{ service }}.conf", "dest": "/etc/logrotate.d/{{ service }}.conf", "owner": "root", "perm": "0644" - }{% if not loop.last %},{% endif %} + }{{ ',' if not loop.last else '' }} {% endfor %} ]