Skip to content

Commit

Permalink
Merged PR 1291: Fix rsyslog issue in master pipeline
Browse files Browse the repository at this point in the history
In PR: https://dev.azure.com/mssonic/internal/_git/sonic-mgmt-int/pullrequest/1151,  we patched rsyslog to send out rsyslog message to lab server and ingests to Kusto. With the SONiC version information, we can query syslog of lab DUTs in Kusto by its version information.

However, master image has added template="SONiCFileFormat" in PR: sonic-net/sonic-buildimage#10991, which caused issue: https://msazure.visualstudio.com/One/_workitems/edit/15990217

To solve this issue, in master image pipeline, we replace template=.*SONiCFileFormat with template=RemoteSONiCFileFormat; in internal image pipeline, we add template=RemoteSONiCFileFormat to action omfwd
  • Loading branch information
xwjiang-ms committed Nov 17, 2022
1 parent ae7674d commit e174adc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ansible/patch_rsyslog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
shell: sed -E -i 's/(^[^#]*@\[[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\]:514).*$/\1;RemoteSONiCFileFormat/g' /etc/rsyslog.conf
become: true

- name: Get template in rsyslog.conf
shell: echo `grep -c 'template=".*SONiCFileFormat"' /usr/share/sonic/templates/rsyslog.conf.j2`
register: remote_template

# Workaround for PR https://msazure.visualstudio.com/One/_git/Networking-acs-buildimage/pullrequest/6631568
# This PR updated the rsyslog.conf to use a new method for sending out syslog. Need to configure the new method
# to use RemoteSONiCFileFormat too.
Expand All @@ -60,6 +64,20 @@
loop_control:
loop_var: rsyslog_conf_path
become: true
when: remote_template.stdout == "0"

- name: Patch rsyslog.conf and rsyslog.conf.j2 to use RemoteSONiCFileFormat instead of SONiCFileFormat for action type omfwd
replace:
dest: "{{ rsyslog_conf_path }}"
regexp: 'template=".*SONiCFileFormat"'
replace: 'template="RemoteSONiCFileFormat"'
loop:
- /usr/share/sonic/templates/rsyslog.conf.j2
- /etc/rsyslog.conf
loop_control:
loop_var: rsyslog_conf_path
become: true
when: remote_template.stdout != "0"

- name: Restart rsyslog service
shell: systemctl restart rsyslog
Expand Down

0 comments on commit e174adc

Please sign in to comment.