I been having problems getting this to work, can anyone provide any insights?
- name Configuring rsyslog.conf playbook
hosts: "{{host}}"
tasks:
- name: Configuring rsyslog.conf
lineinfile:
path: /etc/rsyslog.conf
regexp: "{{item.regexp}}"
line: "{{item.line}}"
state: present
loop:
- { regexp='^action\\(type=', line='action(type"omfwd"' }
- { regexp='^Target=', line='Target="192.168.1.20" Port="514" Protocol="tcp")' }
- { regexp='^$PreserveFQDN', line='$PreserveFQDN on' }
- { regexp='^$template defaultTemplate', line='$template defaultTemplate,\"<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag% %msg% ID:123456789\n\"' }
- { regexp='^$template writeLogs', line='$template writeLogs,\"/var/log/ID-123456789-%$year%%$month%%$day%.log\"' }
My main issue is the 4th loop. I escaped the double quotes to get rid of the "missing comma error" but now I get the "colon error"
EDIT: So my end result I'd like is pretty much this with that 4th loop:
find:
$template defaultTemplate
replace with:
$template defaultTemplate,"<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag% %msg% ID:123456789\n"
I'm unable to cut and paste anything from my computer as it's on a different network. The big issue I'm seeing is knowing what needs to be escaped. I thought it was kinda weird that I had to escape the "(" in the first loop. I been trying all kinds of escapes and none seems to work. It would be so much easier if everything placed in single quotes would be what was literally written in, but it doesn't seem to work that way.
Hope this makes it a bit more clear.
EDIT: one thing I'd like to add, is doing these tasks individually works just fine. It's just when I put it in a loop that it doesn't want to work.