Posted By

alces on 09/26/14


Tagged

python fabric yum tzdata zoneinfo localtime


Versions (?)

Update timezone data on RedHat-like servers using fabric


 / Published in: Python
 

URL: fab_yum_up_tzdata

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

  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')

Report this snippet  

You need to login to post a comment.