--- - name: syslog bash history lineinfile: | dest=/etc/bash.bashrc insertafter=EOF line="{{item}}" create=true with_items: - 'function history_to_syslog {' - ' declare cmd' - ' cmd=$(fc -ln -0)' - ' [[ $cmd ]] && logger -p local6.notice -t bash\[$$\] -- USER=$USER $cmd' - '}' - 'trap history_to_syslog DEBUG'