Originally Posted by
Vaphell
I can't agree learning awk is a waste of time. I've solved many non-trivial problems with it and i still don't know perl.
AWK offers excellent ROI - after just few hours of learning you can solve like 95% of common problems.
Agreed, but that same comment could be made for perl, ruby, python, bash or ...
If you have 5+ servers to manage, check out ansible. I think you'll thank me. Ensuring a config option exists inside a config file is trivial with Ansible. If it exists, it will be left alone. If the line exists, but isn't what you want, it will be changed. If the setting is not in the conf file, it will be added. All with just 1 trivial ansible input. If you are managing 50 conf files, all the pre-written, pre-validated ansible code really speeds things up.
My ansible file to have logwatch use my email address:
common_logwatch_settings.yml
Code:
---
- name: Make logwatch mail {{ logwatch_email }} daily
action: lineinfile dest=/etc/cron.daily/00logwatch
regexp="^/usr/sbin/logwatch" line="/usr/sbin/logwatch --output mail --mailto $logwatch_email --detail high"
state=present create=yes
and that is a complex version.
for sshd_config settings:
Code:
---
- name: Update ssh parameters - no root login
action: lineinfile dest=/etc/ssh/sshd_config
regexp="PermitRootLogin" line="PermitRootLogin without-password"
state=present create=yes
action: lineinfile dest=/etc/ssh/sshd_config
regexp="X11Forwarding" line="X11Forwarding yes"
state=present create=yes
notify:
- restart ssh
Bookmarks