aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-03-10 20:22:15 +0000
committerGerrit Code Review <review@openstack.org>2016-03-10 20:22:15 +0000
commita28b246259ee45d54d036d1db3d6ca19318fbafc (patch)
tree469cdf10e38ea625c3656edf55c60616f74e2f10
parent4a5859bb4690bed22c3d8ca44aa376d2058d440b (diff)
parent32a4cadac9072d630146e0fb667aec146fcd186f (diff)
downloadkolla-a28b246259ee45d54d036d1db3d6ca19318fbafc.tar.gz
kolla-a28b246259ee45d54d036d1db3d6ca19318fbafc.zip
Merge "Add cron image and playbook"
-rw-r--r--ansible/roles/common/defaults/main.yml4
-rw-r--r--ansible/roles/common/tasks/config.yml26
-rw-r--r--ansible/roles/common/tasks/start.yml11
-rw-r--r--ansible/roles/common/templates/cron-logrotate-ansible.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-cinder.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-glance.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-global.conf.j221
-rw-r--r--ansible/roles/common/templates/cron-logrotate-haproxy.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-heat.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-keepalived.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-keystone.conf.j25
-rw-r--r--ansible/roles/common/templates/cron-logrotate-magnum.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-manila.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-mariadb.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-mistral.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-murano.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-neutron.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-nova.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-rabbitmq.conf.j23
-rw-r--r--ansible/roles/common/templates/cron-logrotate-swift.conf.j23
-rw-r--r--ansible/roles/common/templates/cron.json.j222
-rw-r--r--ansible/roles/common/templates/heka-keystone.toml.j23
-rw-r--r--ansible/roles/common/templates/heka-mariadb.toml.j23
-rw-r--r--ansible/roles/common/templates/heka-openstack.toml.j23
-rw-r--r--ansible/roles/common/templates/heka-rabbitmq.toml.j23
-rw-r--r--docker/cron/Dockerfile.j223
-rw-r--r--docker/cron/extend_start.sh7
-rw-r--r--kolla/common/config.py6
-rwxr-xr-xtools/cleanup-containers1
29 files changed, 176 insertions, 7 deletions
diff --git a/ansible/roles/common/defaults/main.yml b/ansible/roles/common/defaults/main.yml
index bb5722867..26abea99a 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 88ac7ba11..30e7a6400 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 c6e44d598..b3d3a3096 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 000000000..3bc0f435b
--- /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 000000000..b5e59abd2
--- /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 000000000..5b20985bd
--- /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 000000000..c21e3d1c0
--- /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 000000000..7af26dd38
--- /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 000000000..7f5e89a77
--- /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 000000000..0346c051d
--- /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 000000000..22dded903
--- /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 000000000..4b2c2af4e
--- /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 000000000..9b9719514
--- /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 000000000..8543983e0
--- /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 000000000..e8e6da8e3
--- /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 000000000..ab3309019
--- /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 000000000..f4c226829
--- /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 000000000..657a994da
--- /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 000000000..cf2dc3f36
--- /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 000000000..0ad2badf1
--- /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 000000000..d6c51d8f0
--- /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 5747d417c..6d7874d56 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 85fad0d04..07d710541 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 32c20514a..9cf3782db 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 d8e16ec3b..d2c49aa1e 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 000000000..fd7b53cd5
--- /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 000000000..08efca96f
--- /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 3816230af..2c6ec6714 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 38772e654..da716b060 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 \