kolla-ansible/ansible/roles/common/tasks/config.yml
Doug Szumski 58eec5ca12 Forward system logs to Monasca Log API
When Monasca is enabled disable direct logging to ElasticSearch and
send all logs harvested by Fluentd to the Monasca Log API.

This change also cleans up output files which may be left behind when
the various log forwarding options are enabled / disabled.

Partially-Implements: blueprint monasca-roles
Change-Id: I7197966c5117176407d60c86c08d3bcea5e8131a
2018-10-12 08:25:28 +00:00

313 lines
10 KiB
YAML

---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
with_items:
- "kolla-toolbox"
- "cron"
- "cron/logrotate"
- name: Ensuring fluentd config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
recurse: yes
become: true
with_items:
- "fluentd"
- "fluentd/input"
- "fluentd/output"
- "fluentd/format"
- "fluentd/filter"
when: enable_fluentd | bool
- name: Copying over config.json files for services
template:
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
register: common_config_jsons
when: item.value.enabled | bool
with_dict: "{{ common_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Copying over fluentd input config files
template:
src: "conf/input/{{ item }}.conf.j2"
dest: "{{ node_config_directory }}/fluentd/input/{{ item }}.conf"
mode: "0660"
become: true
register: fluentd_input
when: enable_fluentd | bool
with_items:
- "00-global"
- "01-syslog"
- "02-mariadb"
- "03-rabbitmq"
- "04-openstack-wsgi"
- "05-libvirt"
- "06-zookeeper"
- "07-kafka"
notify:
- Restart fluentd container
- name: Find custom fluentd input config files
local_action:
module: find
path: "{{ node_custom_config }}/fluentd/input"
pattern: "*.conf"
run_once: True
register: find_custom_fluentd_inputs
when:
- enable_fluentd | bool
- name: Copying over custom fluentd input config files
template:
src: "{{ item.path }}"
dest: "{{ node_config_directory }}/fluentd/input/{{ item.path | basename }}"
register: fluentd_input_custom
when:
- enable_fluentd | bool
with_items: "{{ find_custom_fluentd_inputs.files }}"
notify:
- Restart fluentd container
- name: Determine whether logs should be forwarded directly to Elasticsearch
set_fact:
log_direct_to_elasticsearch: "{{ ( enable_elasticsearch | bool or
( elasticsearch_address != kolla_internal_vip_address )) and
not enable_monasca | bool }}"
- name: Copying over fluentd output config files
template:
src: "conf/output/{{ item.name }}.conf.j2"
dest: "{{ node_config_directory }}/fluentd/output/{{ item.name }}.conf"
mode: "0660"
become: true
register: fluentd_output
when:
- enable_fluentd | bool
- item.enabled | bool
with_items:
- name: "00-local"
enabled: true
- name: "01-es"
enabled: "{{ log_direct_to_elasticsearch }}"
- name: "02-monasca"
enabled: "{{ enable_monasca | bool }}"
notify:
- Restart fluentd container
- name: Removing stale output config files
file:
path: "{{ node_config_directory }}/fluentd/output/{{ item.name }}.conf"
state: "absent"
become: true
when:
- enable_fluentd | bool
- item.disable | bool
with_items:
- name: "02-monasca"
disable: "{{ not enable_monasca | bool }}"
- name: "01-es"
disable: "{{ not log_direct_to_elasticsearch }}"
notify:
- Restart fluentd container
- name: Find custom fluentd output config files
local_action:
module: find
path: "{{ node_custom_config }}/fluentd/output"
pattern: "*.conf"
run_once: True
register: find_custom_fluentd_outputs
when:
- enable_fluentd | bool
- name: Copying over custom fluentd output config files
template:
src: "{{ item.path }}"
dest: "{{ node_config_directory }}/fluentd/output/{{ item.path | basename }}"
mode: "0660"
become: true
register: fluentd_output_custom
when:
- enable_fluentd | bool
with_items: "{{ find_custom_fluentd_outputs.files }}"
notify:
- Restart fluentd container
- name: Copying over fluentd format config files
template:
src: "conf/format/{{ item }}.conf.j2"
dest: "{{ node_config_directory }}/fluentd/format/{{ item }}.conf"
mode: "0660"
become: true
register: fluentd_format
with_items:
- "apache_access"
- "wsgi_access"
when: enable_fluentd | bool
notify:
- Restart fluentd container
- name: Copying over fluentd filter config files
template:
src: "conf/filter/{{ item.src }}.conf.j2"
dest: "{{ node_config_directory }}/fluentd/filter/{{ item.dest }}.conf"
mode: "0660"
become: true
register: fluentd_filter
with_items:
- src: 00-record_transformer
dest: 00-record_transformer
- src: "{{ '01-rewrite-0.14' if kolla_base_distro in ['debian', 'ubuntu'] else '01-rewrite-0.12' }}"
dest: 01-rewrite
when: enable_fluentd | bool
notify:
- Restart fluentd container
- name: Find custom fluentd filter config files
local_action:
module: find
path: "{{ node_custom_config }}/fluentd/filter"
pattern: "*.conf"
run_once: True
register: find_custom_fluentd_filters
when: enable_fluentd | bool
- name: Copying over custom fluentd filter config files
template:
src: "{{ item.path }}"
dest: "{{ node_config_directory }}/fluentd/filter/{{ item.path | basename }}"
mode: "0660"
become: true
register: fluentd_filter_custom
with_items: "{{ find_custom_fluentd_filters.files }}"
when: enable_fluentd | bool
notify:
- Restart fluentd container
- name: Copying over td-agent.conf
template:
src: "td-agent.conf.j2"
dest: "{{ node_config_directory }}/{{ item }}/td-agent.conf"
mode: "0660"
become: true
register: fluentd_td_agent
with_items:
- "fluentd"
when: enable_fluentd | bool
notify:
- Restart fluentd container
- name: Copying over cron logrotate config files
template:
src: "cron-logrotate-{{ item.name }}.conf.j2"
dest: "{{ node_config_directory }}/cron/logrotate/{{ item.name }}.conf"
mode: "0660"
become: true
register: cron_confs
when: item.enabled | bool
with_items:
- { name: "ansible", enabled: "yes" }
- { name: "aodh", enabled: "{{ enable_aodh }}" }
- { name: "barbican", enabled: "{{ enable_barbican }}" }
- { name: "blazar", enabled: "{{ enable_blazar }}" }
- { name: "ceilometer", enabled: "{{ enable_ceilometer }}" }
- { name: "ceph", enabled: "{{ enable_ceph }}" }
- { name: "chrony", enabled: "{{ enable_chrony }}" }
- { name: "cinder", enabled: "{{ enable_cinder }}" }
- { name: "cloudkitty", enabled: "{{ enable_cloudkitty }}" }
- { name: "collectd", enabled: "{{ enable_collectd }}" }
- { name: "congress", enabled: "{{ enable_congress }}" }
- { name: "designate", enabled: "{{ enable_designate }}" }
- { name: "elasticsearch", enabled: "{{ enable_elasticsearch }}" }
- { name: "etcd", enabled: "{{ enable_etcd }}" }
- { name: "freezer", enabled: "{{ enable_freezer }}" }
- { name: "glance", enabled: "{{ enable_glance }}" }
- { name: "global", enabled: "yes" }
- { name: "gnocchi", enabled: "{{ enable_gnocchi }}" }
- { name: "grafana", enabled: "{{ enable_grafana }}" }
- { name: "haproxy", enabled: "{{ enable_haproxy }}" }
- { name: "heat", enabled: "{{ enable_heat }}" }
- { name: "influxdb", enabled: "{{ enable_influxdb }}" }
- { name: "ironic", enabled: "{{ enable_ironic }}" }
- { name: "ironic-inspector", enabled: "{{ enable_ironic }}" }
- { name: "iscsid", enabled: "{{ enable_iscsid }}" }
- { name: "kafka", enabled: "{{ enable_kafka }}" }
- { name: "karbor", enabled: "{{ enable_karbor }}" }
- { name: "keepalived", enabled: "{{ enable_haproxy }}" }
- { name: "keystone", enabled: "{{ enable_keystone }}" }
- { name: "kibana", enabled: "{{ enable_kibana }}" }
- { name: "kuryr", enabled: "{{ enable_kuryr }}" }
- { name: "magnum", enabled: "{{ enable_magnum }}" }
- { name: "manila", enabled: "{{ enable_manila }}" }
- { name: "mariadb", enabled: "{{ enable_mariadb }}" }
- { name: "mistral", enabled: "{{ enable_mistral }}" }
- { name: "monasca", enabled: "{{ enable_monasca }}" }
- { name: "mongodb", enabled: "{{ enable_mongodb }}" }
- { name: "murano", enabled: "{{ enable_murano }}" }
- { name: "neutron", enabled: "{{ enable_neutron }}" }
- { name: "nova", enabled: "{{ enable_nova }}" }
- { name: "octavia", enabled: "{{ enable_octavia }}" }
- { name: "outward-rabbitmq", enabled: "{{ enable_outward_rabbitmq }}" }
- { name: "panko", enabled: "{{ enable_panko }}" }
- { name: "rabbitmq", enabled: "{{ enable_rabbitmq }}" }
- { name: "rally", enabled: "{{ enable_rally }}" }
- { name: "sahara", enabled: "{{ enable_sahara }}" }
- { name: "searchlight", enabled: "{{ enable_searchlight }}" }
- { name: "senlin", enabled: "{{ enable_senlin }}" }
- { name: "skydive", enabled: "{{ enable_skydive }}" }
- { name: "solum", enabled: "{{ enable_solum }}" }
- { name: "storm", enabled: "{{ enable_storm }}" }
- { name: "swift", enabled: "{{ enable_swift }}" }
- { name: "tacker", enabled: "{{ enable_tacker }}" }
- { name: "tempest", enabled: "{{ enable_tempest }}" }
- { name: "trove", enabled: "{{ enable_trove }}" }
- { name: "vitrage", enabled: "{{ enable_vitrage }}" }
- { name: "watcher", enabled: "{{ enable_watcher }}" }
- { name: "zookeeper", enabled: "{{ enable_zookeeper }}" }
- { name: "zun", enabled: "{{ enable_zun }}" }
notify:
- Restart cron container
- name: Ensuring config directories have correct owner and permission
become: true
file:
path: "{{ node_config_directory }}/{{ item.key }}"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
ignore_errors: "{{ ansible_check_mode }}"
when:
- item.value.enabled | bool
- item.key != "kolla-toolbox"
with_dict: "{{ common_services }}"
- name: Check common containers
become: true
kolla_docker:
action: "compare_container"
common_options: "{{ docker_common_options }}"
name: "{{ item.value.container_name }}"
image: "{{ item.value.image }}"
volumes: "{{ item.value.volumes }}"
dimensions: "{{ item.value.dimensions }}"
privileged: "{{ item.value.privileged | default(False) }}"
environment: "{{ item.value.environment }}"
register: check_common_containers
when:
- kolla_action != "config"
- item.value.enabled | bool
with_dict: "{{ common_services }}"
notify:
- "Restart {{ item.key }} container"