Update timezone data on RedHat-like servers using fabric


/ Published in: Python

Usage:

1. save the snippet as *fabfile.py*

2. and run:

**$ fab -H myhost1,myhost2...**

or set *env.roledefs['myrole'] = ['myhost1', 'myhost2', ...]* in *fabfile.py* and run this way:

**$ fab -R myrole**


Copy this code and paste it in your HTML
  1. from fabric.api import env, hide, run, task
  2. import re
  3.  
  4. env.user = 'root'
  5.  
  6. @task(default=True)
  7. def tz_up():
  8. upd = []
  9. with hide('output'):
  10. for pkg in run('rpm -qa').split('\n'):
  11. if re.search('^tzdata-', pkg): upd.append(re.sub('-\d.*$', '', pkg))
  12. if upd:
  13. run('yum update -q -y ' + ' '.join(upd))
  14. run('cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime')

URL: fab_yum_up_tzdata

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.