This is quite a good example Ansible script that can be used when you have different falvours of Linux in your estate.
This example is for changing syslog address for both Redhat and SuSE Linux. This is good to have around in the toolkit, I also have one for differnent versions of the same flavour.
--- - name: "Change Syslog Server" hosts: syslog remote_user: root tasks: - name: replace: dest: /etc/syslog-ng/syslog-ng.conf regexp: '^destination logserver \{ udp\(\"oldsyslog01\" port\(514\)\); \};' replace: 'destination logserver { udp("newsyslog01" port(556)); };' register: suse_result when: (ansible_os_family == "Suse") - service: name=syslog state=restarted when: suse_result.changed - name: replace: dest: /etc/rsyslog.conf regexp: 'oldsyslog01:514' replace: 'newsyslog01:556' register: redhat_result when: (ansible_os_family == "RedHat") - service: name=rsyslog state=restarted when: redhat_result.changed
So here you can see the simple way you can change your syslog hosts and ports. You can also put in IP addresses if they are in the file.
Then when you have all your hosts listed in /etc/ansible/hosts then run ansible-playbook change_syslog.yml and leave it to work it's magic
I am always interested in your thoughts so if you have any comments or feedback then please feel free to add any comments, or you can mail me here.