
January 27th, 2013, 10:29 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 5
Time spent in forums: 2 h 1 m 42 sec
Reputation Power: 0
|
|
|
I found the solution and tested this successfully on local system but when i used fabric module to deploy in remote system, it modify the local hosts file and not remote. where i am wrong ? no errors reported.
[root@lb1oraoemc1p hp]# cat fabfile.py
#!/usr/bin/python
from fabric.api import cd,env,put,run
import fileinput,sys
env.hosts=['root@xyz'] # remote hostname xyz
f = open('/etc/default/xymon-client')
m = f.read().replace('XYMONSERVERS=""','XYMONSERVERS=aaa.xyz.com')
print m
f.close()
f = open('/etc/default/xymon-client','w')
f.write(m)
f.close()
with open("/etc/default/xymon-client","a") as myfile:
myfile.write("CLIENTHOSTNAME=bbb.xyz.com")
run('service xymon start')
|