Fix swift log redirection

Looks like swift log forwarding is skipped atm. Conditions on
ansible blocks are evaluated per task and once a var is
registered, 'is not defined' check (from block) fails and the tasks
are skipped.

This keeps the tasks same in both services so the duplicates
are excluded in DeployStepsTasks.

Also uses shell command like haproxy to check service status.

|         OK | Check if rsyslog exists | overcloud-controller-0
|     TIMING | Check if rsyslog exists | overcloud-controller-0 | 0:15:17.829966 | 0.37s
|       TASK | Forward logging to swift.log file
|    SKIPPED | Forward logging to swift.log file | overcloud-controller-0
|     TIMING | Forward logging to swift.log file | overcloud-controller-0 | 0:15:17.881102 | 0.04s
|       TASK | Restart rsyslogd service after logging conf change
|    SKIPPED | Restart rsyslogd service after logging conf change | overcloud-controller-0
|     TIMING | Restart rsyslogd service after logging conf change | overcloud-controller-0 | 0:15:17.924588 | 0.03s

Change-Id: I2f17b993029fc02ffe1e9d0f6a9c31b9eb97cc0a
(cherry picked from commit 8d51d6d3f4)
This commit is contained in:
rabi 2021-09-23 15:16:21 +05:30 committed by Rabi Mishra
parent 6b70e35fe2
commit ae34f60cdb
2 changed files with 36 additions and 44 deletions

View File

@ -457,35 +457,31 @@ outputs:
- { 'path': /var/log/swift, 'setype': container_file_t }
- { 'path': /var/log/containers/swift, 'setype': container_file_t, 'mode': '0750' }
deploy_steps_tasks:
- name: Configure rsyslog for swift-proxy
- name: Configure rsyslog for swift
when:
- step|int == 1
- swift_logconfig is not defined
- swift_rsyslog_config is not defined
block:
- name: Check if rsyslog exists
systemd:
name: rsyslog
shell: systemctl is-active rsyslog
register: swift_rsyslog_config
- block:
- name: Forward logging to swift.log file
copy:
content: |
# Fix for https://bugs.launchpad.net/tripleo/+bug/1776180
local2.* /var/log/containers/swift/swift.log
& stop
dest: /etc/rsyslog.d/openstack-swift.conf
register: swift_logconfig
- name: Restart rsyslogd service after logging conf change
service:
name: rsyslog
state: restarted
when:
- swift_logconfig is changed
- name: Forward logging to swift.log file
copy:
content: |
# Fix for https://bugs.launchpad.net/tripleo/+bug/1776180
local2.* /var/log/containers/swift/swift.log
& stop
dest: /etc/rsyslog.d/openstack-swift.conf
register: swift_logconfig
when:
- swift_rsyslog_config is defined
- swift_rsyslog_config.status is defined
- swift_rsyslog_config.status.ActiveState == 'active'
- swift_rsyslog_config.rc == 0
- name: Restart rsyslogd service after logging conf change
service:
name: rsyslog
state: restarted
when:
- swift_logconfig is defined
- swift_logconfig is changed
- name: Run kolla_set_configs to copy ring files
when: step|int == 5
shell: "{{ container_cli }} exec -u root {{ item }} /usr/local/bin/kolla_set_configs "

View File

@ -649,35 +649,31 @@ outputs:
with_items: "{{ swift_raw_disks }}"
when: swift_raw_disks
deploy_steps_tasks:
- name: Configure rsyslog for swift-storage
- name: Configure rsyslog for swift
when:
- step|int == 1
- swift_logconfig is not defined
- swift_rsyslog_config is not defined
block:
- name: Check if rsyslog exists
systemd:
name: rsyslog
shell: systemctl is-active rsyslog
register: swift_rsyslog_config
- block:
- name: Forward logging to swift.log file
copy:
content: |
# Fix for https://bugs.launchpad.net/tripleo/+bug/1776180
local2.* /var/log/containers/swift/swift.log
& stop
dest: /etc/rsyslog.d/openstack-swift.conf
register: swift_logconfig
- name: Restart rsyslogd service after logging conf change
service:
name: rsyslog
state: restarted
when:
- swift_logconfig is changed
- name: Forward logging to swift.log file
copy:
content: |
# Fix for https://bugs.launchpad.net/tripleo/+bug/1776180
local2.* /var/log/containers/swift/swift.log
& stop
dest: /etc/rsyslog.d/openstack-swift.conf
register: swift_logconfig
when:
- swift_rsyslog_config is defined
- swift_rsyslog_config.status is defined
- swift_rsyslog_config.status.ActiveState == 'active'
- swift_rsyslog_config.rc == 0
- name: Restart rsyslogd service after logging conf change
service:
name: rsyslog
state: restarted
when:
- swift_logconfig is defined
- swift_logconfig is changed
- name: Run kolla_set_configs to copy ring files
when: step|int == 5
shell: "{{ container_cli }} exec -u root {{ item }} /usr/local/bin/kolla_set_configs"