diff --git a/ansible/roles/common/defaults/main.yml b/ansible/roles/common/defaults/main.yml index bb5722867114b6b2be588f788675472b38d98b8a..26abea99ab503f7f5f7a59167dcc5f0cc643e800 100644 --- a/ansible/roles/common/defaults/main.yml +++ b/ansible/roles/common/defaults/main.yml @@ -13,3 +13,7 @@ ansible_image_full: "{{ ansible_image }}:{{ ansible_tag }}" heka_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-heka" heka_tag: "{{ openstack_release }}" heka_image_full: "{{ heka_image }}:{{ heka_tag }}" + +cron_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-cron" +cron_tag: "{{ openstack_release }}" +cron_image_full: "{{ cron_image }}:{{ cron_tag }}" diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index 88ac7ba11cdbe030f5974466f1cf64d89bf3980f..30e7a64007b5383bfe3cf340a411031ae535d5a1 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -6,6 +6,8 @@ recurse: yes with_items: - "heka" + - "cron" + - "cron/logrotate" - name: Copying over config.json files for services template: @@ -13,6 +15,7 @@ dest: "{{ node_config_directory }}/{{ item }}/config.json" with_items: - "heka" + - "cron" - name: Copying over heka config files template: @@ -55,3 +58,26 @@ with_items: - "elasticsearch" when: "{{ enable_central_logging | bool }}" + +- name: Copying over cron logrotate config files + template: + src: "cron-logrotate-{{ item }}.conf.j2" + dest: "{{ node_config_directory }}/cron/logrotate/{{ item }}.conf" + with_items: + - "ansible" + - "cinder" + - "glance" + - "global" + - "haproxy" + - "heat" + - "keepalived" + - "keystone" + - "magnum" + - "manila" + - "mariadb" + - "mistral" + - "murano" + - "neutron" + - "nova" + - "rabbitmq" + - "swift" diff --git a/ansible/roles/common/tasks/start.yml b/ansible/roles/common/tasks/start.yml index c6e44d59826d9c5bf6fcf664299a2930da161706..b3d3a3096b500345bac5b6c550fecef57863da35 100644 --- a/ansible/roles/common/tasks/start.yml +++ b/ansible/roles/common/tasks/start.yml @@ -28,3 +28,14 @@ - "/dev/:/dev/" - "/run/:/run/" - "kolla_logs:/var/log/kolla/" + +- name: Starting cron container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + image: "{{ cron_image_full }}" + name: "cron" + volumes: + - "{{ node_config_directory }}/cron/:{{ container_config_directory }}/:ro" + - "heka_socket:/var/lib/kolla/heka/" + - "kolla_logs:/var/log/kolla/" diff --git a/ansible/roles/common/templates/cron-logrotate-ansible.conf.j2 b/ansible/roles/common/templates/cron-logrotate-ansible.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..3bc0f435b0b2048352df1edb971a08fb3122b3bb --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-ansible.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/ansible.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-cinder.conf.j2 b/ansible/roles/common/templates/cron-logrotate-cinder.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..b5e59abd2623843f4a1abcd945d4604c591d2fa2 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-cinder.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/cinder/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-glance.conf.j2 b/ansible/roles/common/templates/cron-logrotate-glance.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..5b20985bd002f8f9d529b03604d3021081f631f8 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-glance.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/glance/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-global.conf.j2 b/ansible/roles/common/templates/cron-logrotate-global.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..c21e3d1c0753e2349103b4c53db1b95b5aa39e5d --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-global.conf.j2 @@ -0,0 +1,21 @@ +weekly + +rotate 6 + +copytruncate + +compress + +delaycompress + +notifempty + +missingok + +minsize 30M + +maxsize 100M + +su root kolla + +include /etc/logrotate.d diff --git a/ansible/roles/common/templates/cron-logrotate-haproxy.conf.j2 b/ansible/roles/common/templates/cron-logrotate-haproxy.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..7af26dd38b4b72e2e68337698a174cb352aa3fe8 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-haproxy.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/haproxy/haproxy.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-heat.conf.j2 b/ansible/roles/common/templates/cron-logrotate-heat.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..7f5e89a77e5be83c7b80d5768b89f2ffb8c22f13 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-heat.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/heat/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-keepalived.conf.j2 b/ansible/roles/common/templates/cron-logrotate-keepalived.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..0346c051d8130f7f3d3fe3244e239a3919045ec7 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-keepalived.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/haproxy/keepalived.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-keystone.conf.j2 b/ansible/roles/common/templates/cron-logrotate-keystone.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..22dded903d0c748bfb72e90eb15b8e0ca1fe445b --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-keystone.conf.j2 @@ -0,0 +1,5 @@ +{% set apache_dir = 'apache2' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd' %} +"/var/log/kolla/keystone/*.log" +"/var/log/kolla/{{ apache_dir }}/keystone-apache-*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-magnum.conf.j2 b/ansible/roles/common/templates/cron-logrotate-magnum.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..4b2c2af4e648414bd73bb03e536b52141b9c63de --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-magnum.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/magnum/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-manila.conf.j2 b/ansible/roles/common/templates/cron-logrotate-manila.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..9b9719514f1bd8ebcc59665c4edf58b632614f84 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-manila.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/manila/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-mariadb.conf.j2 b/ansible/roles/common/templates/cron-logrotate-mariadb.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..8543983e042a90d76f7dc4b31f416cf9b4d0409e --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-mariadb.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/mariadb/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-mistral.conf.j2 b/ansible/roles/common/templates/cron-logrotate-mistral.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..e8e6da8e39f4db7a8374013ef1cd639319952679 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-mistral.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/mistral/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-murano.conf.j2 b/ansible/roles/common/templates/cron-logrotate-murano.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..ab33090192dc5aa98ec1ca927097581e4ef2f5fc --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-murano.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/murano/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-neutron.conf.j2 b/ansible/roles/common/templates/cron-logrotate-neutron.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..f4c226829215660399c7d47b9c88bef5101d7283 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-neutron.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/neutron/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-nova.conf.j2 b/ansible/roles/common/templates/cron-logrotate-nova.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..657a994da18cf637f018587932a9776067267d82 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-nova.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/nova/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-rabbitmq.conf.j2 b/ansible/roles/common/templates/cron-logrotate-rabbitmq.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..cf2dc3f367d25ed75da1c4b9e30d3291206bb7a2 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-rabbitmq.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/rabbitmq/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron-logrotate-swift.conf.j2 b/ansible/roles/common/templates/cron-logrotate-swift.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..0ad2badf1b2d9b1d1ece7a36a35098461e5ff5b3 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-swift.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/swift/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron.json.j2 b/ansible/roles/common/templates/cron.json.j2 new file mode 100644 index 0000000000000000000000000000000000000000..d6c51d8f0c768580f6b1237484ea1710768f6fbe --- /dev/null +++ b/ansible/roles/common/templates/cron.json.j2 @@ -0,0 +1,22 @@ +{% set cron_cmd = 'cron -f' if kolla_base_distro in ['ubuntu', 'debian'] else 'crond -s -n' %} +{% set services = ["ansible", "cinder", "glance", "haproxy", "heat", "keepalived", "keystone", "magnum", "manila", "mariadb", "mistral", "murano", "neutron", "nova", "rabbitmq", "swift"] %} +{ + "command": "{{ cron_cmd }}", + "config_files": [ + { + "source": "{{ container_config_directory }}/logrotate/global.conf", + "dest": "/etc/logrotate.conf", + "owner": "root", + "perm": "0644" + }, +{% for service in services %} + { + "source": "{{ container_config_directory }}/logrotate/{{ service }}.conf", + "dest": "/etc/logrotate.d/{{ service }}.conf", + "owner": "root", + "perm": "0644" + }{% if not loop.last %},{% endif %} +{% endfor %} + + ] +} diff --git a/ansible/roles/common/templates/heka-keystone.toml.j2 b/ansible/roles/common/templates/heka-keystone.toml.j2 index 5747d417ce45ec1f46865ac5ccc01dc2cd0130a6..6d7874d5663e798828f6a3c34d855700b2067f89 100644 --- a/ansible/roles/common/templates/heka-keystone.toml.j2 +++ b/ansible/roles/common/templates/heka-keystone.toml.j2 @@ -9,5 +9,6 @@ filename = "lua_decoders/os_keystone_apache_log.lua" type = "LogstreamerInput" decoder = "keystone_apache_log_decoder" log_directory = "/var/log/kolla" -file_match = '{{ apache_dir }}/keystone-apache-(?P<Service>.+)-access\.log' +file_match = '{{ apache_dir }}/keystone-apache-(?P<Service>.+)-access\.log\.?(?P<Seq>\d*)$' +priority = ["^Seq"] differentiator = ["keystone-apache-", "Service"] diff --git a/ansible/roles/common/templates/heka-mariadb.toml.j2 b/ansible/roles/common/templates/heka-mariadb.toml.j2 index 85fad0d0422a2df992b00cf269def122f4e7b722..07d71054101d95b9720f2bbe0752ed4536737a1e 100644 --- a/ansible/roles/common/templates/heka-mariadb.toml.j2 +++ b/ansible/roles/common/templates/heka-mariadb.toml.j2 @@ -6,5 +6,6 @@ filename = "lua_decoders/os_mysql_log.lua" type = "LogstreamerInput" decoder = "mariadb_log_decoder" log_directory = "/var/log/kolla" -file_match = 'mariadb/mariadb\.log' +file_match = 'mariadb/mariadb\.log\.?(?P<Seq>\d*)$' +priority = ["^Seq"] differentiator = ['mariadb'] diff --git a/ansible/roles/common/templates/heka-openstack.toml.j2 b/ansible/roles/common/templates/heka-openstack.toml.j2 index 32c20514a2a9007010e8f7c945e12a2994cbd15b..9cf3782db5cdb7ba9e30a498b6d209cc1643aa8f 100644 --- a/ansible/roles/common/templates/heka-openstack.toml.j2 +++ b/ansible/roles/common/templates/heka-openstack.toml.j2 @@ -6,5 +6,6 @@ filename = "lua_decoders/os_openstack_log.lua" type = "LogstreamerInput" decoder = "openstack_log_decoder" log_directory = "/var/log/kolla" -file_match = '(?P<Service>nova|glance|keystone|neutron|cinder|heat|murano|magnum|mistral|manila)/(?P<Program>.*)\.log' +file_match = '(?P<Service>nova|glance|keystone|neutron|cinder|heat|murano|magnum|mistral|manila)/(?P<Program>.*)\.log\.?(?P<Seq>\d*)$' +priority = ["^Seq"] differentiator = ["Service", "_", "Program"] diff --git a/ansible/roles/common/templates/heka-rabbitmq.toml.j2 b/ansible/roles/common/templates/heka-rabbitmq.toml.j2 index d8e16ec3bee8b1a7e9f8e1eb29427aca804e75de..d2c49aa1e786e82e9f236483279893cae9e930d5 100644 --- a/ansible/roles/common/templates/heka-rabbitmq.toml.j2 +++ b/ansible/roles/common/templates/heka-rabbitmq.toml.j2 @@ -13,5 +13,6 @@ type = "LogstreamerInput" decoder = "rabbitmq_log_decoder" splitter = "rabbitmq_log_splitter" log_directory = "/var/log/kolla" -file_match = 'rabbitmq/(?P<Service>rabbit.*)\.log' +file_match = 'rabbitmq/(?P<Service>rabbit.*)\.log\.?(?P<Seq>\d*)$' +priority = ["^Seq"] differentiator = ["Service"] diff --git a/docker/cron/Dockerfile.j2 b/docker/cron/Dockerfile.j2 new file mode 100644 index 0000000000000000000000000000000000000000..fd7b53cd5ed63c114c478f0312050eee071648fa --- /dev/null +++ b/docker/cron/Dockerfile.j2 @@ -0,0 +1,23 @@ +FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} + +RUN yum -y install \ + cronie \ + logrotate \ + && yum clean all + +{% elif base_distro in ['ubuntu', 'debian'] %} + +RUN apt-get install -y --no-install-recommends \ + cron \ + logrotate \ + && apt-get clean + +{% endif %} + +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 755 /usr/local/bin/kolla_extend_start + +{{ include_footer }} diff --git a/docker/cron/extend_start.sh b/docker/cron/extend_start.sh new file mode 100644 index 0000000000000000000000000000000000000000..08efca96fa1130658377df7e4ce2f5fc62afd1bf --- /dev/null +++ b/docker/cron/extend_start.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# NOTE(elemoine): the cron daemon sends its logs to /dev/log. Heka's log socket +# is at /var/lib/kolla/heka/log so we symlink /dev/log to that location. +if [[ ! -h /dev/log ]]; then + ln -sf /var/lib/kolla/heka/log /dev/log +fi diff --git a/kolla/common/config.py b/kolla/common/config.py index 3816230af0686c6b206119eac27ded1d7e35900f..2c6ec6714f6ff7239b7b8359e4c1a5062bfc8d1c 100644 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -25,7 +25,7 @@ INSTALL_TYPE_CHOICES = ['binary', 'source', 'rdo', 'rhos'] _PROFILE_OPTS = [ cfg.ListOpt('infra', - default=['ceph', 'mariadb', 'haproxy', + default=['ceph', 'cron', 'mariadb', 'haproxy', 'keepalived', 'kolla-toolbox', 'memcached', 'mongodb', 'openvswitch', 'rabbitmq', 'heka'], help='Infra images'), @@ -39,13 +39,13 @@ _PROFILE_OPTS = [ 'magnum', 'mistral', 'trove,' 'zaqar', 'zookeeper'], help='Aux Images'), cfg.ListOpt('default', - default=['kolla-toolbox', 'glance', 'haproxy', + default=['cron', 'kolla-toolbox', 'glance', 'haproxy', 'heat', 'horizon', 'keepalived', 'keystone', 'memcached', 'mariadb', 'neutron', 'nova', 'openvswitch', 'rabbitmq', 'heka'], help='Default images'), cfg.ListOpt('gate', - default=['glance', 'haproxy', 'keepalived', 'keystone', + default=['cron', 'glance', 'haproxy', 'keepalived', 'keystone', 'kolla-toolbox', 'mariadb', 'memcached', 'neutron', 'nova', 'openvswitch', 'rabbitmq', 'heka'], help='Gate images'), diff --git a/tools/cleanup-containers b/tools/cleanup-containers index 38772e6547183d158bf28183b0c2697e046b247a..da716b0607c15bb63627e0336e4dc7d081025a23 100755 --- a/tools/cleanup-containers +++ b/tools/cleanup-containers @@ -14,6 +14,7 @@ else bootstrap_{ceph_mon,cinder,glance,heat,heka,ironic,ironic_pxe,keystone,magnum,mistral,mongodb,murano,neutron,nova,nova_compute} \ cinder_{volume,scheduler,backup,api} \ ceph_{mon,rgw} \ + cron \ elasticsearch \ glance_{api,registry} \ haproxy \