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
This commit is contained in:
rabi 2021-09-23 15:16:21 +05:30
parent 8ef66366de
commit 8d51d6d3f4
2 changed files with 36 additions and 44 deletions

View File

@ -425,35 +425,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

@ -723,35 +723,31 @@ outputs:
with_items: "{{ swift_raw_disks }}"
when: swift_raw_disks|length > 0
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"