The host called “wmd1” used to be the remote logger for all the LINUX boxes in the “left” data center. In the “right” data center it was “wmd2”. For whatever reason its replacement in the “left” data center is now called “wmd7”. The rest is Ansible playbook allowing for a mass edits across all the “left” boxes.
- hosts: remote_user: root tasks: - name: copy /etc/rsyslog.conf to /etc/rsyslog.conf.OLD copy: src=/etc/rsyslog.conf dest=/etc/rsyslog.conf.OLD force=no - name: replace the name of remote logger or insert it if missing shell: grep .*wmd.*\.wmd.edu /etc/rsyslog.conf && sed --in-place 's/wmd.*\.wmd.edu/wmd7.wmd.edu/' /etc/rsyslog.conf || echo '*.* @@wmd7.wmd.edu:1515' >> /etc/rsyslog.conf ; service rsyslog restart
shell line is one long line – there are no folding characters above.