Return to Snippet

Revision: 67477
at September 26, 2014 17:48 by alces


Initial Code
from fabric.api import env, hide, run, task
import re

env.user = 'root'

@task(default=True)
def tz_up():
	upd = []
	with hide('output'):
		for pkg in run('rpm -qa').split('\n'):
			if re.search('^tzdata-', pkg): upd.append(re.sub('-\d.*$', '', pkg))
		if upd:
			run('yum update -q -y ' + ' '.join(upd))
			run('cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime')

Initial URL
fab_yum_up_tzdata

Initial Description
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**

Initial Title
Update timezone data on RedHat-like servers using fabric

Initial Tags
python

Initial Language
Python