From 4a75d05de14e37fb7c6bf14a4d999dd5016add47 Mon Sep 17 00:00:00 2001 From: inc0 Date: Thu, 20 Aug 2015 12:35:19 +0200 Subject: [PATCH] Ansible bits to rsyslog Ansible installation of rsyslog container Change-Id: I17a7ee679f72e8fe667012d7eb6e07a27098a909 Implements: bp logging-container --- ansible/roles/common/defaults/main.yml | 8 ++++ ansible/roles/common/tasks/config.yml | 11 +++++ ansible/roles/common/tasks/main.yml | 3 ++ ansible/roles/common/tasks/start.yml | 44 +++++++++++++++++++ .../roles/common/templates/rsyslog.conf.j2 | 14 ++++++ 5 files changed, 80 insertions(+) mode change 100644 => 100755 ansible/roles/common/defaults/main.yml create mode 100755 ansible/roles/common/tasks/config.yml mode change 100644 => 100755 ansible/roles/common/tasks/main.yml mode change 100644 => 100755 ansible/roles/common/tasks/start.yml create mode 100755 ansible/roles/common/templates/rsyslog.conf.j2 diff --git a/ansible/roles/common/defaults/main.yml b/ansible/roles/common/defaults/main.yml old mode 100644 new mode 100755 index 2e972e44f4..492b96a4e7 --- a/ansible/roles/common/defaults/main.yml +++ b/ansible/roles/common/defaults/main.yml @@ -5,3 +5,11 @@ ansible_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-kolla-ansible" ansible_tag: "{{ openstack_release }}" ansible_image_full: "{{ ansible_image }}:{{ ansible_tag }}" + +rsyslog_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-rsyslog" +rsyslog_tag: "{{ openstack_release }}" +rsyslog_image_full: "{{ rsyslog_image }}:{{ rsyslog_tag }}" + +log_data_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-data" +log_data_tag: "{{ openstack_release }}" +log_data_image_full: "{{ log_data_image }}:{{ log_data_tag }}" diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml new file mode 100755 index 0000000000..2b381dc700 --- /dev/null +++ b/ansible/roles/common/tasks/config.yml @@ -0,0 +1,11 @@ +--- +- name: Ensuring config directory exists + file: + path: "{{ node_config_directory }}/rsyslog/" + state: "directory" + recurse: "yes" + +- name: Copying over config(s) + template: + src: "rsyslog.conf.j2" + dest: "{{ node_config_directory }}/rsyslog/rsyslog.conf" diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml old mode 100644 new mode 100755 index 50662fbc56..81a6a0525a --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -1,2 +1,5 @@ --- +- include: config.yml + - include: start.yml + diff --git a/ansible/roles/common/tasks/start.yml b/ansible/roles/common/tasks/start.yml old mode 100644 new mode 100755 index 13c9a410cb..7b37d0cd6a --- a/ansible/roles/common/tasks/start.yml +++ b/ansible/roles/common/tasks/start.yml @@ -1,4 +1,46 @@ --- + +- name: Starting log_data container + docker: + docker_api_version: "{{ docker_api_version }}" + net: host + pull: "{{ docker_pull_policy }}" + restart_policy: "{{ docker_restart_policy }}" + restart_policy_retry: "{{ docker_restart_policy_retry }}" + state: reloaded + registry: "{{ docker_registry }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + insecure_registry: "{{ docker_insecure_registry }}" + name: log_data + image: "{{ log_data_image_full }}" + volumes: + - "/var/log" + env: + KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" + +- name: Starting rsyslog container + docker: + docker_api_version: "{{ docker_api_version }}" + net: host + pull: "{{ docker_pull_policy }}" + restart_policy: "{{ docker_restart_policy }}" + restart_policy_retry: "{{ docker_restart_policy_retry }}" + state: reloaded + registry: "{{ docker_registry }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + insecure_registry: "{{ docker_insecure_registry }}" + name: rsyslog + image: "{{ rsyslog_image_full }}" + volumes_from: + - "log_data" + volumes: + - "/var/lib/kolla/dev:/dev" + - "{{ node_config_directory }}/rsyslog/:/opt/kolla/rsyslog/:ro" + env: + KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" + - name: Starting Ansible container docker: docker_api_version: "{{ docker_api_version }}" @@ -16,4 +58,6 @@ env: ANSIBLE_NOCOLOR: "1" ANSIBLE_LIBRARY: "/usr/share/ansible" + volumes: + - /var/lib/kolla/dev/log:/dev/log command: "/bin/sleep infinity" diff --git a/ansible/roles/common/templates/rsyslog.conf.j2 b/ansible/roles/common/templates/rsyslog.conf.j2 new file mode 100755 index 0000000000..26c6198fe5 --- /dev/null +++ b/ansible/roles/common/templates/rsyslog.conf.j2 @@ -0,0 +1,14 @@ +# provides support for local system logging +$ModLoad imuxsock + +$ModLoad imklog +$KLogPermitNonKernelFacility on +$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat +$RepeatedMsgReduction on + +$template KollaAnsibleFile,"/var/log/kolla_ansible.log" +:syslogtag,contains,"ansible" ?KollaAnsibleFile + +$template DynFile,"/var/log/syslog.log" +*.* ?DynFile +& ~