I have change my hosts file,so how to change hostname.my system is ubuntu. eg my hosts file:
192.168.0.100 host1.mydomain.com
192.168.0.101 host2.mydomain.com
I wanna the hostname file under /etc/hostname of host1 to host1.mydomain.com,the hostname file of host2 to host2.mydomain.com
how to do that using fabric? I have to ssh every host and edit the hostname file,does fabric can do this?
I didn't mean to use hostname
command but to edit the /etc/hostname file.
I mean how to use fabric to do that:
such as:
def update_hostname():get("/etc/hosts","hosts")hosts_content = file("hosts")**hostname = ·get the hostname corespond to ip·**get("/etc/hostname","hostname")update `hostname file`put("hostname","/etc/hostname")
how get the ip? because fabric do the job on every host, and the hostname is correspond to each host. I need to know the which host the job is working and then get the ip back,then get the hostname correspond the the ip,and final update the hostname file.